Chapter-5 Threads and Concurrancy
Chapter-5 Threads and Concurrancy
2. Accounting information
1. Program counter
2. CPU registers
3
Course Supervisor: ANAUM HAMID
Control Blocks
Process ID (PID)
Parent PID
…
0
Course Supervisor: ANAUM HAMID
Single & Multithreading
Process
• Each thread has
• An execution stack
6
Course Supervisor: ANAUM HAMID
Threads
Threads specific
Threads share…. Attributes….
� Global memory ● Thread ID
executing
Save state into TCB1 ready or
waiting
Reload state from TCB2
Parallelism
Speedup is more as there is different thread or process on
only one execution thread the same or different set of
operating on all sets of data. data.
� Examples
◦ Windows
◦ Linux
◦ Mac OS X
◦ iOS
◦ Android
2. One-to-One
� drawback is, creating a user thread requires creating the corresponding kernel thread
Creating a thread:
Waiting on a thread:
Implicit Threading
� Creation and management of threads done by
compilers and run-time libraries rather than
programmers
� These listed below methods explored
1. Thread Pools
2. Fork Join
3. OpenMP
4. Grand Central Dispatch.
5. Intel Threading Building Blocks