What is Multi-Threading in Computer?

Multithreading

Threads are a popular way to improve application performance. In traditional operating systems, the basic unit of CPU utilization is a process. Each process has its own program counter, its own register states, its own stack, and its own address space. On the other hand, in operating systems with threads facility, the basic unit of CUP utilization is a thread. In these operating systems, a process consists of an address space and one or more threads of control. Each thread of a process has its own program counter, its own register stats, and its own stack. However, all the threads of a process also share the same set of operating system resources, such as open files, signals, accounting information, etc. Due to sharing of address space, there is no protection between the threads of a process. However, protection between multiple threads of a process is not necessary because a single user always owns a process. Multiple processes need protection from each other because different processes may belong to different users.

Motivations for Using Threads

The main motivations for using a multithreaded process instead of multiple single-threaded processes for performing some computation activities are as follows:

  1. The overhead involved in creating a new process is considerably greater than that for creating a new thread within a process. This is because when the operating system creates a new process, it has to create its address space from scratch, although the new process may inherit a part of its address space from its parent process. On the other hand, when the operating system creates a new thread, it need not create an address space for it because the new thread uses the address space of its process.
  2. Due to sharing of address space and other operating system resources among the threads of a process, the overhead involved in CPU switching among peer threads is very small as compared to CPU switching among processes having their own address spaces., This is the reason why threads are called lightweight processes.
  3. An operating system can share resources more efficiently among multiple threads of a process than among multiple processes because all threads of a process share the same address space.

Multiprocessing

Up to this point, we have considered uniprocessor systems. however, we have already seen that the use of I/O processor improves the efficiency of a computer system by making a concurrent input, processing, and output operations possible. CUP performs arithmetic and logical operations, while I/O processors, carry out I/O operations concurrently. The architecture of a computer with its CPU, memory, and I/O processors.

Designer carried further the idea of using I/O processors to improve system performance by designing systems with multiple CUPs. Such systems are called multiprocessing systems because they use multiple processors and can execute multiple processes concurrently. These systems use multiple CPUs to process either instruction from different and independent programs or different instructions from the same program simultaneously. It shows the basic organisation of a typical multiprocessing system.

Leave a Comment

Your email address will not be published. Required fields are marked *