void male(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; //(void)which; male_start(); // Implement this function //extern int male_tail, female_head, female_tail; //extern unsigned long male_pop[]; //extern struct lock *pop_lock; //extern struct cv *maker_cv; lock_acquire(pop_lock); male_pop[male_tail++] = which; if(female_head != female_tail) cv_signal(maker_cv, pop_lock); lock_release(pop_lock); male_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 male(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; male_start(); lock_acquire(male_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(male_lock); male_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 male(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; male_start(); V(malesem); P(testsem); //P(matchmakersem); /*V(testsem); V(testsem); V(testsem); P(testsem); */ //male_cnt++; male_end(); //V(testsem2); //V(matchmakersem); //V(femalesem); // 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 male(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; male_start(); lock_acquire(hold); V(male_sem); male_count++; if(female_count!=0) cv_signal(mate_cv,hold); else cv_wait(mate_cv,hold); lock_release(hold); // Implement this function male_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 male(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; male_start(); kprintf("SStarting Male %lu\n",which); lock_acquire(wm_lock); males++; cv_signal(wm_mmcv,wm_lock); cv_wait(wm_mcv,wm_lock); kprintf("Releasing Male"); lock_release(wm_lock); male_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 male(void *p, unsigned long which) { struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p; (void)which; male_start(); lock_acquire(whaleLock); // Implement this function if (wchan_isempty(femaleCv->cv_wchan) || wchan_isempty(matchMakerCv->cv_wchan)) { cv_wait(maleCv,whaleLock); }else{ cv_signal(femaleCv,whaleLock); cv_signal(matchMakerCv,whaleLock); } lock_release(whaleLock); male_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; }