Starting from:

$25

CSE231 -Operating Systems - Assignment 3 - Solved

1           Modified Dining Philosophers Problem (60 points)
The dining philosophers problem contains five philosophers sitting on a round table can perform only one among two actions – eat and think. For eating, each of them requires two forks, one kept beside each person. Typically, allowing unrestricted access to the forks may result in a deadlock. (a) Write a program to simulate the philosophers using threads, and the forks using global variables. Resolve the deadlock using the following techniques:

1.    Strict ordering of resource requests, and

2.    Utilization of semaphores to access the resources.

(b) Repeat the above system only using semaphores now with a system that also has two sauce bowls. The user would require access to one of the two sauce bowls to eat, and can access any one of them at any point of time.


2           Interprocess Communication (50 points)
Write two programs P1 and P2. The first program P1 needs to generate an array of 50 random strings (of characters) of fixed length each. P1 then sends a group of five consecutive elements of the array of strings to P2 along with the ID’s of the strings, where the ID is the index of the array corresponding to the string. The second program P2 needs to accept the received strings, and send back the highest ID received back to P1 to acknowledge the strings received. The program P2 simply prints the ID’s and the strings on the console. On receiving the acknowledged packet, P1 sends the next five strings, with the string elements starting from the successor of the acknowledged ID.

The above mechanism needs to be implemented using three different techniques: (i) Unix domain sockets, (ii) FIFOs, and (iii) shared memory. Please note that you should NOT make assumptions about the reliability of the interprocess communication mechanism, unless they are guaranteed by the mechanism itself. You should also not use redundant mechanisms to guarantee reliability if the protocol itself guarantees it. Print the amount of time required to finish receiving the acknowledgment of all 50 strings in the three cases.


More products