12/11 OS作業

名稱
12/11 OS作業
日期
12/16
課程名稱
作業系統
指導教師
劉艾華
心得
1. What kind of strategies we can have for using thread pools?

Answer:

Creating new threads needed every time and deleting it when it is done can be inefficient. It can also lead to an unlimited number of threads being created.

An alternative solution is to create a number of threads when the process first starts, and put those threads into a thread pool.

Threads are allocated from the pool as needed, and returned to the pool when no longer needed. When no threads are available in the pool, the process may have to wait until one becomes available.



2. Why the windows uses one to one mapping for the threads while there are many to many available?

Answer:

Because the one to one model allows for greater concurrency, and it also allows multiple threads to run in parallel on multiprocessors.



3. Specify the differences between processes and threads.

Answer:

(1) Both processes and threads are independent sequences of execution. The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces.

(2) Threads have direct access to data segment of its process, while process have their own copy of data segment of parent process.

(3) Threads can directly communicate with other threads of that process; processes must use inter-process communication to communicate with sibling processes.

(4) New threads are easily created; new process require duplication of parent process, and allocation of memory and resources for it are costly.

(5) Context switching between threads in the same process is typically faster than context switching between processes.