Assignment 2 CS703 Operating Systems
Assignment 2
Instructions
1. Due Date: Friday, April 18th, 2025.
2. Please write your own solutions.
Questions
Please use the answer sheet provided to write all your answers.
1. Consider the traffic deadlock depicted in Figure 1.
a. Show that the four necessary conditions for deadlock indeed hold in this example.
b. State a simple rule for avoiding deadlocks in this system.
Figure 1 Traffic deadlock.
2. The Cigarette-Smokers Problem. Consider a system with three smoker processes 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 processes has paper, another has
tobacco, and the third has matches. The agent has an infinite 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 ingredients,
and the cycle repeats. Write a program to synchronize the agent and the smokers.
In your solution, first define the semaphores that you need, give their initial values. Then write pseudo-code
for 4 processes, 1 for the agent, and 1 for each smoker.
1 CS703 - Operating Systems
3. Consider a paging system with the page table stored in memory.
a) If a memory reference takes 260 nanoseconds, how long does a paged memory reference take?
b) If we add TLB, 80 percent of all page-table references are found in the TLB, while accessing TLB takes
15 nanoseconds. What is the effective memory reference time?
4. Considering a 16 bits system, use a linear translate page table with the following assumptions:
• The page size is 32 bytes;
• The virtual address space for the process is 512 pages or 16KB;
• Physical Memory consists of 128 pages.
• Every entry in the page table has one extra VALID bit
• Page entry per page is 32 PTEs.
a) Please design this linear translate page table in detail, including the format of the PTE and
virtual/physical address and the meaning of each part.
b) Is this page table effective? If not, how to improve it? Describe the improved page table in detail.
5. Given the following reference string:
1, 3, 2, 4, 4, 2, 5, 1, 6, 7, 8, 7, 8, 9, 7, 8, 9, 4, 5, 4, 5, 3
Run (a) the Optimal page replacement algorithm, (b) the LRU page replacement algorithm on the above
reference string with a 4 free frame physical memory and computing the number of page faults on that string,
respectively.
2 CS703 - Operating Systems