#define N_CLASSES 10 int value_pass; int nwait = 0; int nwait_prio[N_CLASSES] = {0,0,...}; sem_t sync[N_CLASSES] = {0,0,...}; sem_t mutex = 1, mutex2 = 1; int wait(int w_prio, int max_proc){ int res; P(mutex); if (nwait >= max_proc){ V(mutex); return -1; }else{ nwait_prio[w_prio]++; nwait++; V(mutex); P(sync[w_prio]); P(mutex2); res = value_pass; nwait--; nwait_prio[w_prio]--; if (nwait_prio[w_prio]==0) V(mutex); V(mutex2); return res; } } int sblock(int s_prio, int value){ int c, res; P(mutex); if (nwait_prio[s_prio] > 0){ res = nwait_prio[s_prio]; value_pass = value; for(c=0; c