Why use threads?
We still want to perform concurrent programming.
However,and is difficult!
We wanted a quick hack to deal with these problems.
Multiple threads in the same process requires much less resources to manage compared to multiple processes
- Threads share most of the resources of a process
- No need for additional mechanism for passing information around
- Multithreaded programs much more responsive
- Multithreaded program can take advantage of multiple CPUs
- parallel execution of multiple threads -> parallel syscall.
- need to ensure correctness, since syscall is effectful.
- impact on process operations
- fork() duplicates a process, how about its threads?
- exit() executes exit(), how about the whole process?
- exec() single thread calls it, what about other threads?