Threads
Thread Concept
- D-SP-Ch11aa-Process_and_Thread
- D-SP-Ch11ab-Thread_Benefit_and_Drawback
- Data Parallelism vs. Task Parallelism
- TCB
Concurrent Programming
- Single Process on Single Processor
- Multiple Processes on Single Processor
- Single Instruction Single Data
- Multiple Instruction Multiple Data
- Single Instruction Multiple Data (SIMD)
- Zero Instruction Multiple Data (MIMD)
Speedup
Amdahl’s Law
- where is serial portion, is number of cores
Gustafson’s law
Threading Model
User Level Thread (ULT)
Kernel Level Thread (KLT)
Multithreading Model
- many-to-one: ULT
- one-to-one: KLT
- many-to-many (N:M): Hybrid
- two level: similar to N:M, but allow user to bound user thread to kernel thread (for latency sensitive thread)
Synchronous vs. Asynchronous Threading
Asynchronous Threading
D-OS-Ch03e-Asynchronous_Threading
Synchronous Threading
D-OS-Ch03f-Synchronous_Threading
Implicit Threading
Implicit Threading vs. Explicit Threading
- Implicit Threading: 將 thread 的建立、管理、銷毀都交給 compiler 決定,程式設計者只需要指出哪裡可以平行便可以 (e.g., OpenMP)
- Explicit Threading: 由程式設計師自己管理 thread 週期 (e.g., pthread)