Single-threaded and Multi-threaded Processes

Abstract

Silberschatz and Galvin (2009) explained that a process is defined as a program that perform execution via a single thread of instructions were only one task can be performed at one time. Modern operating systems allow a process to have multiple threads and as such; more than one task can be performed at a time. With such capabilities within an operating system, the system process control block (PCB) is expanded to include information for each thread. A thread is the basic unit that represents the CPU utilization, and it contains a thread ID, a register set, a program counter, and a stack. Threads are belonging to the same process and share the same code section, data section, and other operating-system resources. When a process has multiple threads it is able to perform a multitasking at a time.

Most of the modern software applications run with the multithreading concept where such applications implement a separate process with a control of multithreads. For example, a web browser can have a process running based on the user request  that can have a thread that displays images or text while another thread retrieving data from the network (Galli, 1999).

Single-threaded and Multithreaded processes 

Applications with multithreading implementation increases its responsiveness to the application’s users, for instance; with traditional single-threaded process implementation within a web server can serve only one client request at a time and can make the waiting period for other users requesting services a very long time. With more efficient multithreaded server implementation; separate threads can be created to respond to different users’ requests. Multithreading technique in the above example increased the application responsiveness to the users’ requests. Also; multithreaded programming takes full benefits of the modern architecture of multiple cores computing on a single chip where each core processor acts as a separate processor to the operating system (Titus, 2004)

Multithreading Models

Silberschatz and Galvin (2009) explained that multithreaded computing system provides user threads where they are managed without kernel support, and the kernel threads; where they are managed by the operating system. However; a relationship is exist between the user threads and the kernel threads in different multithreading models. Such relationships can be modeled as follows:

 

  • Many-to-one relationship – Where many user-level threads are mapped to a single kernel thread. In such model the thread is managed by thread library in the user space which makes such model efficient. However; the entire threads can be blocked if a thread makes a blocking system call. Also; with multiprocessors system; threads can access the kernel with only a single thread at a time and as such; multiple threads are unable to take advantage on multiprocessor and run in parallel on multiprocessors. With such model, developer will be able to create as many threads as required; however the true concurrency is not implemented since the kernel can schedule only one thread at a time.

 

  • One-to-one relationship – Where each user thread is mapped to the kernel thread. Such mechanism provides concurrency operation than the many-to-many model where other threads are allowed to run even when one of these threads makes a blocking system call. Also, such model allows multiple threads to run in parallel on multiprocessors. Since such model creates a corresponding kernel thread with every creating of user thread, an overhead of creating kernel threads can affect the performance of an application and as such; this implementation can be restricted with the number of threads that can be supported by the system. Also, with such model, developer can have a greater concurrency applications; however a limited number of threads within an application can be implemented since a limited threads can be created by the system.

 

  • Many-to-many relationship – With such model, many user-level threads can be multiplexed by a smaller or equal number of kernel threads. Also, with such model implementation in the system, developers can run as many user threads as necessary with a corresponding kernel threads that can run in parallel on a multiprocessor. However, the overhead required in creating kernel threading is great compared to the one-to-one relationship.

Finally, multithreading implementation is imperative to any modern computing system, since such mechanism can increase the responsiveness to the user, improve the resources sharing within the process, and add more efficient use of multiple cores processors. User-level threads are visible to the programmers via thread libraries that can provide the application programmer with useful APIs that can create and manage threads. The user-level threads are faster in creation and their management since no intervention is required by the system kernel, and kernel threads required to be supported and management by the operating-system and as such, the user-threads are faster than the kernel threats (Titus, 2004).

Conclusion

A thread is a flow of control with a process and it is more efficient and more productive for a process to have multiple threads to achieve the maximum efficiency of any computing system (Titus, 2004). For example, with a server that can support multithreaded processes, such server can create several threads based on the client’s requests. Multithreading allows application to be more interactive since the program can continue running even when part of such program’s thread is blocked or is involved in a lengthy operation. Also, with multiprocessor architecture that is exist in modern computing system, different threads can run in parallel on different processors (Stallings, 1991).

References

Silberschatz, A. & Galvin, P. (2009) Operating System Concepts. 8th ed. NJ: John Wiley & Sons, Inc.

Stallings, W. (1991) Operating Systems: Concepts and Examples. 2nd ed.USA:Macmillan.

Titus, T. (2004) C# Threading Handbook. 2nd ed.USA: APress

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: