void matchmaker(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; matchmaker_start(); // Implement this function //extern int male_head, male_tail, female_head, female_tail; //extern unsigned long male_pop[], female_pop[]; //extern struct lock *pop_lock; //extern struct cv *maker_cv; lock_acquire(pop_lock); while((male_head==male_tail)||(female_head==female_tail)) cv_wait(maker_cv, pop_lock); kprintf("Male %ld, Female %ld, and Maker %ld\n", male_pop[male_head++], female_pop[female_head++], which); lock_release(pop_lock); matchmaker_end(); // 08 Feb 2012 : GWA : Please do not change this code. This is so that your // whalemating driver can return to the menu cleanly. V(whalematingMenuSemaphore); return; }
void matchmaker(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; matchmaker_start(); lock_acquire(match_maker_lock); lock_acquire(thread_count_lock); thread_count++; if (thread_count == 3) { cv_broadcast(thread_count_cv, thread_count_lock); } else { cv_wait(thread_count_cv, thread_count_lock); } thread_count = 0; lock_release(thread_count_lock); lock_release(match_maker_lock); matchmaker_end(); // 08 Feb 2012 : GWA : Please do not change this code. This is so that your // whalemating driver can return to the menu cleanly. V(whalematingMenuSemaphore); return; }
void matchmaker(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; matchmaker_start(); lock_acquire(wm_lock); while(1) { cv_wait(wm_mmcv,wm_lock); lock_acquire(wm_lock); if(males > 0 && females > 0) { kprintf("Ready to match!"); break; } } cv_signal(wm_mcv,wm_lock); cv_signal(wm_fcv,wm_lock); males--; females--; lock_release(wm_lock); matchmaker_end(); // 08 Feb 2012 : GWA : Please do not change this code. This is so that your // whalemating driver can return to the menu cleanly. V(whalematingMenuSemaphore); return; }
void matchmaker(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; matchmaker_start(); // V(matchmakersem); P(malesem); P(femalesem); V(testsem); V(testsem2); /*P(testsem); V(testsem); V(testsem2); V(testsem2); V(testsem2); P(testsem2); */ matchmaker_end(); /*V(testsem2); V(femalesem); V(malesem); */ // 08 Feb 2012 : GWA : Please do not change this code. This is so that your // whalemating driver can return to the menu cleanly. V(whalematingMenuSemaphore); return; }
void matchmaker(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; matchmaker_start(); lock_acquire(hold); P(male_sem); male_count--; lock_release(hold); lock_acquire(hold); P(female_sem); female_count--; lock_release(hold); // Implement this function matchmaker_end(); // 08 Feb 2012 : GWA : Please do not change this code. This is so that your // whalemating driver can return to the menu cleanly. V(whalematingMenuSemaphore); return; }
void matchmaker(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; matchmaker_start(); lock_acquire(whaleLock); if (wchan_isempty(femaleCv->cv_wchan) || wchan_isempty(maleCv->cv_wchan)) { cv_wait(matchMakerCv,whaleLock); }else{ cv_signal(femaleCv,whaleLock); cv_signal(maleCv,whaleLock); } lock_release(whaleLock); matchmaker_end(); // 08 Feb 2012 : GWA : Please do not change this code. This is so that your // whalemating driver can return to the menu cleanly. V(whalematingMenuSemaphore); return; }