CSC 302- Principles of Operating Systems |
Assignment on Multithreading |
Stephen Nyabuti – 12S01ABT023 |
Feb 2013 |
1. How multithreading works in a server
Multithreading occurs when a process executing an application, is divided into threads that can run concurrently. Multithreading is useful for applications that perform a number of essentially independent tasks that do not need to be serialized.
When a multithreaded application is active in a server, the events that occur take place in three phases:
i. Start-up phase- requests come in and are handed to a thread for processing.
ii. Work phase- in this phase multiple client requests are handled ...view middle of the document...
Another application will not wait pending the completion of another request.
* They use a cooperative approach to sharing the CPU which is a drawback.
* Blocking system calls are problematic since one blocked thread will block all threads.
* In cooperative multithreading the thread themselves are relied to relinquish control once they stop. This creates problems when threads are waiting for resources to become available.
* In preemptive multithreading, a system may make a context switch at an inappropriate time causing priority inversion or other negative effects.
As Kernel space threads
* No runtime system in each process
* The Kernel can easily reschedule threads when they block.
* Improved throughput - many concurrent computed operations and I/O requests within a single process.
* Simultaneous and fully symmetric use of multiple processors for computation and I/O.
* Improved server responsiveness. Large or complex requests or slow clients do not block other requests for service. The overall throughput of the server is much better.
* Minimized system resource usage. Threads impose minimal impact on system resources. They require less overhead to create manage and maintain compared to a traditional process.
* Thread synchronization functions can be used to provide enhanced process- to - process communication.
* The system may make a context switch at an inappropriate time causing priority inversion or other negative effects. This is a drawback.
* Another disadvantage in kernel space multithreading is slower thread switching compared to user space threads.
* Thread scheduling is also slower than in user space threads.
* They get blocked if all of their associated kernel threads get blocked even if there are some user threads that are ready to run.
3. Challenges brought about by multithreading and how they can...