int main(int argc, char *argv[]){ long i; /* spawn a number of individual LWPs */ for(i=0;i<1;i++) lwp_create((lwpfun)indentnum,(void*)i,INITIALSTACK); lwp_start(); return 0; }
int main(int argc, char *argv[]){ if ( argc == -1 ) { /* can't happen, but the linker doesn't know it. */ /* these are all the required external symbols */ lwp_create(NULL,NULL,0); lwp_exit(); lwp_yield(); lwp_start(); lwp_stop(); lwp_set_scheduler(NULL); } printf("Linked successfully.\n"); exit(0); }
int main(int argc, char *argv[]){ int i,cnt,err; snake s[MAXSNAKES]; err = 0; for (i=1;i<argc;i++) { /* check options */ fprintf(stderr,"%s: unknown option\n",argv[i]); err++; } if ( err ) { fprintf(stderr,"usage: %s [-z]\n",argv[0]); exit(err); } install_handler(SIGINT, (sigfun)kill_snake); /* SIGINT will kill a snake */ install_handler(SIGQUIT,(sigfun)lwp_stop); /* SIGQUIT will stop the system */ start_windowing(); /* start up curses windowing */ /* Initialize Snakes */ cnt = 0; /* snake new_snake(int y, int x, int len, int dir, int color) ;*/ s[cnt++] = new_snake( 8,30,10, E,1);/* each starts a different color */ s[cnt++] = new_snake(10,30,10, E,2); s[cnt++] = new_snake(12,30,10, E,3); s[cnt++] = new_snake( 8,50,10, W,4); s[cnt++] = new_snake(10,50,10, W,5); s[cnt++] = new_snake(12,50,10, W,6); s[cnt++] = new_snake( 4,40,10, S,7); /* Draw each snake */ draw_all_snakes(); /* turn each snake loose as an individual LWP */ for(i=0;i<cnt;i++) { s[i]->lw_pid = lwp_create((lwpfun)run_hungry_snake,(void*)(s+i), INITIALSTACK); } lwp_start(); /* returns when the last lwp exits */ end_windowing(); /* close down curses windowing */ printf("Goodbye.\n"); /* Say goodbye, Gracie */ return err; }
int main(int argc, char *argv[]){ long i; printf("Creating LWPS\n"); /* spawn a number of individual LWPs */ for(i=1;i<=5;i++) { lwp_create((lwpfun)indentnum,(void*)i,INITIALSTACK); } printf("Setting the scheduler.\n"); lwp_set_scheduler(AltRoundRobin); printf("Launching LWPS\n"); lwp_start(); /* returns when the last lwp exits */ printf("Back from LWPS.\n"); return 0; }
int main(int argc, char *argv[]){ long i; srandom(0); /* so it's repeatable */ lwp_set_scheduler(Random); printf("Launching LWPS\n"); /* spawn a number of individual LWPs */ for(i=1;i<=NUMTHREADS;i++) { lwp_create((lwpfun)indentnum,(void*)i,INITIALSTACK); } lwp_start(); /* returns when the last lwp exits */ printf("Back from LWPS.\n"); return 0; }
int main(int argc, char *argv[]){ int i; for (i=1;i<argc;i++) { /* check options */ if ( !strcmp(argv[i],"-z") ){ /* -z = schedule element 0 */ lwp_set_scheduler(AlwaysZero); } else { fprintf(stderr,"%s: unknown option\n",argv[i]); exit(-1); } } printf("Launching LWPS\n"); /* spawn a number of individual LWPs */ for(i=1;i<=5;i++) { new_lwp((lwpfun)indentnum,(void*)i,INITIALSTACK); } lwp_start(); /* returns when the last lwp exits */ printf("Back from LWPS.\n"); return 0; }
int main() { lwp_create((lwpfun)counter,(void*)100,STACKSIZE); lwp_start(); exit(0); }