Solution ²need error detection mechanism eg CHECKSUM ² need error correction

Solution ²need error detection mechanism eg checksum

This preview shows page 50 - 56 out of 56 pages.

± Solution ² need error detection mechanism, e.g. CHECKSUM ² need error correction mechanism, e.g. retransmission
Image of page 50
Cooperating Processes ° Concurrent Processes can be ± Independent processes ² cannot affect or be affected by the execution of another process. ± Cooperating processes ² can affect or be affected by the execution of another process. ° Advantages of process cooperation: ² Information sharing ² Computation speedup ² Modularity ² Convenience(e.g. editing, printing, compiling) ° Concurrent execution requires ² process communication and process synchronization
Image of page 51
Producer-Consumer Problem ° Paradigm for cooperating processes; ± producer process produces information that is consumed by a consumer process. ° We need buffer of items that can be filled by producer and emptied by consumer. ± Unbounded-buffer places no practical limit on the size of the buffer. Consumer may wait, producer never waits. ± Bounded-buffer assumes that there is a fixed buffer size. Consumer waits for new item, producer waits if buffer is full. ± Producer and Consumer must synchronize.
Image of page 52
Producer-Consumer Problem
Image of page 53
Bounded-buffer - Shared Memory Solution ° Shared data var n ; type item = ….; var buffer : array [0..n-1] of item ; in , out : 0.. n -1; in :=0; out := 0; /* shared buffer = circular array */ /* Buffer empty if in == out */ /* Buffer full if ( in +1) mod n == out */ /* noop means ‘do nothing’ */
Image of page 54
Bounded Buffer - Shared Memory Solution ° Producer process - creates filled buffers repeat produce an item in nextp while in +1 mod n = out do noop ; buffer[in] := nextp ; in := in+1 mod n ; until false ;
Image of page 55
Bounded Buffer - Shared Memory Solution ° Consumer process - Empties filled buffers repeat while in = out do noop ; nextc := buffer[out] ; out := out +1 mod n ; consume the next item in nextc until false
Image of page 56

You've reached the end of your free preview.

Want to read all 56 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors