All pastes #124876 Raw Edit

imk

public c v1 · immutable
·published 2006-08-10 08:31 UTC
rendered paste body
#include <pspkernel.h>#include <pspdebug.h>//#include <stdlib.h>//#include <string.h>PSP_MODULE_INFO("THREADTEST", 0x1000, 1, 1);PSP_MAIN_THREAD_ATTR(0);#define printf	pspDebugScreenPrintfint done = 0;int exit_callback(int arg1, int arg2, void *common) {  done = 1;  sceKernelExitGame();  return 0;}int CallbackThread(SceSize args, void *argp) {  int cbid;  cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);  sceKernelRegisterExitCallback(cbid);  sceKernelSleepThreadCB();  return 0;}int SetupCallbacks(void) {  int thid = 0;  thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);  if(thid >= 0) {    sceKernelStartThread(thid, 0, 0);  }  return thid;}int thread1(SceSize args, void *argp) {  while(!done) {    printf("Thread 1 working!\n");    sceKernelDelayThread(5000 * 1000);  }  return 0;}int thread2(SceSize args, void *argp) {  while(!done) {    printf("Thread 2 working!\n");    sceKernelDelayThread(5000 * 1000);  }  return 0;}int thread3(SceSize args, void *argp) {  while(!done) {    printf("Thread 3 working!\n");    sceKernelDelayThread(5000 * 1000);  }  return 0;}int main(void) {  SetupCallbacks();  SceUID th1id;  SceUID th2id;  SceUID th3id;  pspDebugScreenInit();  pspDebugScreenClear();  th1id = sceKernelCreateThread("thread1", thread1, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);  sceKernelStartThread(th1id, 0, NULL);  if (th1id < 0) {    printf("Error! Thread 1 could not be created!\n");    sceKernelSleepThread();  }  th2id = sceKernelCreateThread("thread2", thread2, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);  sceKernelStartThread(th2id, 0, NULL);  if (th2id < 0) {    printf("Error! Thread 1 could not be created!\n");    sceKernelSleepThread();  }  th3id = sceKernelCreateThread("thread3", thread3, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);  sceKernelStartThread(th3id, 0, NULL);  if (th3id < 0) {    printf("Error! Thread 1 could not be created!\n");    sceKernelSleepThread();  }  while (!done) {    printf("Main loop!\n");    sceKernelDelayThread(1000 * 1000);  }  return 0;}