threads, smp, and microkernels chapter 4 1. process resource ownership - process includes a virtual...
TRANSCRIPT
Threads, SMP, and Threads, SMP, and MicrokernelsMicrokernelsChapter 4
1
ProcessProcessResource ownership - process
includes a virtual address space to hold the process image
Scheduling/execution- follows an execution path that may be interleaved with other processes
These two characteristics are treated independently by the operating system
2
ProcessProcessDispatching is referred to as a
thread or lightweight processResource of ownership is referred
to as a process or task
3
MultithreadingMultithreadingOperating 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 process
Windows, Solaris, Linux, Mach, and OS/2 support multiple threads
4
5
ProcessProcessHave a virtual address space
which holds the process imageProtected access to processors,
other processes, files, and I/O resources
6
ThreadThreadAn execution state (running, ready,
etc.)Saved thread context when not
runningHas an execution stackSome per-thread static storage for
local variablesAccess to the memory and
resources of its process◦all threads of a process share this
7
8
Benefits of ThreadsBenefits 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
9
Uses of Threads in a Single-Uses of Threads in a Single-User Multiprocessing SystemUser Multiprocessing SystemForeground to background workAsynchronous processingSpeed of executionModular program structure
10
ThreadsThreadsSuspending 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
11
Thread StatesThread StatesStates associated with a change
in thread state◦Spawn
Spawn another thread
◦Block◦Unblock◦Finish
Deallocate register context and stacks
12
Remote Procedure Call Remote Procedure Call Using Single ThreadUsing Single Thread
13
Remote Procedure Call Remote Procedure Call Using ThreadsUsing Threads
14
MultithreadingMultithreading
15
Adobe PageMakerAdobe PageMaker
16
User-Level ThreadsUser-Level ThreadsAll thread management is done
by the applicationThe kernel is not aware of the
existence of threads
17
User-Level ThreadsUser-Level Threads
18
19
Kernel-Level ThreadsKernel-Level ThreadsWindows is an example of this
approachKernel maintains context
information for the process and the threads
Scheduling is done on a thread basis
20
Kernel-Level ThreadsKernel-Level Threads
21
VAX Running UNIX-Like VAX Running UNIX-Like Operating SystemOperating System
22
Combined ApproachesCombined ApproachesExample is SolarisThread creation done in the user
spaceBulk of scheduling and
synchronization of threads within application
23
Combined ApproachesCombined Approaches
24
Relationship Between Relationship Between Threads and ProcessesThreads and Processes
25
Categories of Computer Categories of Computer SystemsSystemsSingle Instruction Single Data
(SISD) stream◦Single processor executes a single
instruction stream to operate on data stored in a single memory
Single Instruction Multiple Data (SIMD) stream◦Each instruction is executed on a
different set of data by the different processors
26
Categories of Computer Categories of Computer SystemsSystemsMultiple Instruction Single Data (MISD)
stream◦ 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
27
28
Symmetric Symmetric MultiprocessingMultiprocessingKernel can execute on any
processorTypically each processor does
self-scheduling form the pool of available process or threads
29
30
Multiprocessor Operating Multiprocessor Operating System Design System Design ConsiderationsConsiderationsSimultaneous concurrent
processes or threadsSchedulingSynchronizationMemory managementReliability and fault tolerance
31
MicrokernelsMicrokernelsSmall operating system coreContains only essential core operating
systems functionsMany services traditionally included in
the operating system are now external subsystems◦ Device drivers◦ File systems◦ Virtual memory manager◦ Windowing system◦ Security services
32
33
Benefits of a Microkernel Benefits of a Microkernel OrganizationOrganizationUniform interface on request made by
a process◦ Don’t distinguish between kernel-level and
user-level services◦ All services are provided by means of
message passingExtensibility
◦ Allows the addition of new servicesFlexibility
◦ New features added◦ Existing features can be subtracted
34
Benefits of a Microkernel Benefits of a Microkernel OrganizationOrganizationPortability
◦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
35
Benefits of Microkernel Benefits of Microkernel OrganizationOrganizationDistributed system support
◦Message are sent without knowing what the target machine is
Object-oriented operating system◦Components are objects with clearly
defined interfaces that can be interconnected to form software
36
Microkernel DesignMicrokernel Design
Low-level memory management◦ Mapping each virtual page to a physical
page frame
37
Microkernel DesignMicrokernel DesignInterprocess communicationI/O and interrupt management
38
Windows ProcessesWindows ProcessesImplemented as objectsAn executable process may
contain one or more threadsBoth processes and thread
objects have built-in synchronization capabilities
39
40
Windows Process ObjectWindows Process Object
41
Windows Thread ObjectWindows Thread Object
42
Windows 2000Windows 2000Thread StatesThread StatesReadyStandbyRunningWaitingTransitionTerminated
43
44
SolarisSolarisProcess includes the user’s
address space, stack, and process control block
User-level threadsLightweight processes (LWP)Kernel threads
45
46
47
Solaris Lightweight Data Solaris Lightweight Data StructureStructureIdentifierPrioritySignal maskSaved values of user-level registersKernel stackResource usage and profiling dataPointer to the corresponding kernel
threadPointer to the process structure
48
49
Linux Task Data StructureLinux Task Data StructureStateScheduling informationIdentifiersInterprocess communicationLinksTimes and timersFile systemAddress spaceProcessor-specific context
50
Linux States of a ProcessLinux States of a ProcessRunningInterruptableUninterruptableStoppedZombie
51
52