Hi,
I have a working solution but I've just confused myself with why it works.
Could someone explain, for a simple command file as below with a time quantum of 5
#
shortsleep
5usecs exit
#
Why the output is as below? Particularly, after further thought I've confused myself as to why this process ever makes it from running back to ready. The process completes its computation of 5usecs within the time quantum allowance so wouldn't it just exit, making the total time since reboot 10?
Also if the transition from running to exit takes 0usecs, why does the time since reboot advance to 26usecs in the sample solution. Should it not be 25?
Many thanks.
@00*0*0*0 REBOOTING at Wed Sep 13 16:39:19, with timequantum=5
@00*0*0*0 spawn 'shortsleep', pid0.NEW->READY, transition takes 0usecs
@00*0*0*0 pid0.READY->RUNNING, transition takes 5usecs (1..5)
@00*0*0*1 + OS
@00*0*0*2 + OS
@00*0*0*3 + OS
@00*0*0*4 + OS
@00*0*0*5 + OS
@00*0*0*5 pid0 now on CPU, gets new timequantum shortsleep(onCPU=0)
@00*0*0*6 c shortsleep(onCPU=1)
@00*0*0*7 c shortsleep(onCPU=2)
@00*0*0*8 c shortsleep(onCPU=3)
@00*0*0*9 c shortsleep(onCPU=4)
@00*0*0*0 c shortsleep(onCPU=5)
@00*0*0*0 timequantum expired, pid0.RUNNING->READY, transition takes 10usecs (11..20)
@00*0*0*1 + OS
@00*0*0*2 + OS
@00*0*0*3 + OS
@00*0*0*4 + OS
@00*0*0*5 + OS
@00*0*0*6 + OS
@00*0*0*7 + OS
@00*0*0*8 + OS
@00*0*0*9 + OS
@00*0*0*0 + OS
@00*0*0*0 pid0.READY->RUNNING, transition takes 5usecs (21..25)
@00*0*0*1 + OS
@00*0*0*2 + OS
@00*0*0*3 + OS
@00*0*0*4 + OS
@00*0*0*5 + OS
@00*0*0*5 pid0 now on CPU, gets new timequantum shortsleep(onCPU=5)
@00*0*0*6 exit, pid0.RUNNING->EXIT, transition takes 0usecs shortsleep(onCPU=5)
@00*0*0*6 nprocesses=0, SHUTDOWN
@00*0*0*6 26usecs total system time, 5usecs onCPU by all processes, 5/26 -> 19%
measurements 26 19