Beruflich Dokumente
Kultur Dokumente
and Microkernels
Fred Kuhns
Fred Kuhns ( )
Basic MP Architectures
Single Instruction Single Data (SISD)
conventional uniprocessor designs.
Fred Kuhns ( )
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 ( )
MP Block Diagram
CPU
cache
MMU
CPU
cache
MMU
CPU
cache MMU
CPU
cache
MMU
Interconnection Network
MM
Fred Kuhns ( )
MM
MM
MM
Other Details of MP
Interconnection technology
Bus
Cross-Bar switch
Multistage Interconnect Network
Fred Kuhns ( )
MP OS Structure - 1
Separate Supervisor
Master/Slave Configuration
Fred Kuhns ( )
MP OS Structure - 2
Symmetric Configuration - Most Flexible.
all processors are autonomous, treated equal
one copy of the kernel executed concurrently
across all processors
Synchronized access to shared data structures:
Fred Kuhns ( )
MP Overview
MultiProcessor
SIMD
MIMD
Shared Memory
(tightly coupled)
Master/Slave
Fred Kuhns ( )
Distributed Memory
(loosely coupled)
Symmetric
(SMP)
Clusters
10
Fred Kuhns ( )
11
Fred Kuhns ( )
12
CPU
cache
MMU
CPU
cache
MMU
CPU
cache
MMU
CPU
cache
MMU
System/Memory Bus
Issues:
Memory contention
Main 50ns
I/O
Bridge
INT
Limited bus BW
Memory
subsystem
I/O contention
ether
System Functions
Cache coherence
(timer, BIOS, reset)
scsi
video
13
14
Introduction to Threads
Multithreaded Process Model
Single-Threaded
Process Model
Process
Control
Block
User
Stack
User
Address
Space
Kernel
Stack
Fred Kuhns ( )
Thread
Thread
Thread
Thread
Control
Block
Thread
Control
Block
Thread
Control
Block
Process
Control
Block
User
Stack
User
Stack
User
Stack
User
Address
Space
Kernel
Stack
Kernel
Stack
Kernel
Stack
15
16
Threads
Effectiveness of parallel computing depends on
the performance of the primitives used to
express and control parallelism
Separate notion of execution from Process
abstraction
Useful for expressing the intrinsic concurrency
of a program regardless of resulting
performance
We will discuss three examples of threading:
User threads,
Kernel threads and
Scheduler Activations
Fred Kuhns ( )
17
Threads cont.
Thread : Dynamic object representing an
execution path and computational state.
One or more threads per process, each having:
Execution state (running, ready, etc.)
Saved thread context when not running
Execution stack
Per-thread static storage for local variables
Shared access to process resources
all threads of a process share a common
address space.
Fred Kuhns ( )
18
Thread States
Primary states:
Running, Ready and Blocked.
19
Benefits:
no modifications required to kernel
flexible and low cost
Drawbacks:
can not block without blocking entire process
no parallelism (not recognized by kernel)
Fred Kuhns ( )
20
Benefits:
Drawbacks:
Fred Kuhns ( )
21
Scheduler Activations
Attempt to combine benefits of both user and
kernel threading support
blocking system call should not block whole process
user space library should make scheduling decisions
Fred Kuhns ( )
22
Scheduler Activations
An activation:
Pthreads
a POSIX standard (IEEE 1003.1c) API
for thread creation and synchronization.
API specifies behavior of the thread
library, implementation is up to
development of the library.
Common in UNIX operating systems.
Fred Kuhns ( )
24
Solaris
user threads, kernel threads, LWPs and in 2.6
Scheduler Activations
Mach
kernel threads and tasks. Thread libraries provide
semantics of user threads, LWPs and kernel threads.
25
Solaris Threads
Supports:
user threads (uthreads) via libthread and
libpthread
LWPs, abstraction that acts as a virtual CPU
for user threads.
LWP is bound to a kthread.
interrupts as threads
Fred Kuhns ( )
26
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 ( )
27
Solaris LWP
Kernel provided mechanism to allow for both user
and kernel thread implementation on one platform.
Bound to a kthread
LWP data (see /usr/include/sys/klwp.h)
user-level registers, system call params, resource
usage, pointer to kthread_t and proc_t
signal mask
alternate stack for signal handling
28
29
klwp_t
kthread_t
t_procp
t_lwp
t_forw
lwp_thread
lwp_procp
Fred Kuhns ( )
30
Process 1
user
......
...
kernel
hardware
Fred Kuhns ( )
Int kthr
P
31
Wakeup
Runnable
Continue
Stop
Stopped
Preempt
Stop
Fred Kuhns ( )
Sleeping
Dispatch
Active
Sleep
32
Stop
Running
Dispatch
Runnable
Wakeup
Blocking
System
Call
Stopped
Continue
Wakeup
Stop
Blocked
Fred Kuhns ( )
33
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 ( )
34
Fred Kuhns ( )
35
Mach
Two abstractions:
Fred Kuhns ( )
36
Fred Kuhns ( )
37
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
Threads:
Fred Kuhns ( )
38
Fred Kuhns ( )
39
Linux Threads
Linux refers to them as tasks rather
than threads.
Thread creation is done through clone()
system call.
Clone() allows a child task to share the
address space of the parent task
(process)
Fred Kuhns ( )
40
Fred Kuhns ( )
41
Microkernel
Transition to Microkernel discussion
Fred Kuhns ( )
42
Microkernel
Small operating system core
Contains only essential operating systems
functions
Many services traditionally included in the
operating system are now external
subsystems
device drivers
file systems
virtual memory manager
windowing system and security services
Fred Kuhns ( )
43
Microkernel Benefits
Portability
isolate port specific code to microkernel
Reliability
modular design, small microkernel, simpler
validation
Uniform interface
all services are provided by means of message
passing
Extensibility
allows the addition of new services
Fred Kuhns ( )
44
Microkernel Benefits
Flexibility
existing features can be subtracted
45
Microkernel Design
Primitive memory management
mapping each virtual page to a physical page
frame: grant, map and flush.
Inter-process communication
I/O and interrupt management
Fred Kuhns ( )
46