Assignment:
Simulator of the states of processes in an operating system
Phase# 1:
The first phase of the simulator will consist to develop effectively a QUEUE, which is a data structure that does a FIFO. This READY QUEUE must be capable of storing Process #, The time it will take to execute the process (0 <= Num <=25) and the description of the process (Word, Excel, Dev C++, etc.)
Process #
|
Time required
|
Process
|
1
|
18
|
Dev C++
|
2
|
3
|
Word Perfect
|
7
|
8
|
Flight Simulator
|
5
|
12
|
PowerPoint
|
9
|
7
|
Netscape
|
Hint: Create a QUEUE where you insert numbers like 1 2 3 4 5 6 and empty the QUEUE one by one, so the numbers after each pop would be 1 2 3 4 5 6
Phase #2:
Remove the first element inserted in the READY QUEUE and put it in the structure called CPU. Once in the CPU, the process would have 3 units of time to execute. Each unit of time would be executed pressing the key [ENTER] (on the keyboard). By pressing the [ENTER] key he simulator would subtract one unit of time to the process that is in the CPU structure.
Process ID Time required Description
17
16
15
Phase #3:
When the process in the CPU expires, the simulator will remove the process from the CPU and will put it at the end of other QUEUE where the processes are sleeping. When 3 units of time have passed (3 [Enter]s ), the simulator will remove the oldest process of this QUEUE and will put it in the Ready QUEUE.
Phase #4:
The simulator will insert a process in the READY QUEUE every 3 cycles ([ENTER]s) up to a maximum of 25 processes. If a process runs out of the time assigned for its execution the process will be removed from the simulator.
Phase #5:
The program must provide information about all the processes that the CPU had. In other words, it must show:
Ø Pid - Process ID
Ø States - ( Executing, Sleeping, Finished )
Ø Description (Word, FireFox, etc. )
Ø The time it will take to execute the process