Our implementation suffers from 1 second of delay at the first time slot. That is the reason why process s0 arrives at time slot 0 but it has to wait until time slot 1 to be used by the CPU.
- At time slot 1, process sO will execute in 2 time slots as the time slice is 2.
- Then at time slot 3, because there is no other process waiting for the CPU except for pro- cess s0, the CPU takes process s0 again.
- Process s1 arrives at time slot 4, but at that time, we have only one CPU but it is using for process sO, so process s1 has to be waiting for process s0.
Next, at time slot 5 when process s0 finishes, the CPU takes process s1 and executes it.
This process continues until all the 2 processes have finished. The program ends.
5.1.3 Testcase sched_1 Input content
- Time slide: 2 - Number of CPU: 1 - Number of processes: 4
ano ke ee 5 = 8 Sean =
Process | Arrival Time | Priority
s0 0 4
sl 4 1
s2 6 0
s3 7 2
0 1 3 5 7 9 1 3.5107 ot 2S ON ee OO re OO Ot A196 eee 58... 41... 43... 4548 s0 s0 s1 s2 s2 s2 s2 s2 s2 s1 S1 |s1| s3 s3 s3 s3 s3 s3. s0 s0 sO s0 sO (sO
Figure 7: The Gantt chart of sched_1
Time slice: 2, Number of CPUs: 1, Number of processes: 4 Start Time: 0, Process: sQ, Priority: 4
Start Time: 4, Process: si, Priority: 1 Start Time: 6, Process: s2, Priority: 0 Start Time: 7, Process: s3, Priority: 2 Time slot 9
ld_routine
Loaded a process at input/proc/sO, PID: i PRIO: 4 Time slot 1
CPU 0: Dispatched process 1 Process 1 executes calc Time slot 2
Process 1 executes calc Time slot 3
CPU 0: Put process i to run queue CPU 0: Dispatched process 1 Process 1 executes calc Time slot 4
Process 1 executes calc
Loaded a process at input/proc/si, PID: 2 PRIO: 1 Time slot 5
CPU 0: Put process i to run queue CPU 0: Dispatched process 2
Begin: Process 2 allocates 300 from RAM for register 0 Process 2 ALLOC CALL | SIZE = 300
[Page mapping] PID #2: Frame:0 PTE:80000000 PGN:O [Page mapping] PID #2: Frame:1 PTE:80000001 PGN:1 Region id
Process 2 Free Region list Start = 300, end = 512
VMA id 1 start = 0, end = 512, sbrk = 512
~—————————ơ RAM mapping status ---
Assignment for Operating System - Academic year 2023 - 2024 Page 39/82
Number of mapped frames: 2 Number of remaining frames: 4094
print_list_vma:
va [0->512]
End allocation process Time slot 6
Process 2 executes calc
Loaded a process at input/proc/s2, PID: 3 PRIO: 0 Time slot 7
CPU 0: Put process 2 to run queue CPU O0: Dispatched process 3 Process 3 executes calc
Loaded a process at input/proc/s3, PID: 4 PRIO: 2 Time slot 8
Process 3 executes calc Time slot 9
CPU O0: Put process 3 to run queue CPU O0: Dispatched process 3 Process 3 executes calc Time slot 10
Process 3 executes calc Time slot 11
CPU 0: Put process 3 to run queue CPU O0: Dispatched process 3 Process 3 executes calc Time slot 12
Process 3 executes calc Time slot 13
CPU 0: Put process 3 to run queue CPU O0: Dispatched process 3 Process 3 executes calc Time slot 14
Process 3 executes calc Time slot 15
CPU 0: Put process 3 to run queue CPU O0: Dispatched process 3 Process 3 executes calc Time slot 16
Process 3 executes calc Time slot 17
CPU 0: Put process 3 to run queue CPU O0: Dispatched process 3 Process 3 executes calc Time slot 18
Process 3 executes calc Time slot 19
CPU O: Processed 3 has finished CPU 0: Dispatched process 2 Process 2 executes calc Time slot 20
Process 2 executes calc
Time slot 21
CPU 0: Put process 2 to run queue CPU 0: Dispatched process 2 Process 2 executes calc Time slot 22
Process 2 executes calc Time slot 23
CPU O: Put process 2 to run queue CPU 0: Dispatched process 2 Process 2 executes calc Time slot 24
CPU O: Processed 2 has finished CPU 0: Dispatched process 4 Process 4 executes calc Time slot 25
Process 4 executes calc Time slot 26
CPU 0: Put process 4 to run queue CPU 0: Dispatched process 4 Process 4 executes calc Time slot 27
Process 4 executes calc Time slot 28
CPU 0: Put process 4 to run queue CPU 0: Dispatched process 4 Process 4 executes calc Time slot 29
Process 4 executes calc Time slot 30
CPU 0: Put process 4 to run queue CPU 0: Dispatched process 4 Process 4 executes calc Time slot 31
Process 4 executes calc Time slot 32
CPU 0: Put process 4 to run queue CPU 0: Dispatched process 4 Process 4 executes calc Time slot 33
Process 4 executes calc Time slot 34
CPU 0: Put process 4 to run queue CPU 0: Dispatched process 4 Process 4 executes calc Time slot 35
CPU 0: Processed 4 has finished CPU 0: Dispatched process 1 Process 1 executes calc Time slot 36
Process 1 executes calc Time slot 37
CPU O: Put process i to run queue CPU 0: Dispatched process 1 Process 1 executes calc Time slot 38
Process 1 executes calc Time slot 39
CPU O: Put process i to run queue
CPU O: Dispatched process 1 Process 1 executes calc Time slot 40
Process 1 executes calc Time slot 41
Time slot 42 Time slot 43
Time slot 44 Time slot 45
CPU O: Put process i to run queue CPU 0: Dispatched process 1 Process 1 executes calc Process 1 executes calc CPU O: Put process i to run queue CPU 0: Dispatched process 1 Process 1 executes calc Process 1 executes calc CPU O: Put process i to run queue CPU 0: Dispatched process 1 Process 1 executes calc Time
CPU 0: Processed slot 46
1 has finished CPU O stopped
RPS time of PID 1 RPS time of PID 2 RPS time of PID 3 is 1 RPS time of PID 4
is 1 is 1 is 17 Average RPS time: 5.00