Two Concurrent Threads Need Access Shared Variable Count Follows Observer Forever Reporter Q10352169

Two concurrent threads need to access a shared variable count asfollows:

Observer: doforever                      Reporter: do forever

           observe anevent;                    print count;

           count := count +1;                   count := 0;

end                                                    end

Given the above two concurrent threads, show a scenario thatresults in an over-reporting of 2 occurrences and another inunder-reporting also of 2 occurrences of events, using the tablesbelow. Note that computer executes a program (thread) byinstructions, and it is due to interrupt between instructions thaterroneous results occur. Therefore, your will need to define theinstructions for the critical sections of Observer and Reporterbelow and show sequences of the execution of these instructions inthe tables.

Identify critical section in Observer, and defineinstructions         Identifycritical section in Reporter and define instructions

that implement this criticalsection:                                                     that implement this critical section:

Over-reporting

Event occurrence

#1

Instruction executed

Value of variable count (initially 0)

Value of variable (or register) internal to Observer

Value of variable (or register) internal to Reporter, which willbe sent to output

Under-reporting

Event

#1

Instruction executed

Value of variable count (initially 0)

Value of variable (or register) internal to Observer

Value of variable (or register) internal to Reporter, which willbe sent to output

"We Offer Paper Writing Services on all Disciplines, Make an Order Now and we will be Glad to Help"
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.