Answered You can hire a professional tutor to get the answer.

QUESTION

The system used a shared buffer that would accept blocks of characters from a measurement process P1 and forward blocks of data to the output...

The system used a shared buffer that would accept blocks of characters from a measurement process P1 and forward blocks of data to the output process, P2.  The designer has written the following routines, one for P1 and one for P2.

      full = 0

      max = buffer size

          p1Generate( )                                          p2Transmit( )

      {                                                           {

P2

P1

head

buffer

while (full < max)                                   while (full > 0)

{                                                           {

      buffer(head) = anItem;                           anItem  = buffer(head);

      (head = head + 1) mod max;                  (head = head - 1) mod max;

      full++ ;                                                  full--;

}                                                           }

            }                                                           }

Occasionally the system either looses data or forwards garbage data.

Can you explain why?

Please propose (in detail) a way to fix the problem.  Modify the existing code as necessary.

Please show how your design solves the problem.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question