Docsity

SunOS Kernel Thread Implementation: Data Structures, Scheduling, and Interrupts, Papers of Operating Systems

Partial preview of the text

Download SunOS Kernel Thread Implementation: Data Structures, Scheduling, and Interrupts and more Papers Operating Systems in PDF only on Docsity!

Kernel Thread Implementation

  • based on paper “Beyond Multiprocessing…

Multithreading the SunOS Kernel” byEykholt et al.

  • paper is report on actual kernel threads

implementation, not many new ideas, butgood to know technical details.

SunOS 5.0 kernel

SunOS 5.0 kernel is the main operating system

component for Solaris 2.

-^

kernel consists of kernel threads – lightweight,inexpensive switching, fully preemtible

-^

process model changed from heavyweight tolightweight processes (LWPs)

-^

LWPs map one-to-one to kernel threads

-^

kernel threads that are only used internally don’tneed to be associated with LWPs (system threads)

-^

entire kernel is multithreaded (e.g., for asyncoperations), even interrupts

Data structures

•^

kernel thread structure–

kernel registers– scheduling class– dispatch queue links– pointer to the stack– pointers to LWP, process, and CPU structure

-^

CPU structure:–

pointer to currently executing thread– pointer to idle thread– current dispatching and interrupt handling info– for the most part architecture independent

-^

for efficient access to structures, hold pointer to current thread inglobal register–

enables access to struct fields with single instruction

Kernel Scheduling

•^

Support for multiple scheduling classes– system, timesharing, real-time (fixed-priority)– dispatcher chooses thread with greatest global priority

to run on a CPU

•^

Preemption – kernel is fully preemtible– if a higher priority thread becomes runnable, it is

scheduled

as soon as possible

in the place of a lower

priority thread

  • important for real-time and interrupt threads
    • e.g. user code run by real-time thread can have sufficiently

high priority to preempt other threads, i.e. preemption in user-level libraries…

Interrupts as threads

•^

mutexes when spinning need to raise interrupt levelabove that of interrupt handlers that use mutexes– otherwise?– this is expensive, and makes interrupt coding inconvenient

-^

Solution: interrupts (up to a certain level) are threadedas asynchronously created and dispatched high-prioritythreads– mutexes get interrupted, but the result is the creation of an

interrupt thread

  • interrupt threads can sleep and can synchronize– interrupts disabled in some places (putting a thread to sleep,

if it needs to be awaken, during dispatching)

Implementing interrupts as threads

•^

for efficiency there are preallocated, partiallyinitialized interrupt threads

-^

initially (after interrupt occurs), interrupt threadsare not separate from interrupted thread, which ispinned, and cannot move to another CPU

-^

if the interrupt thread blocks, then it becomes afull-fledged thread, separate from interruptedthread, and can be descheduled.

-^

CPU structure keeps track of interrupt level ofblocked interrupt thread, so lower level interruptsare ignored