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

# Solution ²need error detection mechanism eg checksum

• edwardtoo165
• 56

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
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
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.
Producer-Consumer Problem
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’ */
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 ;
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

#### You've reached the end of your free preview.

Want to read all 56 pages?

• One '20

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern