Professional Documents
Culture Documents
Operating Systems
Processes and Threades
Dr. Youssef Iraqi
College of Computing
Email: Youssef.Iraqi@um6p.ma
Operating Systems 1
Process Model
Operating Systems 2
1
1/25/24
Process Model
Operating Systems 3
Process Creation
Operating Systems 4
2
1/25/24
Process Termination
Operating Systems 5
Process Hierarchies
• Parent creates a child process, child processes can create its own
process
• Forms a hierarchy
• UNIX calls this a process group
• Windows has no concept of process hierarchy
• all processes are created equal
Operating Systems 6
3
1/25/24
Process States
Operating Systems 7
Process States
Operating Systems 8
4
1/25/24
Implementation of Processes
Operating Systems 9
Implementation of Processes
Operating Systems 10
10
5
1/25/24
Threads
Operating Systems 11
11
Operating Systems 12
12
6
1/25/24
Operating Systems 13
13
Operating Systems 14
14
7
1/25/24
Multithreading
Operating Systems 15
15
Multithreading (2)
• When a thread has finished its work, it can exit by calling a library
procedure, say, thread_exit.
• In some thread systems, one thread can wait for a (specific)
thread to exit by calling a procedure, for example, thread_wait.
This procedure blocks the calling thread until a (specific) thread
has exited.
• Another common thread call is thread_yield, which allows a
thread to voluntarily give up the CPU to let another thread run.
• Other calls allow one thread to wait for another thread to finish
some work, for a thread to announce that it has finished some
work, and so on.
Operating Systems 16
16
8
1/25/24
Operating Systems 17
17
Operating Systems 18
18
9
1/25/24
Operating Systems 19
19
Operating Systems 20
20
10
1/25/24
Operating Systems 21
21
Operating Systems 22
22
11
1/25/24
Operating Systems 23
23
Operating Systems 24
24
12
1/25/24
Operating Systems 25
25
A user-level threads
package
Operating Systems 26
26
13
1/25/24
Advantages:
• User-level threads package can be implemented on an operating system that
does not support threads.
• Each process can have its own customized scheduling algorithm.
• User-level threads package scale better
Major problems:
• How blocking system calls are implemented
• Page faults
• Unless a thread enters the run-time system of its own free will, the
scheduler will never get a chance.
• Once a trap has occurred to the kernel, it is hardly any more work for the
kernel to switch threads if the old one has blocked.
Operating Systems 27
27
Operating Systems 28
28
14
1/25/24
Hybrid Implementations
Multiplexing user-level
threads onto kernel-
level threads
Operating Systems 29
29
15