N processes and M types of processes - enter and exit cs
- by sarit
i was asked to write: enter function and exit function for the following case:
there are N processes and M types of processes (NM)
tere is a critical section in which all processes with the same type can enter.
for example: if type A is in cs, type B cannot enter cs. but all processes with type A can enter.
i can use only mutex and "type" which is the type of the process.
deadlock is not allowed.
do you think this is ok?
shared: this.type = -1;
mutex m, m1=1;
enter{
down(m)
if (this.type == process.type) up(m1)
down(m1)
this.type= process.type
up(m)
}
exit {
this.type = -1
up(m1)
}
thanks!
(by the way, this is not HW... i have an exam and im solvig tests from previous years)