Topic 1: SIMULATION: CPU SCHEDULING ALGORITHMS COMPARISON Overview: In this project, you'll implement and evaluate the f
Posted: Sun May 15, 2022 12:48 pm
Topic 1: SIMULATION: CPU SCHEDULING ALGORITHMS COMPARISON Overview: In this project, you'll implement and evaluate the following four different CPU scheduling algorithms by writing a CPU simulator. First Come First Serve (FCFS) The first come first serve algorithm is simplest CPU-scheduling algorithm. In this algorithm, the process at the head of the queue is allowed to execute until it voluntarily leaves the CPU due to either termination or an 1/0 request. In other words, the first come first serve algorithm is a non-preemptive CPU scheduling algorithm. Shortest Job First (SJF)(Non-preemptive) The shortest job first algorithm is a priority based scheduling algorithm that associates with each process the length of the process's next CPU burst. When CPU is available, it is assigned to the process that has the smallest next CPU burst. Shortest Remaining Time Next (SRTN)(Preemptive) The shortest remaining process next scheduling algorithm is the preemptive Shortest Job First algorithm. With this scheduling algorithm, the process in the ready queue with the shortest execution time is chosen to execute. If a "new process" arrives in the ready queue with a CPU service time less than the remaining time of the current process, preempt. Roundrobin (RR) The roundrobin algorithm is similar to FCFS scheduling algorithm, but preemption is added to switch between processes. The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum. Your Task Given a set of processes to execute with CPU and I/O requirements, your CPU simulator should simulate the execution of these processes based on a given CPU scheduling policy. Your simulation should collect the following statistics: the CPU utilization (NOT CPU efficiency), the total time required to execute the set of processes, and the service time (or CPU time), 1/0 time, and turnaround time for each individual process.
Your simulation structure should be event-driven simulation, which is the most common simulation model. At any given time, the simulation is in a single state. The simulation state can ONLY change at event times, where an event is defined as an occurrence that MAY change the state of the system. Events in this CPU simulation are the following: process arrival and the transition of a process state (e.g., when an interrupt occurs due to a time slice, the process moves from running state to ready state) Each event occurs at a specified time. Since the simulation state only changes at an event, the clock can be advanced to the next most recently scheduled event. (Thus the term next event simulation model.) Events are scheduled via an event queue. The event queue is a sorted queue which contains "future" events; the queue is sorted by the time of these "future" events. The event queue is initialized to contain the arrival of the processes and the first occurrence of the timer interrupt. The main loop of the simulation consists of processing the next event, perhaps adding more future events in the queue as a result, advancing the clock, and so on until all processes terminate. In the end, you should compare the following scheduling policy: 1. First Come First Serve
2. Shortest Job First, without preemption 3. Shortest Job First, or shortest-remaining-time-first; preemption 4. Round Robin, with the quantum 10. 5. Round Robin, with time quantum 50. 6. Round Robin, with time quantum 100. Simulation Execution Your simulation program will be invoked as: sim (-d] [-v] [-a algorithm] <input_file where -d stands for detailed information, -v stands for verbose mode, and -a stands for the execution of a given algorithm (only FCFS, SJF, SRTN, RR with time quantum 10, RR with time quantum 50, and RR with time quantum 100 should be acceptable input). You can assume only these flags will be used with your program, and that they will appear in the order listed. The output for the default mode (i.e., no flags), the detailed information mode, the verbose mode, and the algorithm mode is defined in the output format section. The -d, -v, and -a flags may be used separately or together. Input Format The simulator input includes the number of processes that require execution, the process switch overhead time i.e., the number of time units required to switch to a new process), and, for each process, the arrival time and the number of CPU execution bursts the process requires; the CPU execution bursts are separated by time the process does 1/0. You should assume an infinite number of 1/0 devices. In other words, processes do not need to wait to do 1/0. Also, no overhead is associated with placing a process on, or removing a process from, an I/O device. Also, you should assume the processes listed in the input file will be in the order that the processes arrive. Since a process must exit from the system while in the executing state, the last task of a process is a CPU burst. All these simulation parameters are integers. Your simulator obtains these parameters from the input file, which is in the following format. number_of_processes process_switch number 1 time subori
In the executing state, the last task or a process is a tru burst. All these simulation parameters are integers. Your simulator obtains these parameters from the input file, which is in the following format. number_of_processes process_switch process number arrival time numberl 1 cpu_time io_time 2 cpu_time io_time numberl cpu_time process number arrival time number2 1 cpu_time io_time 2 cpu_time io_time number2 cpu_time The following is an example input file to the CPU simulation: 4 5 1 0 6 1 15 400 2 18 200 3 15 100 4 15 400 5 25 100 6 240 2 12 4 1 4 150
Your simulation structure should be event-driven simulation, which is the most common simulation model. At any given time, the simulation is in a single state. The simulation state can ONLY change at event times, where an event is defined as an occurrence that MAY change the state of the system. Events in this CPU simulation are the following: process arrival and the transition of a process state (e.g., when an interrupt occurs due to a time slice, the process moves from running state to ready state) Each event occurs at a specified time. Since the simulation state only changes at an event, the clock can be advanced to the next most recently scheduled event. (Thus the term next event simulation model.) Events are scheduled via an event queue. The event queue is a sorted queue which contains "future" events; the queue is sorted by the time of these "future" events. The event queue is initialized to contain the arrival of the processes and the first occurrence of the timer interrupt. The main loop of the simulation consists of processing the next event, perhaps adding more future events in the queue as a result, advancing the clock, and so on until all processes terminate. In the end, you should compare the following scheduling policy: 1. First Come First Serve
2. Shortest Job First, without preemption 3. Shortest Job First, or shortest-remaining-time-first; preemption 4. Round Robin, with the quantum 10. 5. Round Robin, with time quantum 50. 6. Round Robin, with time quantum 100. Simulation Execution Your simulation program will be invoked as: sim (-d] [-v] [-a algorithm] <input_file where -d stands for detailed information, -v stands for verbose mode, and -a stands for the execution of a given algorithm (only FCFS, SJF, SRTN, RR with time quantum 10, RR with time quantum 50, and RR with time quantum 100 should be acceptable input). You can assume only these flags will be used with your program, and that they will appear in the order listed. The output for the default mode (i.e., no flags), the detailed information mode, the verbose mode, and the algorithm mode is defined in the output format section. The -d, -v, and -a flags may be used separately or together. Input Format The simulator input includes the number of processes that require execution, the process switch overhead time i.e., the number of time units required to switch to a new process), and, for each process, the arrival time and the number of CPU execution bursts the process requires; the CPU execution bursts are separated by time the process does 1/0. You should assume an infinite number of 1/0 devices. In other words, processes do not need to wait to do 1/0. Also, no overhead is associated with placing a process on, or removing a process from, an I/O device. Also, you should assume the processes listed in the input file will be in the order that the processes arrive. Since a process must exit from the system while in the executing state, the last task of a process is a CPU burst. All these simulation parameters are integers. Your simulator obtains these parameters from the input file, which is in the following format. number_of_processes process_switch number 1 time subori
In the executing state, the last task or a process is a tru burst. All these simulation parameters are integers. Your simulator obtains these parameters from the input file, which is in the following format. number_of_processes process_switch process number arrival time numberl 1 cpu_time io_time 2 cpu_time io_time numberl cpu_time process number arrival time number2 1 cpu_time io_time 2 cpu_time io_time number2 cpu_time The following is an example input file to the CPU simulation: 4 5 1 0 6 1 15 400 2 18 200 3 15 100 4 15 400 5 25 100 6 240 2 12 4 1 4 150