Parallel Processing and Concurrent Processes
Parallel Processing and Concurrent Processes
Concurrent Processes
Learning Objectives
Benefits
Increased reliability
More than one CPU
If one processor fails, others take over
Not simple to implement
Faster processing
Instructions processed in parallel two or more at a time
Understanding Operating Systems, Sixth Edition
Evolution of Multiprocessors
Developed for high-end midrange and mainframe
computers
Each additional CPU treated as additional resource
Problems
Heat and current leakage (tunneling)
Solution
Single chip with two processor cores in same space
Allows two sets of simultaneous calculations
80 or more cores on single chip
Two cores each run more slowly than single core chip
10
Multicore Era
Goal: to reach exascale computing
Motivation for Multicore Architectures
Limitation of performance improvement
Power wall (high power consumption and heat dissipation)
Memory wall (gap between processor speed and memory speed)
Frequency wall (high penalty for wrong branch prediction due to
deep pipelines with out-of-order execution)
For a uni-processor
Increase frequency by 20%
- Will increase power by more than 50%
- But increase performance by only 13%
Multicores with simple cores
decrease frequency, power consumption, and improve
performance
2001
, POWER4, IBM, 2 Cores
2005, Ultra SPARC T1
, Sun, 8 Cores
2008
, Core i7, Intel, 2/ 4/ 6 Cores
2012, Tesla GPGPU, Nvidia, 10 Cores
2012, Am2045, Ambric, a 336-core Massively
Parallel Processor Array (MPPA)
2014, Adapteva Epiphany, a many-core
processor architecture with up to 4096
processors on-chip
Top500.org
Started in 1993
Detects trends in high-performance computing (HPC)
Every 2 years sites operating the 500 most powerful
computer systems is resealed
How to rank the computer systems?
- Linpack benchmark (performance measure based
on floating point computing power, FLOPS)
Presented at the International Supercomputing
Conference
http://top500.org/
14
Master/Slave Configuration
Asymmetric multiprocessing system
Single-processor system
Additional slave processors
Each managed by primary master processor
15
16
Disadvantages
Reliability
No higher than single processor system
17
18
19
Symmetric Configuration
Decentralized processor scheduling
Each processor is same type
More reliable
Uses resources effectively
Can balance loads well
Can degrade gracefully in failure situation
20
21
Interrupt processing
Update corresponding process list
Run another process
More conflicts
Several processors access same resource at same
time Race condition
Process synchronization
Algorithms resolving conflicts between processors
Understanding Operating Systems, Sixth Edition
22
Deadlock
If key resource is being used
Understanding Operating Systems, Sixth Edition
23
24
25
Test-and-Set
Indivisible machine instruction
Executed in single machine cycle
If key available: set to unavailable
Actual key
Single bit in storage location: zero (free) or one (busy)
26
Test-and-Set (cont'd.)
Advantages
Simple procedure to implement
Works well for small number of processes
Drawbacks
Starvation
Many processes waiting to enter a critical region
Processes gain access in arbitrary fashion
Busy waiting
Waiting processes remain in unproductive, resourceconsuming wait loops
Understanding Operating Systems, Sixth Edition
27
WAIT
Activated when process encounters busy condition
code
SIGNAL
Activated when process exits critical region and
condition code set to free
Understanding Operating Systems, Sixth Edition
28
Semaphores
Nonnegative integer variable
Flag
Signals if and when resource is free
Resource can be used by a process
29
Semaphores (cont'd.)
30
Semaphores (cont'd.)
Let s be a semaphore variable
V(s): s: = s + 1
Fetch, increment, store sequence
31
Semaphores (cont'd.)
32
Semaphores (cont'd.)
P and V operations on semaphore s
Enforce mutual exclusion concept
Critical region
Ensures parallel processes modify shared data only
while in critical region
Parallel computations
Mutual exclusion explicitly stated and maintained
33
Process Cooperation
Several processes work together to complete
common task
Each case requires
Mutual exclusion and synchronization
Examples
Producers and consumers problem
Readers and writers problem
34
Mutex
Third semaphore: ensures mutual exclusion
Understanding Operating Systems, Sixth Edition
35
36
37
38
39
40
Concurrent Programming
Concurrent processing system
One job uses several processors
Executes sets of instructions in parallel
41
Applications of Concurrent
Programming
A = 3 * B * C + 4 / (D + E) **(F G)
42
Applications of Concurrent
Programming (cont'd.)
A = 3 * B * C + 4 / (D + E) ** (F G)
43
Applications of Concurrent
Programming (cont'd.)
Two types of parallelism
Explicit parallelism
Requires programmer intervention
Explicitly state parallel executable instructions
Disadvantages
Time-consuming coding
Missed opportunities for parallel processing
Errors
Parallel processing mistakenly indicated
44
Applications of Concurrent
Programming (cont'd.)
Implicit parallelism
Compiler automatically detects parallel instructions
Advantages
Solves explicit parallelism problems
Complexity dramatically reduced
45
Minimizes overhead
Swapping process between main memory and
secondary storage
46
Thread States
47
48
Terminating thread
Releasing its resources
49
50
Summary
Multiprocessing
Single-processor systems
Interacting processes obtain control of CPU at different
times
System configuration
Master/slave, loosely coupled, symmetric
51
Summary (cont'd.)
Multiprocessing system success
Synchronization of resources
Mutual exclusion
Prevents deadlock
Maintained with test-and-set, WAIT and SIGNAL, and
semaphores (P, V, and mutex)
52
Summary (cont'd.)
Avoid typical problems of synchronization
Missed waiting customers
Synchronization of producers and consumers
Mutual exclusion of readers and writers
53