Presentation is loading. Please wait.

Presentation is loading. Please wait.

Threads, SMP, and Microkernels. Processes zResource ownership - process is allocated a virtual address space to hold the process image zDispatched - process.

Similar presentations


Presentation on theme: "Threads, SMP, and Microkernels. Processes zResource ownership - process is allocated a virtual address space to hold the process image zDispatched - process."— Presentation transcript:

1 Threads, SMP, and Microkernels

2 Processes zResource ownership - process is allocated a virtual address space to hold the process image zDispatched - process is an execution path through one or more programs yexecution may be interleaved with other processes zThese two characteristics are treated independently by the operating system

3 Processes zDispatching is referred to as a thread zResource of ownership is referred to as a process or task

4 Multithreading zOperating system supports multiple threads of execution within a single process zMS-DOS supports a single thread zUNIX supports multiple user processes but only supports one thread per process zWindows NT, Solaris, Linux supports multiple threads

5 Threads and Processes one process one thread multiple processes one thread per process one process multiple threads multiple processes multiple threads per process

6 Processes zHave a virtual address space which holds the process image zProtected access to processors, other processes, files, and I/O resources

7 Threads zHas an execution state (running, ready, etc.) zSaves thread context when not running zHas an execution stack zHas some per-thread static storage for local variables zHas access to the memory and resources of its process yall threads of a process share this

8 Single Threaded and Multithreaded Process Models Thread Control Block User Stack User Stack Kernel Stack Kernel Stack User Address Space User Address Space Process Control Block Process Control Block Thread Single-Threaded Process Model Multithreaded Process Model Thread Control Block User Stack Kernel Stack Thread Control Block User Stack Kernel Stack Thread

9 Benefits of Threads zTakes less time to create a new thread than a process zLess time to terminate a thread than a process zLess time to switch between two threads within the same process zSince threads within the same process share memory and files, they can communicate with each other without invoking the kernel

10 Threads zSuspending a process involves suspending all threads of the process since all threads share the same address space zTermination of a process, terminates all threads within the process zThread operations: spawn, block, unblock, finish (no suspend, only active)

11 User-Level Threads zAll thread management is done by the application, and is fast zThe kernel is not aware of the existence of threads zThread switching does not require kernel mode privileges zScheduling is application specific

12 Kernel-Level Threads zWindows NT, Linux and OS/2 are examples of this approach zKernel maintains context information for the process and the threads zSwitching between threads requires the kernel and may be slower than user-level

13 Combined Approaches for Threads zExample is Solaris zThread creation done in the user space zBulk of scheduling and synchronization of threads done in the user space

14 Relationship Between Threads and Processes Threads:ProcessDescriptionExample Systems 1:1Each thread of execution is a unique process with its own address space and resources. Most UNIX implementations M:1 A process defines an address space and dynamic resource ownership. Multiple threads may be created and executed within that process. Windows NT, Solaris, Linux, OS/2, OS/390, MACH

15 Relationship Between Threads and Processes Threads:ProcessDescriptionExample Systems 1:MA thread may migrate from one process environment to another. This allows a thread to be easily moved among distinct systems. Ra (Clouds), Emerald M:MCombines attributes of M:1 and 1:M cases TRIX

16 Categories of Computer Systems zSingle Instruction Single Data (SISD) ysingle processor executes a single instruction stream to operate on data stored in a single memory zSingle Instruction Multiple Data (SIMD) yone instruction is executed on a different set of data by the different processors

17 Categories of Computer Systems zMultiple Instruction Single Data (MISD) ya sequence of data is transmitted to a set of processors, each of which executes a different instruction sequence. Never implemented yMultiple Instruction Multiple Data (MIMD) ya set of processors simultaneously execute different instruction sequences on different data sets

18 Parallel Processor Architecture MIMD Shared memory multiprocessor Distributed memory (self-contained computers) Clusters Master/Slave Symmetric multiprocessors (SMP)

19 Symmetric Multiprocessing zKernel can execute on any processor zTypically each processor does self- scheduling from the pool of available process or threads zportions of the kernel can execute in parallel in different processors

20 Symmetric Multiprocessor Organization Main Memory Processor Cache I/O Subsystem...

21 Multiprocessor OS requirements zMust provide functionality of a multiprogramming OS plus additional features to support multiple processors zSimultaneous concurrent processes or threads: kernel routines need to be reentrant zScheduling done by any processor, can create conflicts. zSynchronization through locks is required. zMemory management needs to be coordinated in the different processors zMuch more complex than just multiprogramming OS.

22 Microkernel zSmall operating system corecore zContains only essential operating systems functions zMany services traditionally included in the operating system are now external subsystems ydevice drivers yfile systems yvirtual memory manager ywindowing system and security services

23 Benefits of a Microkernel Organization zUniform interface on request made by a process yall services are provided by means of message passing zExtensibility yallows the addition of new services zFlexibility yexisting features can be subtracted

24 Benefits of a Microkernel Organization zPortability ychanges needed to port the system to a new processor is changed in the microkernel - not in the other services zReliability ymodular design ysmall microkernel can be rigorously tested

25 Benefits of Microkernel Organization zDistributed system support ymessage are sent without knowing what the target machine is zObject-oriented operating system ycomponents are objects with clearly defined interfaces that can be interconnected to form software

26 Microkernel Design zPrimitive memory management ymapping each virtual page to a physical page frame zInter-process communication zI/O and interrupt management

27 Windows NT Processes zImplemented as objects zAn executable process may contain one or more threads zBoth process and thread objects have built-in synchronization capabilities

28 Windows NT Process Object Attributes Process ID Security Descriptor Base priority Default processor affinity Quota limits Execution time I/O counters VM operation counters Exception/debugging ports Exit status

29 Windows NT Thread Object Attributes Thread ID Thread context Dynamic priority Base priority Thread processor affinity Thread execution time Alert status Suspension count Impersonation token Termination port Thread exit status

30 NT Thread Status Resource Available Unblock/Resume Resource Available Unblock Resource Not Available Block/ Suspend Terminate Switch Pick to Run Preempted TransitionWaitingTerminated Not Runnable Runnable Ready Standby Running

31 Solaris zProcess includes the user’s address space, stack, and process control block zUser-level threads zLightweight processes zKernel threads

32 Solaris User Level Threads Stop Sleep Dispatch Stop Wakeup Continue Preempt Stopped Runnable Active Sleeping

33 Solaris Lightweight Processes Timeslice or Preempt Wakeup Stop Blocking System Call Wakeup Dispatch Runnable Running Active Stopped Continue Stop


Download ppt "Threads, SMP, and Microkernels. Processes zResource ownership - process is allocated a virtual address space to hold the process image zDispatched - process."

Similar presentations


Ads by Google