12/17 12/11OS作業

名稱
12/11OS作業
日期
12/17
課程名稱
作業系統
指導教師
劉艾華
心得
1. What kind of strategies we can have for using thread pools? Name two of them.
Thread pools can handle thread lifecycle automatically according to the strategy selected on thread pool creation. An important feature of a thread pool is that it allows applications to degrade gracefully. A server application can queue incoming requests and handle them when it has enough resources, like memory or CPU, to do so. Otherwise, without thread pools, the server application may crash. There are many reasons why there are no more resources. For example, multiple connections to the server caused by a denial-of-service attack may result in many threads running in parallel which in turn leads to thread starvation. Moreover, programmers who run threads manually must remember to handle exceptional situations when a thread dies due to an exception.
2. Why the windows uses one-to-one mapping for the threads while it has many-to-many available?
one-to-one Model: Each user thread maps to a kernel thread.
many-to-many Model: Multiplex many user thread to a smaller or equal number of kernel threads.
1):The one-to-one model allows for greater concurrency.
2):Provides more concurrency than the many-to-one by allowing another thread to run when a thread makes a blocking system call;
3):Allows multiple threads to run in parallel on multiprocessors;


3. Please specify the differences between processes and threads.
1): It’s important to note that a thread can do anything a process can do. But since a process can consist of multiple threads, a thread could be considered a ‘lightweight’ process. Thus, the essential difference between a thread and a process is the work that each one is used to accomplish. Threads are used for small tasks, whereas processes are used for more ‘heavyweight’ tasks – basically the execution of applications.

2):Another difference between a thread and a process is that threads within the same process share the same address space, whereas different processes do not. This allows threads to read from and write to the same data structures and variables, and also facilitates communication between threads. Communication between processes – also known as IPC, or inter-process communication – is quite difficult and resource-intensive.