Reference no: EM133119209
Question:
Create a Deadlock Prevention program that submits processes to the Ready State only if they can be allocated all of the devices they request for execution. The server has a list of total resources, such as scanner, laser printer, and 3-D printer and a total number of devices for each. A client is prompted to enter a given device (for example "S", "L" or "D") and the number of instances of that device needed. Such a request is sent to the server by several clients. If the full request for devices cannot be allocated for this client, none of the devices will be allocated and the client request is rejected with a message back to the client. If the full request for devices can be satisfied, this client is allowed to be placed in the Ready State. Use appropriate print statements to indicate whether or not device requests are satisfied, thus allocated. When at least 3 clients have been added successfully to the Ready state, the server "runs" the client processes that are in the Ready State (by adding the CPU burst to a "clock"). As each process completes, its resources will be deallocated and added back to the available resources. Show the initial list of resources, the available resources after they have been allocated for each client, and the final list of resources when a process completes. Report to each client its individual turn around time and the average turnaround time for all client processes.
Assume that all processes arrive at time 0. Format your output to one place after the decimal.
For example:
Total Devices: 5 scanners, 3 laser printers, 6 3_D Message on server: S5 L3 D6 available
printers
Request from client1: S2, L0, D3, cpu burst 22 Message on server: S2L0D3 allocated
Message on server: S3L3 D3 available
Request from client2: S1, L2, D2, cpu burst 17 Message on server: S1L2D2allocated
Message on server: S2 L1 D1 available
Request from client3: S3, L1, D1, cpu burst 33 Message on server: S2 L1 D1rejected
Message from server to client 3: not enough resources
Request from client4: S1, L1, D1, cpu burst 8 Message on server: S1L1D1 allocated
Message on server: S1 L0 D0 available
Client programs are now in Ready and have been allocated resources...
Returned to client1 from server: 22 (turnaround time), 15.7 (average turnaround time)
Message on server: S3 L0D3 available
Returned to client2 from server: 39 (turnaround time), 15.7 (average turnaround time)
Message on server: S4 L2 D5 available
Returned to client4 from server: 47 (turnaround time), 15.7 (average turnaround time)
Message on server: S5 L3 D6 available
Please note: My messages have been abbreviated to fit on the page. Your output can be more descriptive.