Hello Guys,
I got a question that i don't know how to answer, can someone help me please? Thanks
Consider the following code segment which are synchronized using the atomic TestandSet instruction. Assume count=10 and process 1 starts first and the global variable occ is initialized as false. The variable "code" is an internal variable to each process. Does this code ensure the desired properties of mutual exclusion, lack of deadlock and eventual entry? Please explain to me why.
Process P1::
while(1){
Entry Protocol:
TestandSet(occ);
while(code) {
nop;
}
Critical Section:
count = count+1;
Exist Protocol:
occ=false;
}
Process P2::
while(1){
Entry Protocol:
TestandSet(occ);
while(code) {
nop;
}
Critical Section:
count = count-1;
Exist Protocol:
occ=false;
}
I got a question that i don't know how to answer, can someone help me please? Thanks
Consider the following code segment which are synchronized using the atomic TestandSet instruction. Assume count=10 and process 1 starts first and the global variable occ is initialized as false. The variable "code" is an internal variable to each process. Does this code ensure the desired properties of mutual exclusion, lack of deadlock and eventual entry? Please explain to me why.
Process P1::
while(1){
Entry Protocol:
TestandSet(occ);
while(code) {
nop;
}
Critical Section:
count = count+1;
Exist Protocol:
occ=false;
}
Process P2::
while(1){
Entry Protocol:
TestandSet(occ);
while(code) {
nop;
}
Critical Section:
count = count-1;
Exist Protocol:
occ=false;
}