Concurrent programming for embedded system

Discussion in 'Homework Help' started by questionmark, Nov 6, 2011.

  1. questionmark

    Thread Starter New Member

    Nov 6, 2011
    2
    0
    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;
    }
     
  2. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    This seems like homework from a class course. Am I right? For that reason, I have moved your question in the Homework Help section.

    This section requires you to post your efforts before receiving help. Write your thoughts on the approach to tackle the problem.
     
Loading...