6-sol - CHAPTER Process Synchronization 6 Practice...

This preview shows pages 1–2. Sign up to view the full content.

6 CHAPTER Process Synchronization Practice Exercises 6.1 In Section 6.4 we mentioned that disabling interrupts frequently could affect the system’s clock. Explain why it could and how such effects could be minimized. Answer: The system clock is updated at every clock interrupt. If in- terrupts were disabled—particularly for a long period of time—it is possible the system clock could easily lose the correct time. The sys- tem clock is also used for scheduling purposes. For example, the time quantum for a process is expressed as a number of clock ticks. At every clock interrupt, the scheduler determines if the time quantum for the currently running process has expired. If clock interrupts were disabled, the scheduler could not accurately assign time quantums. This effect can be minimized by disabling clock interrupts for only very short periods. 6.2 The Cigarette-Smokers Problem . Consider a system with three smoker pro- cesses and one agent process. Each smoker continuously rolls a cigarette and then smokes it. But to roll and smoke a cigarette, the smoker needs three ingredients: tobacco, paper, and matches. One of the smoker pro- cesses has paper, another has tobacco, and the third has matches. The agent has an in±nite supply of all three materials. The agent places two of the ingredients on the table. The smoker who has the remaining ingredient then makes and smokes a cigarette, signaling the agent on completion. The agent then puts out another two of the three ingredi- ents, and the cycle repeats. Write a program to synchronize the agent and the smokers using Java synchronization. Answer:

This preview has intentionally blurred sections. Sign up to view the full version.

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

{[ snackBarMessage ]}

Page1 / 4

6-sol - CHAPTER Process Synchronization 6 Practice...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online