12/16 12/11 OS作業 | |
---|---|
名稱 | 12/11 OS作業 |
日期 | 12/16 |
課程名稱 | 作業系統 |
指導教師 | 劉艾華 |
1.What kind of strategies we can have for using thread pools?
Reasons for using a thread pool, rather than the obvious alternative of spawning one thread per task, are to prevent the time and memory overhead inherent in thread creation,and to avoid running out of resources such as open files or network connections (of which operating systems allocate a limited number to running programs).A common way of distributing the tasks to threads is by means of a synchronized queue. The threads in the pool take tasks off the queue, perform then, then return to the queue for their next task.
2.Why the windows uses one to one mapping for the threads while there are many to many available?
We can see the defination of one-to-one and many-to-many first.
One-to-one model:
The one-to-one model creates a separate kernel thread to handle each user thread.
One-to-one model overcomes the problems listed above involving blocking system calls and the splitting of processes across multiple CPUs.
However the overhead of managing the one-to-one model is more significant, involving more overhead and slowing down the system.
Most implementations of this model place a limit on how many threads can be created.
Linux and Windows from 95 to XP implement the one-to-one model for threads.
And, many-to-many model:
The many-to-many model multiplexes any number of user threads onto an equal or smaller number of kernel threads, combining the best features of the one-to-one and many-to-one models.
Users have no restrictions on the number of threads created.
Blocking kernel system calls do not block the entire process.
Processes can be split across multiple processors.
Individual processes may be allocated variable numbers of kernel threads, depending on the number of CPUs present and other factors.
The <oneToOneMappings> element of the <iisClientCertificateMappingAuthentication> element maps individual client certificates to individual user accounts on a one-to-one basis. These one-to-one certificate mappings can be used in place of the more commonly used methods of authentication, such as Windows authentication or Basic authentication.
3.Specify the differences between processes and threads?
A process is an executing instance of an application. What does that mean? Well, for example, when you double-click the Microsoft Word icon, you start a process that runs Word. A thread is a path of execution within a process. Also, a process can contain multiple threads. When you start Word, the operating system creates a process and begins executing the primary thread of that process.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.
更新日期:2015/12/16 下午 06:53:03