Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void wait(int semaphoreIndex) {
- struct semaphore *Sem = &Forks[semaphoreIndex];
- Sem->count-- ;
- if (Sem->count < 0) {
- // Find the sem queue tail
- struct PCB *SQT = Sem->Sem_Queue;
- while (SQT->Next_PCB != NULL) {
- SQT = SQT->Next_PCB;
- }
- // Add process to the end of the sem queue
- SQT->Next_PCB = Current;
- SQT->Next_PCB->Next_PCB = NULL;
- printf("Process PID: %d was BLOCKED\n", Current->PID);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement