educative.io

I think that simulator output is wrong

For MLFQ simulator, If we do
./mlfq.py -j 3
Then 3 jobs have below characteristics

Job List:  
Job  0: startTime   0 - runTime  84 - ioFreq   7  
`**Job  1: startTime   0 - runTime  42 - ioFreq   2**`  
Job  2: startTime   0 - runTime  51 - ioFreq   4

For Job -1 I/O frequence is 2
But if we check the output below, first time when the Job-1 is scheduled, it runs for 3 ticks before I/O comes. Why so, I/O should have come after 2 ticks only.

[ time 0 ] JOB BEGINS by JOB 0
[ time 0 ] JOB BEGINS by JOB 1
[ time 0 ] JOB BEGINS by JOB 2
[ time 0 ] Run JOB 0 at PRIORITY 2 [ TICKS 9 ALLOT 1 TIME 83 (of 84) ]
[ time 1 ] Run JOB 0 at PRIORITY 2 [ TICKS 8 ALLOT 1 TIME 82 (of 84) ]
[ time 2 ] Run JOB 0 at PRIORITY 2 [ TICKS 7 ALLOT 1 TIME 81 (of 84) ]
[ time 3 ] Run JOB 0 at PRIORITY 2 [ TICKS 6 ALLOT 1 TIME 80 (of 84) ]
[ time 4 ] Run JOB 0 at PRIORITY 2 [ TICKS 5 ALLOT 1 TIME 79 (of 84) ]
[ time 5 ] Run JOB 0 at PRIORITY 2 [ TICKS 4 ALLOT 1 TIME 78 (of 84) ]
[ time 6 ] Run JOB 0 at PRIORITY 2 [ TICKS 3 ALLOT 1 TIME 77 (of 84) ]
[ time 7 ] IO_START by JOB 0
IO DONE
[ time 7 ] Run JOB 1 at PRIORITY 2 [ TICKS 9 ALLOT 1 TIME 41 (of 42) ]
[ time 8 ] Run JOB 1 at PRIORITY 2 [ TICKS 8 ALLOT 1 TIME 40 (of 42) ]
[ time 9 ] Run JOB 1 at PRIORITY 2 [ TICKS 7 ALLOT 1 TIME 39 (of 42) ]
[ time 10 ] IO_START by JOB 1
IO DONE
[ time 10 ] Run JOB 2 at PRIORITY 2 [ TICKS 9 ALLOT 1 TIME 50 (of 51) ]

H @Brajesh_Agrawal, Thanks for reaching out to us.
When I run the same command ./mlfq.py -j 3, It’s working fine for me. For Job 1 ioFreq is 3, not 2. For reference, I have attached the screenshot here.

Consider running this command again, hopefully, you will get desired results.
Hope this helps!

1 Like