static void indentnum(uintptr_t num) { /* print the number num num times, indented by 5*num spaces * Not terribly interesting, but it is instructive. */ printf("Greetings from Thread %d. Yielding...\n",(int)num); lwp_yield(); printf("I'm still alive. Goodbye\n"); exit(0); }
static void indentnum(uintptr_t num) { /* print the number num num times, indented by 5*num spaces * * Not terribly interesting, but it is instructive. * */ int id; id = (int)num; printf("Greetings from Thread %d. Yielding...\n",id); lwp_yield(); printf("I (%d) am still alive. Goodbye.\n",id); lwp_exit(); }
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); }
static void indentnum(void *num) { /* print the number num num times, indented by 5*num spaces * Not terribly interesting, but it is instructive. */ int howfar,i; howfar=(int)num; /* interpret num as an integer */ for(i=0;i<howfar;i++){ printf("%*d\n",howfar*5,howfar); lwp_yield(); /* let another have a turn */ } lwp_exit(); /* bail when done. This should * be unnecessary if the stack has * been properly prepared */ }
static void indentnum(uintptr_t num) { /* print the number num num times, indented by 5*num spaces * Not terribly interesting, but it is instructive. */ int howfar,i; howfar=(int)num; /* interpret num as an integer */ for(i=0;i<ITERS;i++){ printf("%*d\n",howfar*5,howfar); if ( num == NUMTHREADS && i == ITERS - 3 ) { checktids(); exit(EXIT_SUCCESS); } lwp_yield(); /* let another have a turn */ } lwp_exit(); /* bail when done. This should * be unnecessary if the stack has * been properly prepared */ }
int ldap_pvt_thread_yield( void ) { lwp_yield( SELF ); return 0; }