Page 2 of 2

Re: Task scheduler infinite loop

Posted: Fri Dec 13, 2013 9:22 am
by rdos
Combuster wrote:
ManyGifts wrote:Yes, I would like to use hardware task switching as it's my first kernel.
It's exactly the opposite: you do not want hardware task switching for reasons of simplicity.
Mostly you want to avoid hardware task switching because it doesn't work well with multicore CPUs, as the switching process is modifying descriptor types. Another problem is that you will often double save registers when using hardware task switching, which is caused by a badly designed interface where you must both load and save task state in one step. A typical software task switcher will first save the registers of the incoming task, select a new task, and then load a new task.

Re: Task scheduler infinite loop

Posted: Sat Dec 14, 2013 4:45 am
by linguofreak
bwat wrote:I don't think you've fully understood the terms you've used.
thomasloven wrote:Switching tasks when a process blocks helps in order to avoid bussy waiting
No. Switching tasks has nothing to do with avoiding busy waiting.
Busy waiting is when you continuously poll for a change in state.
In other words, it's when you're very busy doing nothing while you wait for something to do.
If the process blocks then it performs no work. The process cannot by definition be busy when blocked.


On a well designed system where the OS keeps a list of blocked processes that it then does not schedule to run, yes. On a crappily designed system where there's no such thing as blocking at the OS level, the process has to implement it itself, and the best it can do is busy waiting. In that case the process is both busy and blocked (or as close to blocked as you can get on such a system).