Task-scheduling and what (not) to interrupt
Posted: Tue Dec 06, 2005 5:48 pm
I've been thinking a lot about (pre-emptive) multi-threading, or task scheduling whatever the name of the game.
The question on my mind is: are there some ground rules on what to switch away from and what not? For example, I can see problems developing if the current process where to syscall into the kernel for memory management or talking to a device drive. What happens if the time-slice of the process was up and the timer event fired and we switch away to another task?
The device driver may have to deal with device timings to not leave a device in an unknown state (or something) whereas a memory manager might have some problems with re-entrancy when it was doing some bookkeeping.
Now you of course could simply disable interrupts for such calls but I have a feeling that this might be a bit too broad to disable interrupts for.
Another thought was what if we simply modify the return call so it returns to the scheduler when the kernel task is done and it normally would've returned to the calling process. We should be able to safely switch away to another process at that point and return it back to the proper place when the next time-slice for this project comes up.
I've read a lot in the OS FAQ (great stuff, thanks!) and some multi-threading links but didn't really find much if anything on this.
Does anyone have some thoughts and/or experience on this subject?
Thanks!
The question on my mind is: are there some ground rules on what to switch away from and what not? For example, I can see problems developing if the current process where to syscall into the kernel for memory management or talking to a device drive. What happens if the time-slice of the process was up and the timer event fired and we switch away to another task?
The device driver may have to deal with device timings to not leave a device in an unknown state (or something) whereas a memory manager might have some problems with re-entrancy when it was doing some bookkeeping.
Now you of course could simply disable interrupts for such calls but I have a feeling that this might be a bit too broad to disable interrupts for.
Another thought was what if we simply modify the return call so it returns to the scheduler when the kernel task is done and it normally would've returned to the calling process. We should be able to safely switch away to another process at that point and return it back to the proper place when the next time-slice for this project comes up.
I've read a lot in the OS FAQ (great stuff, thanks!) and some multi-threading links but didn't really find much if anything on this.
Does anyone have some thoughts and/or experience on this subject?
Thanks!