[NSWI004] Notes on minimum quantum

Vojtech Horky horky at d3s.mff.cuni.cz
Thu Dec 12 11:01:13 CET 2019


Hello,

we discussed yesterday when to reset the timer for scheduler and what 
values to use.

I did some quick experiments on my version of the solution and observed 
the following.

Setting the quantum below 200 does not make sense because that is 
roughly the number of instructions that takes thread_yield() and nested 
calls. Practically, values below 500 mean that the kernel spends more 
time in context switch than in some useful work.

Values below 1000 still result in very slow execution, especially when 
debug prints are turned on (at least on my code, the slowdown was 
unproportionally bigger that the quantum reduction).

So if your code time-outs, try increasing the quantum.

However, if your code is failing with a reasonable quantum, you probably 
have a race condition somewhere.

Also note that it makes sense to set the quantum with each re-schedule 
as otherwise the quantum after thread_yield() is not reset for the next 
thread.

Hope this helps,
- VH


More information about the NSWI004 mailing list