Chapter 4 Notes

Download Report

Transcript Chapter 4 Notes

Threads, SMP and Microkernels
• Process vs. thread:
– Unit of resource ownership (process has virtual
address space, memory, I/O channels, files)
– Unit of dispatching
• process execution path through one or more
programs
• process has execution state, process is dispatched.
Process/Threads
• Unit of dispatching=thread/lightweight
process
• Unit of resource ownership: process/task
Multithreading
• Support multiple threads execution within
one process (one process, one thread is
single threading)
• Within a process, have >1 thread.
• Thread has (a) thread execution state, (b)
saved thread context, © execution context,
(d) per-thread storage
Multithreading; continued
• All threads of a process
– share state and resources of that process
– reside in same address space and have same
access
– one thread alters data=> others see change
– one thread opens file=> other threads have
access
Benefits of multithreading
• Performance:
– far less time to create, terminate and switch
between threads
– factor of 10 improvement in performance
– example: server
– >1 CPU?
– IPC more time consuming
Thread operations
•
•
•
•
Spawn (first thread created automatically)
Block waiting for an event
Unblock -- event occurs
finish-- thread completes
Thread implementations
• User level threads (ULT)
• Kernel level threads (KLT)
• Combined approach
MS-DOS
• One process
• One thread
Many UNIX OS
• Multiple processes
• One thread/process
Process 1
Process 2
Java Runtime Environment
One process; Multipe threads
Solaris
• Multiple processes; multiple threads
We are interested in this
Multithreading
• Process = unit of protection + unit of
resource allocation
• has virtual address space; protected access
to processor, other processes (IPC), files,,
I/O resources…
• Within a process, have more than one
thread.
Symmetric MultiProcessing
• SIMD
• MIMD
– Distributed memory
– Shared memory
• master/slave
• Symmetric (each process self schedules)
Microkernels
• Small OS core; provides foundation for
modular extension
• Benefits:
–
–
–
–
–
uniform interfaces
extensibility
flexibility
portability
Distributed OS support