Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Given the two semaphore operations illustrated below; wait (x) { while x

Instructions

Given the two semaphore operations illustrated below;

wait (x)

{

while x <= 0

// No Operation

x--

}

Signal (x)

{

x++

}

And using (as an example and basis) the producer-consumer code as illustrated below;

Producer()

{

while (true)

{

item = produceitem()

wait(empty)

wait(binary)

additemtobuffer(item)

signal(binary)

signal(full)

}

}

Consumer()

{

while (true)

{

wait(full);

wait(binary);

takeitemfrombuffer(item);

signal(binary);

signal(empty);

consumeitem(item)

}

}

Then given the following information;

Three processes are involved in printing a file (pictured below);

Process A reads the file data from the disk to Buffer 1

Process B copies the data from Buffer 1 to Buffer 2

Process C takes the data from Buffer 2 and prints it

Assume all three processes operate on one (file) record at a time, both buffers' capacity are one record.

Write pseudo code (in the style of the producer-consumer) to coordinate the three processes using semaphores and successfully print a file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Consider this article:...

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago

Question

=+ What skills and competencies will enable someone

Answered: 1 week ago

Question

=+to live and work wherever he or she wants?

Answered: 1 week ago