Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

Operating Systems Assignment Four: More IPC Problems

PROBLEM A:

Little rascals, Spanky, Alfalfa, and Darla are sitting around a table waiting to eat an ice cream sundae.  To eat a sundae, you need three things:jimmies, ice cream, chocolate sauce.

  • Spanky has ice cream and chocolate sauce.
  • Alfalfa has jimmies and chocolate sauce, and
  • Darla has jimmies and ice cream

Initially all three kids are "blocked."

Their lovely teacher, Miss Crabtree,   has an infinite supply of each item.  Miss Crabtree randomly places one item on the table, unblocking the kid who needs it, and then Miss Crabtree blocks (waits). The kid who needs that item takes it and eats. Only one item may be placed on a table at any time.  Each rascal waits for the one item he/she needs then consumes some ice cream for a random amount of time unblocking Miss Crabtree when he/she is done eating. Miss Crabtree then puts another item on the table and the scenario continues.

Write a program that synchronizes the threads such that deadlock does not occur and no little rascal starves. The output should specify which rascal is eating.

PROBLEM B:

Consider an orchestra conductor and a group of musicians. The musicians play independently but are coordinated by the conductor. For each measure of music indicated by the conductor's baton, the musicians play a set of notes. The musicians do not move onto the next measure until indicated by the conductor's baton. The Orchestra is called the Narcolepsy Symphony Orchestra because occasionally a musician falls asleep. When this happens the rest of the musicians continue playing. When the sleeping musician wakes up, the musician begins playing again with the orchestra.

Here are some guidelines:

  • Simulate 100 measures
  • Simulate 3 to 10 musicians
  • use one thread per musician. The thread doesn't die at the end of the measure... it lives for the duration of the piece.
  • use semaphores as the synchronization mechanism not pthread_join (since musician threads live across measures)
  • for each measure, there is a 25% chance that the musician will fall asleep
  • when a musician sleeps, it is for a random number of measures (say 1-5)... this is sleep amount is unknowable to the conductor.. the musician simply "wakes up" when it is ready to start playing again.
  • use the sleep method sleep() method to simulate sleep, sleeping players do a sleep(random 1-5) seconds to simulate sleeping.
  • do not to use sleep as a synchronization mechanism
  • in addition to outputting that it is playing, the musician thread should sleep(1) to simulate playing a measure...
  • provide feedback for each measure that looks something like this:

MEASURE 1:

Musician 3 playing

Musician 4 playing

Musician 1 playing

Musician 2 playing

MEASURE 2:

Musician 1 playing

Musician 3 playing

Musician 4 playing

MEASURE 3:

Musician 4 playing

Musician 1 playing

Musician 3 playing

MEASURE 4:

Musician 3 playing

Musician 2 playing

Note that: Musician 2 is sleeping in Measure 2 & 3 and Musicians 3 & 1 are sleeping in Measure 4

PROBLEM C:

Enhance the reader/writer problem we discussed in class using N readers and 1 writer so that the writer will not suffer from starvation.

Simulate readDB() and writeDB() using sleep().

Ensure that the delay for readDB() is much shorter than writeDB().

PROBLEM D:

Consider a doctor's office with a very overworked doctor.

The doctor has an examining room and a waiting room with a number of chairs in it. When the doctor finishes with a patient, the patient leaves and the doctor goes to the waiting room to see if there are other patients waiting. If there are, she brings one of them back to the examining room and examines the patient. If there are no patients waiting, she returns to her examining room, lies down on the examining table and goes to sleep.

Each patient (or I should say impatient), when he arrives, knocks on the examining room door to see what the doctor is doing. If the doctor is sleeping, then the patient wakes her up and enters the examining room. If the doctor is performing an examination, then the patient goes to the waiting room. If there is a free chair in the waiting room, the patient sits in it and waits his turn. If there is no free chair, then the patient leaves.

Assume there are 10 chairs in the waiting room. The doctor must be a thread. Each patient must be a thread, assume 13 patients, each running in an infinite loop to simulate arriving at the office, being examined (or not), then leaving... then repeat.

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M92023053

Have any Question?


Related Questions in Operating System

Question state the required answer precisely and then

Question : State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. What is the purpose of the command interpreter? Why is it usually separate fr ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

Question topic computerized operating systems os are almost

Question: Topic: Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use our phone or tablet. Find articles that describes the diff ...

Show all stepssuppose that the following processes arrive

Show all steps Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. in answering the questions, use non-preemptive scheduling and base all dec ...

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Consider a computer embedded in the control of a manned spacecraft. Would it require an ...

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As