Press ESC to close

Processes and Threads in Operating System

Process and Threads

Processes and Threads in Operating System is an abstraction of a running program, a process is the most fundamental idea in any operating system. A computer system’s operating system (OS) organizes and carries out different activities. In this perspective, processes and threads are basic ideas that are essential to a system’s overall performance and usefulness. They provide simultaneous operation even with a single processor. The processes are the only reason modern computing exists.

Operating System Process

  • A process is a program that is being carried out.
  • A process in progress is arranged into consecutive processes. CPU is required for every process to finish executing—the CPU alternates between these active activities.
  • Any multiprogramming system has a CPU that swiftly changes between processes, with each one lasting tens or hundreds of milliseconds.
  • A process is any form of activity. It has a state, an input, an output, and a program.
  • A scheduling algorithm is used to decide when to stop working on one task and serve another, allowing a single processor to be shared by multiple processes.
  • A program, on the other hand, is something that can be kept on disk but does nothing.
process state

Process Memory

  • The compiled program code is read in from non-volatile storage and placed into the text area at the program launch.
  • Global and static variables are allocated and initialized before main is executed, and are stored in the data section.
  • Calls to new, delete, malloc, free, etc. are used to manage the heap, which is utilized for dynamic memory allocation.
  • For local variables, the stack is utilized.

Process Creation in OS

A process can create several new processes by creating process system calls during the process execution. The parent process creates a new process known as the child process. Every new process in turn generates another process, resulting in a tree-like arrangement. These processes can be distinguished by unique identifiers, often denoted as pid, which are usually integer numbers. Every process needs some resources like CPU time, memory, file, and I/O devices to accomplish.

Whenever a process creates a subprocess and maybe each subprocess can obtain its resources directly from the operating system or the resources of the parent process. The parent process needs to partition its resources among all its children or it may be able to share some resources to several children. Restricting a child process to a subset of the parent’s resources prevents any process from overloading the system by creating too many sub-processes. A process is going to obtain its resources whenever it is created.

Process Deletion in OS

Process deletion involves freeing allocated resources during the process creation, closing open files, and notifying other processes of its deletion. The operating system ensures that the ending process does not cause disruptions to other running processes.

Threads in the Operating System

The responsibility of managing all threads while simultaneously sharing memory with other resources and processes lies with the operating system. Just as a single task can be divided among multiple people to enhance efficiency and speed through collaboration, a process can similarly be divided into multiple threads to achieve greater efficiency and speed.

Threads in the Operating System

Importance of Threads

  • To increase the application performance we need threads.
  • Threads have their CPU states but they transfer their address space with the process that created them during the process.
  • The threads can also be given priorities, similar to processes, allowing higher-priority threads to be executed before others.
  • Each thread has its thread control block (TCB), analogous to a process control block (PCB), where all the thread information is stored. This TCB facilitates context switching between threads, particularly when threads share the same address space and require resource synchronization for their activities.

Frequently Asked Questions (FAQs)

  1. What is Multi-Threading?

    Achieving parallelism involves dividing a process into multiple threads is called multi-threading.

  2. What is a process?

    An instance of a program running in a computer is known as a process. In some operating systems, this term is similar in meaning to task.

  3. What is thread synchronization?

    The collaborative act of synchronization involves two or more threads making sure that each thread reaches a known point of operation in relation to other threads before they continue.

Related Posts

Read More>>>>

Er. Vaibhav Sharma

Vaibhav Sharma, with a background in Computer Science Engineering, has a passion for writing and simplifying complex technology. At Engineeringa2z, he combines his technical knowledge with clear and engaging content to help readers easily understand and stay informed about the latest in technology.

Leave a Reply

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