q5 (1) Computer Structures

The producer and consumer processes each communicate

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Consumer process. The Producer and Consumer processes each communicate directly only with the Filter process. The following is in Shared Memory (shared among Producer, Filter, and Consumer processes): Semaphore charsA=???, spaceA=???, charsB=???, spaceB=???; char buf[20]; char indata; int in=0, out=0; and the following code runs in the Filter Process: while (1) { char temp; /* loop forever… */ /* local variable */ wait(charsA); temp = buf[out]; out = (out+1)%20; signal(spaceA); temp = translate(temp); wait(spaceB); indata = temp; signal(charsB); /* increment ‘out’ modulo 20 */ /* do the actual translation */ } (A) (1 point) What is the maximum number of characters that can be produced by the Producer process but not yet processed b...
View Full Document

This document was uploaded on 02/27/2014 for the course COMSCI 6.004 at MIT.

Ask a homework question - tutors are online