The process model defines a process as an executable program with a single control thread. However, most modern operating systems now offer the ability to contain multiple threads of control within a process. This tutorial discusses various concepts related to multithreaded computer structures, including the challenges associated with multithreaded programming and its impact on operating system design.



What is a thread?

A thread is a stream of execution throughout the process code, having its program counter, which keeps track of lists of instructions to execute next, and system registers, which bind its current working variables. Threads are also termed lightweight processes. A thread uses parallelism, which provides a way to improve application performance.

Major Types of Threads

For example, a web browser may have one thread to display images or text while another thread retrieves data from the network. Another example is a word processor that may have a thread for displaying the UI or graphics, a new thread for responding to keystrokes received from the user, and another thread to perform spelling and grammar checking in the background. Sometimes, a single application may be required to complete several similar tasks.

Advantages / Benefits of Threads in Operating System

The advantages of multithreaded programming can be categorized into four major headings -

  • Responsiveness: Multithreading is an interactive concept for an application that may allow a program to continue running even when a part of it is blocked or is carrying a lengthy operation, which increases responsiveness to the user.
  • Resource sharing: Mostly, threads share the memory and the resources of any process to which they fit in. The advantage of sharing code is that it allows any application to have multiple activity threads inside the same address space.
  • Economy: In OS, allocating memory and resources for process creation seems costly. Because threads can distribute resources of any process to which they belong, creating and developing context-switch threads became more economical.
  • Utilization of multiprocessor architectures: The advantages of multithreading can be significantly amplified in a multiprocessor architecture, where threads may run in parallel on diverse processors.

Multithreading Models

All the threads must have a relationship between them (i.e., user threads and kernel threads). Here is a list of three common ways of establishing this relationship.

  • Many-to-One Model: The many-to-one model plots several user-level threads to a single kernel thread.
  • One-to-One Model: The one-to-one model maps every user thread to a kernel thread and provides more concurrency than the many-to-one model.
  • Many-to-Many Model: In the many-to-many model, many user-level threads get mapped to a smaller or equal quantity of kernel threads. The number of kernel threads might be exact to a particular application or a specific machine.


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram