Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operating Systems. Part b ONLY answer for A is below already Three gardeners are together in a greenhouse with a vendor of gardening supplies. Each

image text in transcribed
Operating Systems. Part b ONLY answer for A is below already Three gardeners are together in a greenhouse with a vendor of gardening supplies. Each gardener needs three items to complete a planting: seeds, potting soil, and manure. The vendor has all of these in infinite quantities. One gardener has her own seeds, the second has his own potting soil, and the third has his own manure. The action begins when the vendor puts two ingredients on a table, allowing one gardener to do a planting. When the appropriate gardener is done, he or she wakes up the vendor, who then puts two more ingredients (at random) on the table, thus unblocking another gardener a.) Using semaphores, write programs for the gardeners and the vendor that solve this problem. (You may find it helpful to first consider the problem of one gardener and the vendor.) b.) turnin this part Using messages, write two solutions for this problem. In the first solution, make a straight-forward substitution of messages for semaphores; that is, replace each semaphore with a mailbox, and replace each P and V operation with Send/Receive as needed. In the second solution, use the messages to convey the items from the vendor to the gardener. Note that this solution eliminates the a.) global: table. semaphore plantingDone createsem(0); vendor waiting gardener specific semaphores* semaphore seeds createsem(O) semaphore soilcreatesem(0); semaphore manure createsem(0); process Vendor while () switch (random3pick a random gardener case 1 put soil and manure on the table V(seeds); wake up gardener Seeds/ break case 2: put seeds and manure on the table V(soil) wake up gardener Seeds / break; case 3 put seeds and soil on the table V(manure)wake up gardener Manure break; P(plantingDone);wait for gardener to finish/ process soil: while () process seeds: process manure: while (I) P(seedsd) get soil & manure; doe a planting: V(plantingDone); while (I) P(soil get seeds & manure; do a planting: V(plantingDone); P(manure); get soil & seeds; do a planting: V(plantingDone)

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

ISBN: 3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

Challenges Facing Todays Organizations?

Answered: 1 week ago