Question: make sure to write a full code that solve this task and test it after write the code you will simulate a CPU scheduling system
make sure to write a full code that solve this task and test it after write the code
you will simulate a CPU scheduling system combined with deadlock detection and recovery. The system consists of a single CPU core and several resource types, with only one instance of each resource type. The goal is to simulate the execution of processes, apply CPU scheduling, detect deadlocks, and recover from them.
Input format:
Your program will take as input a text file containing a list of processes. Each line in the file represents a process and has the following format:
PIDArrival TimePrioritySequence of CPU and IO bursts
Each process must start and finish with a CPU burst. Within CPU bursts, processes can request or release resources. For example, the input file might look like this:
CPU R F
CPU IO CPU R F
Explanation:
Process PID arrives at time has a priority of and consists of one CPU burst. During this burst, it requests resource R executes for time units, then releases resource F and terminates.
Process PID arrives at time also with priority and consists of two CPU bursts and one IO burst:
The first CPU burst lasts for units, followed by an IO burst lasting units. The second CPU burst executes for units, after which it requests resource R executes for units, releases resource F and finally finishes with more CPU units.
Your Task:
Simulate CPU Scheduling: Implement priority scheduling algorithm with round robin The simulation should continue until all the processes in the input file terminate.
Deadlock Detection and Recovery: Implement an appropriate deadlock detection algorithm to monitor the system status and identify deadlock situations. If a deadlock is detected, implement a deadlock recovery strategy of your choice eg process termination, resource preemption
At the end of simulation, your program must show the Gantt chart representing the timeline of process execution, average waiting time, and average turnaround time for all processes. Also report the detected deadlock states and how recovery was handled.
Remarks:
Testing: Start with simple input files to test your program and ensure its correctness. Gradually test with more complex scenarios.
Context Switching: Assume that the context switch time is negligible and can be ignored in the simulation.
IO Simulation: When a process finishes its CPU burst, it moves to the IO queue for the duration of its IO burst. Processes can perform IO simultaneously and do not wait for each other. When the IO burst is finished, the process goes back to the ready queue.
Resource Requests: If a process requests a resource that is currently held by another process, it should be moved to thewaiting queueuntil the resource becomes available. The process will remain in the waiting queue until the requested resource is released by the holding process.
Time Representation: Use a simple time counter for the simulation. The time units do not need to have any realworld meaning, but the simulation should track time correctly.
Singlethreaded Implementation: You can implement the simulation in a singlethreaded program. If you choose to implement it usingmultithreadingormultiprocessing ensure you handle synchronization correctly.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
