threads, smp, and microkernels. processes zresource ownership - process is allocated a virtual...
TRANSCRIPT
Threads, SMP, and Microkernels
Processes
Resource ownership - process is allocated a virtual address space to hold the process image
Dispatched - process is an execution path through one or more programs execution may be interleaved with other
processesThese two characteristics are treated
independently by the operating system
Processes
Dispatching is referred to as a threadResource of ownership is referred to
as a process or task
Multithreading
Operating system supports multiple threads of execution within a single process
MS-DOS supports a single threadUNIX supports multiple user processes
but only supports one thread per processWindows NT, Solaris, Linux supports
multiple threads
Threads and Processes
one processone thread
multiple processesone thread per process
one processmultiple threads
multiple processesmultiple threads per process
Processes
Have a virtual address space which holds the process image
Protected access to processors, other processes, files, and I/O resources
Threads
Has an execution state (running, ready, etc.)
Saves thread context when not runningHas an execution stackHas some per-thread static storage for
local variablesHas access to the memory and resources
of its process all threads of a process share this
Single Threaded and Multithreaded Process Models
ThreadControlBlock
UserStack
UserStack
KernelStack
KernelStack
UserAddressSpace
UserAddressSpace
ProcessControlBlock
ProcessControlBlock
Thread
Single-ThreadedProcess Model
MultithreadedProcess Model
ThreadControlBlock
UserStack
KernelStack
Thread
ThreadControlBlock
UserStack
KernelStack
Thread
Benefits of ThreadsTakes less time to create a new thread than
a processLess time to terminate a thread than a
processLess time to switch between two threads
within the same processSince threads within the same process share
memory and files, they can communicate with each other without invoking the kernel
Threads
Suspending a process involves suspending all threads of the process since all threads share the same address space
Termination of a process, terminates all threads within the process
Thread operations: spawn, block, unblock, finish (no suspend, only active)
User-Level Threads
All thread management is done by the application, and is fast
The kernel is not aware of the existence of threads
Thread switching does not require kernel mode privileges
Scheduling is application specific
Kernel-Level Threads
Windows NT, Linux and OS/2 are examples of this approach
Kernel maintains context information for the process and the threads
Switching between threads requires the kernel and may be slower than user-level
Combined Approaches for Threads
Example is SolarisThread creation done in the user
spaceBulk of scheduling and
synchronization of threads done in the user space
Relationship Between Threads and Processes
Threads:Process Description Example Systems
1:1 Each thread of execution is aunique process with its ownaddress space and resources.
Most UNIX implementations
M:1 A process defines an addressspace and dynamic resourceownership. Multiple threadsmay be created and executedwithin that process.
Windows NT, Solaris, Linux, OS/2, OS/390, MACH
Relationship Between Threads and Processes
Threads:Process Description Example Systems
1:M A thread may migrate from oneprocess environment toanother. This allows a threadto be easily moved amongdistinct systems.
Ra (Clouds), Emerald
M:M Combines attributes of M:1and 1:M cases
TRIX
Categories of Computer Systems
Single Instruction Single Data (SISD) single processor executes a single
instruction stream to operate on data stored in a single memory
Single Instruction Multiple Data (SIMD) one instruction is executed on a different
set of data by the different processors
Categories of Computer Systems
Multiple Instruction Single Data (MISD) a sequence of data is transmitted to a set
of processors, each of which executes a different instruction sequence. Never implemented
Multiple Instruction Multiple Data (MIMD) a set of processors simultaneously
execute different instruction sequences on different data sets
Parallel Processor Architecture
MIMD
Shared memorymultiprocessor
Distributed memory(self-contained computers)
Clusters
Master/SlaveSymmetricmultiprocessors(SMP)
Symmetric Multiprocessing
Kernel can execute on any processorTypically each processor does self-
scheduling from the pool of available process or threads
portions of the kernel can execute in parallel in different processors
Symmetric Multiprocessor Organization
MainMemory
Processor Processor Processor
Cache CacheCache
I/OSubsystem
. . .
Multiprocessor OS requirements
Must provide functionality of a multiprogramming OS plus additional features to support multiple processors
Simultaneous concurrent processes or threads: kernel routines need to be reentrant
Scheduling done by any processor, can create conflicts.
Synchronization through locks is required. Memory management needs to be coordinated in the
different processors Much more complex than just multiprogramming OS.
MicrokernelSmall operating system coreContains only essential operating systems
functionsMany services traditionally included in the
operating system are now external subsystems device drivers file systems virtual memory manager windowing system and security services
Benefits of a Microkernel Organization
Uniform interface on request made by a process all services are provided by means of
message passingExtensibility
allows the addition of new servicesFlexibility
existing features can be subtracted
Benefits of a Microkernel Organization
Portability changes needed to port the system to a
new processor is changed in the microkernel - not in the other services
Reliability modular design small microkernel can be rigorously
tested
Benefits of Microkernel Organization
Distributed system support message are sent without knowing what
the target machine isObject-oriented operating system
components are objects with clearly defined interfaces that can be interconnected to form software
Microkernel Design
Primitive memory management mapping each virtual page to a physical
page frameInter-process communicationI/O and interrupt management
Windows NT Processes
Implemented as objectsAn executable process may contain
one or more threadsBoth process and thread objects
have built-in synchronization capabilities
Windows NT Process Object Attributes
Process IDSecurity DescriptorBase priorityDefault processor affinityQuota limitsExecution timeI/O countersVM operation countersException/debugging portsExit status
Windows NT Thread Object Attributes
Thread IDThread contextDynamic priorityBase priorityThread processor affinityThread execution timeAlert statusSuspension countImpersonation tokenTermination portThread exit status
NT Thread Status
ResourceAvailable
Unblock/ResumeResource Available
UnblockResource Not Available
Block/Suspend
Terminate
SwitchPick toRun
Preempted
Transition Waiting Terminated
Not Runnable
Runnable
Ready
Standby
Running
Solaris
Process includes the user’s address space, stack, and process control block
User-level threadsLightweight processesKernel threads
Solaris User Level Threads
Stop
Stop Sleep
Dispatch
Stop
WakeupContinue
Preempt
Stopped
Runnable
Active
Sleeping
Solaris Lightweight Processes
Timesliceor Preempt
WakeupStop
BlockingSystem
Call
WakeupDispatch
Runnable
Running
Active
Stopped
Continue
Stop