12/11 OS作業

名稱
12/11 OS作業
課程名稱
作業系統
指導教師
劉艾華
心得
1. what kind of strategies we can have for using thread pools
Thread pool is suitable only when you use it for operations that takes less time to complete. Thread pool threads are not suitable for long running operations, as it can easily lead to thread starvation.
If you require your thread to have a specific priority, then thread pool thread is not suitable.
You have tasks that cause the thread to block for long periods of time. The thread pool has a maximum number of threads, so a large number of blocked thread pool threads might prevent tasks from starting.
Thread pools of limited size are dangerous if the tasks running on it exchange information via blocking queues - this may cause a thread starvation

2. why the windows uses one to one mapping for the threads while there are many to many available.
In one to one model, the OS is aware of each thread and can schedule another if a particular thread blocks. The OS is unable to do this in the many-to-one model.

3. specify the differences between processes and threads.
Process: each process provides the resources needed to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variable, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Each process is started with a single threads, often called the primary thread, but can create additional threads from any of its threads.
Threads: A thread is the entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. In addition, each thread maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled. The thread context includes the thread's set of machine registers, the kernel stack, a thread environment block, and a user stack in the address space of the thread's process. Threads can also have their own security context, which can be used for impersonating clients.