- What are the two advantages that threads have over multiple processes? [2 marks]
- Inter-thread communication is easier/faster than inter-process communication.
- Threads incur less overhead to create/terminate/switch
- What are the differences between user-level threads and kernel-level threads and under what circumstances is one type better than the other? [4 marks]
- User-level threads:
- Threads are in user space. Thus, no mode switches required
- Full control over the thread shceduler (e.g. website server)
- OS independent (threads can run on OS that do not support them).
- The runtime system can switch local blocking threads in user space. (e.g. wait for another thread to complete)
- Cons1: Blocking system calls suspend the entire process s(user threads are mapped onto a single process, managed by the kernl).
- Cons2: page fault result in blocking the process
- Cons3: No true parallelism (a process is scheduled on single CPU)
- Kernel-level thread: (Windows, linux)
- Pro: true parallelism can be achieved.
- Pro2: no run-time system needed.
- Cons: frequence mode switch take place, resulting in lower performance.
- Hybrid implementations
- Implementation: user threads are multiplexed onto kernel threads.
- Kernel sees and schedules the kernel threads (a limited number)
- User application sees user threads and create/schedules these (an “unrestricted” number)
- User-level threads:
User-level and kernel-level thread comparison and which one to choose in what circustance
最新推荐文章于 2023-10-30 15:17:14 发布