Open In App

Process in Operating System

Last Updated : 30 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

A process is a program in execution. For example, when we write a program in C or C++ and compile it, the compiler creates binary code. The original code and binary code are both programs. When we actually run the binary code, it becomes a process.

  • A process is an 'active' entity instead of a program, which is considered a 'passive' entity.
  • A single program can create many processes when run multiple times; for example, when we open a .exe or binary file multiple times, multiple instances begin (multiple processes are created). .

How Does a Process Look Like in Memory? 

A process in memory is divided into several distinct sections, each serving a different purpose. Here's how a process typically looks in memory:

Process Management

  • Text Section: A text or code segment contains executable instructions. It is typically a read only section
  • Stack: The stack contains temporary data, such as function parameters, returns addresses, and local variables. 
  • Data Section: Contains the global variable. 
  • Heap Section: Dynamically memory allocated to process during its run time.

Attributes of a Process

A process has several important attributes that help the operating system manage and control it. These attributes are stored in a structure called the Process Control Block (PCB) (sometimes called a task control block). The PCB keeps all the key information about the process, including:

  1. Process ID (PID): A unique number assigned to each process so the operating system can identify it.
  2. Process State: This shows the current status of the process, like whether it is running, waiting, or ready to execute.
  3. Priority and other CPU Scheduling Information: Data that helps the operating system decide which process should run next, like priority levels and pointers to scheduling queues.
  4. I/O Information: Information about input/output devices the process is using.
  5. File Descriptors: Information about open files files and network connections.
  6. Accounting Information: Tracks how long the process has run, the amount of CPU time used, and other resource usage data.
  7. Memory Management Information: Details about the memory space allocated to the process, including where it is loaded in memory and the structure of its memory layout (stack, heap, etc.).

These attributes in the PCB help the operating system control, schedule, and manage each process effectively.

States of Process

A process is in one of the following states: 

  • New: Newly Created Process (or) being-created process.
  • Ready: After the creation process moves to the Ready state, i.e. the process is ready for execution.
  • Running: Currently running process in CPU (only one process at a time can be under execution in a single processor).
  • Wait (or Block): When a process requests I/O access.
  • Complete (or Terminated): The process completed its execution.
  • Suspended Ready: When the ready queue becomes full, some processes are moved to a suspended ready state
  • Suspended Block: When the waiting queue becomes full.

process-states

Please refer States of a Process for more details.


Next Article

Similar Reads