N processes and M types of processes - enter and exit cs
Posted
by sarit
on Stack Overflow
See other posts from Stack Overflow
or by sarit
Published on 2009-08-03T16:11:12Z
Indexed on
2010/05/04
4:08 UTC
Read the original article
Hit count: 545
i was asked to write: enter function and exit function for the following case:
there are N processes and M types of processes (N>>M) 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)
© Stack Overflow or respective owner