/* * Start the event handler. * Initializes the Hashtable, event queue, semaphores and starts * the main event manager thread. */ void em_startup() { int err; Error error; /* Init the the listnersHashTable */ listenersHashTable = HashCreateTable(1024, (HashFuncPtr)calcHashCode, (CompFuncPtr)compHashEntrys, (DestroyFuncPtr) freeListenerList); threading_mutex_init( &(listenersHashTableLock) ); /* Init the event handler thread */ assert( eventManagerThread == (pthread_t) NULL ); frontEvent = 0; backEvent = 0; err = sem_init( &eventsInQueue, 0, 0 ); assert( err == 0 ); threading_mutex_init( &eventQueueModificationLock ); assert( err == 0 ); /* So that we can access teh detachedThreadAttr variable */ threading_init(); /* The Event Manager Thread will be joined upon shutdown, and is therefore not created in a detached state */ err = threading_pthread_create( &eventManagerThread, NULL, em_mainLoop, NULL ); assert( err == 0 ); }
void main (int argc, char **argv) { // Init libxenon xenos_init(VIDEO_MODE_AUTO); console_init(); xenon_make_it_faster(XENON_SPEED_FULL); #if 0 threading_init(); network_init_sys(); #endif usb_init(); usb_do_poll(); xenon_ata_init(); xenon_atapi_init(); fatInitDefault(); #ifdef CAPS fatMountSimple("udb", &usb2mass_ops_1); printf("CAPTURE BUILD !!!\n"); #endif // Quake II char * newargv[] = { "uda:/q3.elf", //"+set", "game", "baseq2", "+set", "cddir", "uda:/baseq2/" "+set", "basedir" , "uda:/", "+set", "cddir", "uda:/baseq2/", "+set", "cl_maxfps", "400" }; int newargc = sizeof (newargv) / sizeof (char *); Qcommon_Init (newargc, newargv); console_close(); int time, oldtime, newtime; oldtime = Sys_Milliseconds(); while (1) { do { newtime = Sys_Milliseconds (); time = newtime - oldtime; } while (time < 1); Qcommon_Frame (time); oldtime = newtime; } }
int main(int argc, char *argv[]) { thread_t ** threads; struct thread_fun_params * params; int i; int nthreads, start, stride, end; if (argc < 5) { printf("Usage: %s <nthreads> <start> <stride> <end>\n", argv[0]); exit(1); } nthreads = atoi(argv[1]); start = atoi(argv[2]); stride = atoi(argv[3]); end = atoi(argv[4]); threads = malloc(nthreads*sizeof(thread_t*)); params = malloc(nthreads*sizeof(struct thread_fun_params)); assert(threads); assert(params); threading_init(); for (i = 0; i < nthreads; i++) { params[i].id = i; params[i].start = (i*10)+start; params[i].stride = stride; params[i].end = (i*10)+end; threads[i] = thread_create(thread_fun, ¶ms[i]); } printf("%d threads created, waiting for all of them\n", nthreads); for (i = 0; i < nthreads; i++) { thread_join(threads[i]); } printf("Finished\n"); threading_exit(); return 0; }
int x264_threading_init( void ) { LONG state; while( (state = InterlockedCompareExchange( &threading_is_init, -1, 0 )) != 0 ) { /* if already init, then do nothing */ if( state > 0 ) return 0; } if( threading_init() < 0 ) { InterlockedExchange( &threading_is_init, 0 ); return -1; } InterlockedExchange( &threading_is_init, 1 ); return 0; }
void Sys_PlatformInit( void ) { // Init libxenon xenos_init(VIDEO_MODE_AUTO); console_init(); xenon_make_it_faster(XENON_SPEED_FULL); http_output_start(); #if 0 threading_init(); network_init_sys(); #endif usb_init(); usb_do_poll(); xenon_ata_init(); xenon_atapi_init(); // fatInitDefault(); // XTAFMount(); // fatInit(16, 1); fatMount ("uda", &usb2mass_ops_0, 0, 256, 64); ListDevices(); Sys_SetEnv("HOME", "uda:/"); console_close(); }