Reputation: 385
In the world of UserMode we have processes and threads.
We have a kernel scheduler that schedules the thread running times and that's how we get "multi threads".
Now I have a few questions:
Upvotes: 2
Views: 985
Reputation: 8394
OSes will have a timer interrupt setup, usually at about 60ms. The interrupt handler in the OS will kick-off the scheduling algorithms, to see what's best run next. This is called preempting, because the OS does this without cooperation from the applications its running. Other interrupts - from devices - will also kick off a scheduling reevaluation. So when a new Ethernet frame is received, that may eventually result in your web browser being rescheduled resulting in a page being drawn. In the old days of Windows 3 and the like (and other early OSes of that sort), they depended on applications making calls to operating system functions to give the OS a chance to run the scheduling algorithms. This is called cooperative multi-tasking - the OS depends on the applications making those OS function calls.
Depends. A microkernel based OS will actually put a lot of what we think is OS code into processes (e.g. device drivers), and run them at no higher privilege than other userland applications. Windows and Linux aren't like this.
Again, depends. In Linux the drivers were simply functions that'd get run whenever, or if the Linux PreemptRT patch set was applied the bulk of this functionality was put into kernel threads, to be scheduled along with all other threads in the system. Kind of a poor man's way of getting a fully preemptable operating system. In OSes like VXWorks, the device drivers have always been threads with no more or less privilege than application threads (in fact VxWorks makes no distinction between them). This means that the whole of VxWorks is preemptable - even all the device drivers, etc - making it a very good hard real time OS.
The kernel is not a thread as such, as it's the thing that defines what a thread is. But it is code executing within the system.
Upvotes: 1