Multiprocessors and Threads: Fred Kuhns CS523S: Operating Systems
Multiprocessors and Threads: Fred Kuhns CS523S: Operating Systems
Multiprocessors and Threads: Fred Kuhns CS523S: Operating Systems
Lecture 3
Fred Kuhns ( )
Fred Kuhns ( )
CS523S: Operating
Basic MP Architectures
Single Instruction Single Data (SISD) conventional uniprocessor designs.
Single Instruction Multiple Data (SIMD) Vector and Array Processors
Multiple Instruction Single Data (MISD) Not Implemented.
Multiple Instruction Multiple Data (MIMD)
- conventional MP designs
Fred Kuhns ( )
CS523S: Operating
MIMD Classifications
Tightly Coupled System - all processors
share the same global memory and have the
same address spaces (Typical SMP system).
Main memory for IPC and Synchronization.
Fred Kuhns ( )
CS523S: Operating
MP Block Diagram
CPU
CPU
CPU
CPU
cache MMU
cache MMU
cache MMU
cache MMU
Interconnection Network
MM
Fred Kuhns ( )
MM
MM
CS523S: Operating
MM
CS523S: Operating
Other Details of MP
Interconnection technology
Bus
Cross-Bar switch
Multistage Interconnect Network
Fred Kuhns ( )
CS523S: Operating
MP OS Structure - 1
Separate Supervisor all processors have their own copy of the kernel.
Some share data for interaction
dedicated I/O devices and file systems
good fault tolerance
bad for concurrency
Fred Kuhns ( )
CS523S: Operating
MP OS Structure - 2
Master/Slave Configuration
master monitors the status and assigns work to
other processors (slaves)
Slaves are a schedulable pool of resources for
the master
master can be bottleneck
poor fault tolerance
Fred Kuhns ( )
CS523S: Operating
MP OS Structure - 3
Symmetric Configuration - Most Flexible.
all processors are autonomous, treated equal
one copy of the kernel executed concurrently
across all processors
Synchronize access to shared data structures:
Lock entire OS - Floating Master
Mitigated by dividing OS into segments that normally
have little interaction
multithread kernel and control access to resources
(continuum)
Fred Kuhns ( )
CS523S: Operating
MP Overview
MultiProcessor
SIMD
MIMD
Shared Memory
(tightly coupled)
Master/Slave
Fred Kuhns ( )
Distributed Memory
(loosely coupled)
Symmetric
(SMP)
CS523S: Operating
Clusters
CS523S: Operating
CS523S: Operating
CPU
cache
CPU
MMU
Issues:
Memory contention
Limited bus BW
I/O contention
Cache coherence
cache
MMU
CPU
cache
MMU
cache
MMU
System/Memory Bus
INT
Main 50ns
Memory
I/O
Bridge
subsystem
System Functions
(timer, BIOS, reset)
Typical I/O Bus:
33MHz/32bit (132MB/s)
66MHz/64bit (528MB/s)
Fred Kuhns ( )
CPU
CS523S: Operating
ether
scsi
video
Some Definitions
Parallelism: degree to which a multiprocessor
application achieves parallel execution
Concurrency: Maximum parallelism an
application can achieve with unlimited
processors
System Concurrency: kernel recognizes
multiple threads of control in a program
User Concurrency: User space threads
(coroutines) provide a natural programming
model for concurrent applications. Concurrency
not supported by system.
Fred Kuhns ( )
CS523S: Operating
CS523S: Operating
Threads
Effectiveness of parallel computing depends on
the performance of the primitives used to
express and control parallelism
Threads separate the notion of execution from
the Process abstraction
Useful for expressing the intrinsic concurrency
of a program regardless of resulting
performance
Three types: User threads, kernel threads and
Light Weight Processes (LWP)
Fred Kuhns ( )
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating
Scheduler Activations
An activation:
serves as execution context for running thread
notifies thread of kernel events (upcall)
space for kernel to save processor context of current
user thread when stopped by kernel
CS523S: Operating
Solaris:provides
user threads, kernel threads and LWPs
Mach: supports
kernel threads and tasks. Thread libraries provide
semantics of user threads, LWPs and kernel threads.
CS523S: Operating
Solaris Threads
Supports:
user threads (uthreads) via libthread and libpthread
LWPs, acts as a virtual CPU for user threads
kernel threads (kthread), every LWP is associated
with one kthread, however a kthread may not have an
LWP
interrupts as threads
Fred Kuhns ( )
CS523S: Operating
Solaris kthreads
Fundamental scheduling/dispatching object
all kthreads share same virtual address space
(the kernels) - cheap context switch
System threads - example STREAMS, callout
kthread_t, /usr/include/sys/thread.h
scheduling info, pointers for scheduler or sleep
queues, pointer to klwp_t and proc_t
Fred Kuhns ( )
CS523S: Operating
Solaris LWP
Bound to a kthread
LWP specific fields from proc are kept in
klwp_t (/usr/include/sys/klwp.h)
user-level registers, system call params, resource
usage, pointer to kthread_t and proc_t
Fred Kuhns ( )
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating
CS523S: Operating
klwp_t
lwp_thread
lwp_procp
Fred Kuhns ( )
CS523S: Operating
kthread_t
t_procp
t_lwp
t_forw
Process 1
user
......
...
kernel
hardware
Fred Kuhns ( )
Int kthr
CS523S: Operating
Solaris Interrupts
One system wide clock kthread
pool of 9 partially initialized kthreads per CPU
for interrupts
interrupt thread can block
interrupted thread is pinned to the CPU
Fred Kuhns ( )
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating
Mach
Two abstractions:
Task - static object, address space and system
resources called port rights.
Thread - fundamental execution unit and runs in
context of a task.
Zero or more threads per task,
kernel schedulable
kernel stack
computational state
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating
Digital UNIX
Based on Mach 2.5 kernel
Provides complete UNIX programmers interface
4.3BSD code and ULTRIX code ported to Mach
u-area replaced by utask and uthread
proc structure retained
Fred Kuhns ( )
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating
Pthreads library
One Mach thread per pthread
implements asynchronous I/O
separate thread created for synchronous I/O which in
turn signals original thread
Fred Kuhns ( )
CS523S: Operating
Mach Continuations
Address problem of excessive kernel stack memory
requirements
process model versus interrupt model
one per process kernel stack versus a per thread kernel
stack
CS523S: Operating
Threads in Windows NT
Design driven by need to support a variety of
OS environments
NT process implemented as an object
executable process contains >= 1 thread
process and thread objects have built in
synchronization capabilitiesS
Fred Kuhns ( )
CS523S: Operating
NT Threads
Support for kernel (system) threads
Threads are scheduled by the kernel and thus are
similar to UNIX threads bound to an LWP
(kernel thread)
fibers are threads which are not scheduled by the
kernel and thus are similar to unbound user
threads.
Fred Kuhns ( )
CS523S: Operating
Fred Kuhns ( )
CS523S: Operating