1/14
Threads
Process VS Thread
Independent
Address space
memory
PCB
creation
switching
communication

Benefits of threads
May continue executing even if part of prcoess is blocked
Cheap creation
Scalabikity
Resource sharing
Concurrency vs Parallelism
Concurency only one at a time
Parallelism run at same time
Types of Parallelism
Data: divide data
Task; different thread do different task
Amdahl’s Law
Identifies performance gains from adding additional cores to an application that has both serial and parallel components
• S is serial portion
• N processing cores

Multiprogramming challenges programmers face
dividing challenge
Data splitting
data dependecy
testing and debugging
3 Thread libraries
POSIX
Windows
Java
Kernel Threads
Windows
Solaris
Linux
Tru64
Max OSX
Pros and cons of User level threads
Pros
fast creation
simpler to control
switching does not need kernel level privelages
Cons
dont communicate well with OS kernel
does not matter if process is single or mutithreaded, still recives one slot
has to be non-blocking
Pros and cons of Kernel level threads
Pros
can scheduling diff instances on diff cpus
when thread halted, can scheduling another thread to do same task
Cons
slow
overhead
complex
Multithread models
Many-to-one (solaris green threads)
one-to-one (windows/linux/solaris 9)
many-to-many (windows/ solaris)
What is implicit threading
Creation and management of threads is done by the compiler and run-time libraries instead of programmer
Way to implicit threading
Thread pool
Open MP
Grand Central Dispatch
Thread issues
Semantics
Signal handling
Thread cancelations (Asynchronous / differed)
Thread local storage
Scheduling activations
Examples of threads
Windows
Windows API
ONE-TO-ONE
Linux
clone() creates threads