Threads, SMP, and Microkernels Chapter 4 Chapter 4 1 Process - - PowerPoint PPT Presentation

threads smp and microkernels
SMART_READER_LITE
LIVE PREVIEW

Threads, SMP, and Microkernels Chapter 4 Chapter 4 1 Process - - PowerPoint PPT Presentation

Threads, SMP, and Microkernels Chapter 4 Chapter 4 1 Process Process Resource ownership - process includes a R hi i l d virtual address space to hold the process image Scheduling/execution- follows an Scheduling/execution-


slide-1
SLIDE 1

Threads, SMP, and Microkernels

Chapter 4 Chapter 4

1

slide-2
SLIDE 2

Process Process

R hi i l d

  • Resource ownership - process includes a

virtual address space to hold the process image

  • Scheduling/execution- follows an
  • Scheduling/execution- follows an

execution path that may be interleaved ith th with other processes

  • These two characteristics are treated

independently by the operating system

2

slide-3
SLIDE 3

Process Process

Di hi i f d h d

  • Dispatching is referred to as a thread or

lightweight process

  • Resource of ownership is referred to as a

process or task process or task

3

slide-4
SLIDE 4

Multithreading Multithreading

O i l i l

  • Operating system supports multiple

threads of execution within a single process

  • MS-DOS supports a single thread
  • MS-DOS supports a single thread
  • UNIX supports multiple user processes

but only supports one thread per process

  • Windows, Solaris, Linux, Mach, and

Windows, Solaris, Linux, Mach, and OS/2 support multiple threads

4

slide-5
SLIDE 5

5

slide-6
SLIDE 6

Process Process

H i l dd hi h h ld

  • Have a virtual address space which holds

the process image

  • Protected access to processors, other

processes files and I/O resources processes, files, and I/O resources

6

slide-7
SLIDE 7

Thread Thread

A i ( i d )

  • An execution state (running, ready, etc.)
  • Saved thread context when not running
  • Has an execution stack
  • Some per-thread static storage for local

variables

  • Access to the memory and resources of

its process its process

– all threads of a process share this

7

slide-8
SLIDE 8

8

slide-9
SLIDE 9

Benefits of Threads Benefits of Threads

T k l ti t t th d th

  • Takes less time to create a new thread than a

process

  • Less time to terminate a thread than a process
  • Less time to switch between two threads

within the same process

  • Since threads within the same process share

Since threads within the same process share memory and files, they can communicate with each other without invoking the kernel each other without invoking the kernel

9

slide-10
SLIDE 10

Uses of Threads in a Single- User Multiprocessing System

F d b k d k

  • Foreground to background work
  • Asynchronous processing

y p g

  • Speed of execution
  • Modular program structure

10

slide-11
SLIDE 11

Threads Threads

S di i l

  • Suspending a process involves

suspending all threads of the process since all threads share the same address space sp ce

  • Termination of a process, terminates all

th d ithi th threads within the process

11

slide-12
SLIDE 12

Thread States Thread States

S i d i h h i h d

  • States associated with a change in thread

state

– Spawn

  • Spawn another thread

Sp

– Block Unblock – Unblock – Finish

  • Deallocate register context and stacks

12

slide-13
SLIDE 13

Remote Procedure Call Using Single Thread

13

slide-14
SLIDE 14

Remote Procedure Call Using Threads

14

slide-15
SLIDE 15

Multithreading Multithreading

15

slide-16
SLIDE 16

Adobe PageMaker Adobe PageMaker

16

slide-17
SLIDE 17

User Level Threads User-Level Threads

All h d i d b h

  • All thread management is done by the

application

  • The kernel is not aware of the existence
  • f threads
  • f threads

17

slide-18
SLIDE 18

User Level Threads User-Level Threads

18

slide-19
SLIDE 19

19

slide-20
SLIDE 20

Kernel Level Threads Kernel-Level Threads

Wi d i l f hi h

  • Windows is an example of this approach
  • Kernel maintains context information for

the process and the threads S h d li i d th d b i

  • Scheduling is done on a thread basis

20

slide-21
SLIDE 21

Kernel Level Threads Kernel-Level Threads

21

slide-22
SLIDE 22

VAX Running UNIX-Like Operating System

22

slide-23
SLIDE 23

Combined Approaches Combined Approaches

E l i S l i

  • Example is Solaris
  • Thread creation done in the user space

p

  • Bulk of scheduling and synchronization

f th d ithi li ti

  • f threads within application

23

slide-24
SLIDE 24

Combined Approaches Combined Approaches

24

slide-25
SLIDE 25

Relationship Between Threads and Processes

25

slide-26
SLIDE 26

Categories of Computer Systems

Si l I i Si l D (SISD)

  • Single Instruction Single Data (SISD)

stream

– Single processor executes a single instruction stream to operate on data stored p in a single memory

  • Single Instruction Multiple Data (SIMD)
  • Single Instruction Multiple Data (SIMD)

stream

– Each instruction is executed on a different set of data by the different processors

26

slide-27
SLIDE 27

Categories of Computer Systems

M lti l I t ti Si l D t (MISD)

  • Multiple 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 instruction sequence. Never implemented

  • Multiple Instruction Multiple Data (MIMD)

A f i l l – A set of processors simultaneously execute different instruction sequences on different data sets sets

27

slide-28
SLIDE 28

28

slide-29
SLIDE 29

Symmetric Multiprocessing Symmetric Multiprocessing

K l

  • Kernel can execute on any processor
  • Typically each processor does self-

yp y p scheduling form the pool of available process or threads process or threads

29

slide-30
SLIDE 30

30

slide-31
SLIDE 31

Multiprocessor Operating System Design Considerations

Si l

  • Simultaneous concurrent processes or

threads

  • Scheduling

S h i ti

  • Synchronization
  • Memory management

y g

  • Reliability and fault tolerance

31

slide-32
SLIDE 32

Microkernels Microkernels

  • Small operating system core
  • Small operating system core
  • Contains only essential core operating systems

functions functions

  • Many services traditionally included in the
  • perating system are now external subsystems
  • perating system are now external subsystems

– Device drivers File systems – File systems – Virtual memory manager – Windowing system Windowing system – Security services

32

slide-33
SLIDE 33

33

slide-34
SLIDE 34

Benefits of a Microkernel Organization

  • Uniform interface on request made by a
  • Uniform interface on request made by a

process

Don’t distinguish between kernel level and user – Don t distinguish between kernel-level and user- level services – All services are provided by means of message p y g passing

  • Extensibility

– Allows the addition of new services

  • Flexibility

– New features added – Existing features can be subtracted

34

slide-35
SLIDE 35

Benefits of a Microkernel Organization

P bili

  • Portability

– Changes needed to port the system to a new processor is changed in the microkernel - not in the other services

  • Reliability

Modular design – Modular design – Small microkernel can be rigorously tested

35

slide-36
SLIDE 36

Benefits of Microkernel Organization

Di ib d

  • Distributed system support

– Message are sent without knowing what the target machine is

  • Object-oriented operating system

Object oriented operating system

– Components are objects with clearly defined interfaces that can be defined interfaces that can be interconnected to form software

36

slide-37
SLIDE 37

Microkernel Design Microkernel Design

L l l t

  • Low-level memory management

– Mapping each virtual page to a physical page frame

37

slide-38
SLIDE 38

Microkernel Design Microkernel Design

I i i

  • Interprocess communication
  • I/O and interrupt management

p g

38

slide-39
SLIDE 39

Windows Processes Windows Processes

I l d bj

  • Implemented as objects
  • An executable process may contain one

p y

  • r more threads

B th d th d bj t h

  • Both processes and thread objects have

built-in synchronization capabilities

39

slide-40
SLIDE 40

40

slide-41
SLIDE 41

Windows Process Object Windows Process Object

41

slide-42
SLIDE 42

Windows Thread Object Windows Thread Object

42

slide-43
SLIDE 43

Windows 2000 Thread States

R d

  • Ready
  • Standby
  • Running
  • Waiting
  • Transition

Transition

  • Terminated

43

slide-44
SLIDE 44

44

slide-45
SLIDE 45

Solaris Solaris

P i l d h ’ dd

  • Process includes the user’s address

space, stack, and process control block

  • User-level threads

Li ht i ht (LWP)

  • Lightweight processes (LWP)
  • Kernel threads

45

slide-46
SLIDE 46

46

slide-47
SLIDE 47

47

slide-48
SLIDE 48

Solaris Lightweight Data Structure

Id tifi

  • Identifier
  • Priority
  • Signal mask
  • Saved values of user-level registers

Saved values of user level registers

  • Kernel stack

R d fili d t

  • Resource usage and profiling data
  • Pointer to the corresponding kernel thread
  • Pointer to the process structure

48

slide-49
SLIDE 49

49

slide-50
SLIDE 50

Linux Task Data Structure Linux Task Data Structure

  • State
  • State
  • Scheduling information

d ifi

  • Identifiers
  • Interprocess communication
  • Links
  • Times and timers
  • File system
  • Address space

Address space

  • Processor-specific context

50

slide-51
SLIDE 51

Linux States of a Process Linux States of a Process

R i

  • Running
  • Interruptable

p

  • Uninterruptable
  • Stopped
  • Zombie

Zombie

51

slide-52
SLIDE 52

52