threads, smp, and microkernels chapter 4 1. process resource ownership - process includes a virtual...

52
Threads, SMP, and Threads, SMP, and Microkernels Microkernels Chapter 4 1

Upload: miles-whisler

Post on 01-Apr-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Threads, SMP, and Threads, SMP, and MicrokernelsMicrokernelsChapter 4

1

Page 2: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 3: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

ProcessProcessDispatching is referred to as a

thread or lightweight processResource of ownership is referred

to as a process or task

3

Page 4: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 5: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

5

Page 6: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

ProcessProcessHave a virtual address space

which holds the process imageProtected access to processors,

other processes, files, and I/O resources

6

Page 7: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 8: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

8

Page 9: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 10: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 11: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 12: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Thread StatesThread StatesStates associated with a change

in thread state◦Spawn

Spawn another thread

◦Block◦Unblock◦Finish

Deallocate register context and stacks

12

Page 13: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Remote Procedure Call Remote Procedure Call Using Single ThreadUsing Single Thread

13

Page 14: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Remote Procedure Call Remote Procedure Call Using ThreadsUsing Threads

14

Page 15: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

MultithreadingMultithreading

15

Page 16: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Adobe PageMakerAdobe PageMaker

16

Page 17: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

User-Level ThreadsUser-Level ThreadsAll thread management is done

by the applicationThe kernel is not aware of the

existence of threads

17

Page 18: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

User-Level ThreadsUser-Level Threads

18

Page 19: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

19

Page 20: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 21: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Kernel-Level ThreadsKernel-Level Threads

21

Page 22: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

VAX Running UNIX-Like VAX Running UNIX-Like Operating SystemOperating System

22

Page 23: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Combined ApproachesCombined ApproachesExample is SolarisThread creation done in the user

spaceBulk of scheduling and

synchronization of threads within application

23

Page 24: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Combined ApproachesCombined Approaches

24

Page 25: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Relationship Between Relationship Between Threads and ProcessesThreads and Processes

25

Page 26: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 27: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 28: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

28

Page 29: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Symmetric Symmetric MultiprocessingMultiprocessingKernel can execute on any

processorTypically each processor does

self-scheduling form the pool of available process or threads

29

Page 30: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

30

Page 31: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Multiprocessor Operating Multiprocessor Operating System Design System Design ConsiderationsConsiderationsSimultaneous concurrent

processes or threadsSchedulingSynchronizationMemory managementReliability and fault tolerance

31

Page 32: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 33: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

33

Page 34: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 35: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 36: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 37: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Microkernel DesignMicrokernel Design

Low-level memory management◦ Mapping each virtual page to a physical

page frame

37

Page 38: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Microkernel DesignMicrokernel DesignInterprocess communicationI/O and interrupt management

38

Page 39: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Windows ProcessesWindows ProcessesImplemented as objectsAn executable process may

contain one or more threadsBoth processes and thread

objects have built-in synchronization capabilities

39

Page 40: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

40

Page 41: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Windows Process ObjectWindows Process Object

41

Page 42: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Windows Thread ObjectWindows Thread Object

42

Page 43: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Windows 2000Windows 2000Thread StatesThread StatesReadyStandbyRunningWaitingTransitionTerminated

43

Page 44: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

44

Page 45: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

SolarisSolarisProcess includes the user’s

address space, stack, and process control block

User-level threadsLightweight processes (LWP)Kernel threads

45

Page 46: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

46

Page 47: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

47

Page 48: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

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

Page 49: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

49

Page 50: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Linux Task Data StructureLinux Task Data StructureStateScheduling informationIdentifiersInterprocess communicationLinksTimes and timersFile systemAddress spaceProcessor-specific context

50

Page 51: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

Linux States of a ProcessLinux States of a ProcessRunningInterruptableUninterruptableStoppedZombie

51

Page 52: Threads, SMP, and Microkernels Chapter 4 1. Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-

52