Introduction to Process Management | Operating System - Computer Science Engineering (CSE) PDF Download

Program vs Process 

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, as opposed to a program, which is considered to be 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). 

What does a process look like in memory? 
Introduction to Process Management | Operating System - Computer Science Engineering (CSE)

  • Text Section: A Process, sometimes known as the Text Section, also includes the current activity represented by the value of the Program Counter. 
  • Stack: The stack contains the temporary data, such as function parameters, returns addresses, and local variables. 
  • Data Section: Contains the global variable. 
  • Heap Section: Dynamically allocated memory to process during its run time. 

Attributes or Characteristics of a Process 

A process has the following attributes.

  1. Process Id: A unique identifier assigned by the operating system
  2. Process State: Can be ready, running, etc.
  3. CPU registers: Like the Program Counter (CPU registers must be saved and restored when a process is swapped in and out of CPU)
  4. Accounts information
  5. I/O status information: For example, devices allocated to the process, open files, etc 
  6. CPU scheduling information: For example, Priority (Different processes may have different priorities, for example a short process may be assigned a low priority in the shortest job first scheduling)

All of the above attributes of a process are also known as the context of the process.
Every process has its own process control block(PCB), i.e each process will have a unique PCB. All of the above attributes are part of the PCB. 

States of Process 
A process is in one of the following states: 

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

Introduction to Process Management | Operating System - Computer Science Engineering (CSE)

Context Switching 

The process of saving the context of one process and loading the context of another process is known as Context Switching. In simple terms, it is like loading and unloading the process from the running state to the ready state. 

When does context switching happen? 

  1. When a high-priority process comes to a ready state (i.e. with higher priority than the running process) 
  2. An Interrupt occurs 
  3. User and kernel-mode switch (It is not necessary though) 
  4. Preemptive CPU scheduling used. 

Context Switch vs Mode Switch

 


A mode switch occurs when the CPU privilege level is changed, for example when a system call is made or a fault occurs. The kernel works in more a privileged mode than a standard user task. If a user process wants to access things that are only accessible to the kernel, a mode switch must occur. The currently executing process need not be changed during a mode switch.
A mode switch typically occurs for a process context switch to occur. Only the kernel can cause a context switch. 

CPU-Bound vs I/O-Bound Processes
A CPU-bound process requires more CPU time or spends more time in the running state.
An I/O-bound process requires more I/O time and less CPU time. An I/O-bound process spends more time in the waiting state.

Exercise
Q.1. Which of the following need not necessarily be saved on a context switch between processes? (GATE-CS-2000) 
(a) General purpose registers 
(b) Translation lookaside buffer 
(c) Program counter 
(d) All of the above 
Ans: (b)
Explanation: In a process context switch, the state of the first process must be saved somehow, so that when the scheduler gets back to the execution of the first process, it can restore this state and continue. The state of the process includes all the registers that the process may be using, especially the program counter, plus any other operating system-specific data that may be necessary. A translation look-aside buffer (TLB) is a CPU cache that memory management hardware uses to improve virtual address translation speed. A TLB has a fixed number of slots that contain page table entries, which map virtual addresses to physical addresses. On a context switch, some TLB entries can become invalid, since the virtual-to-physical mapping is different. The simplest strategy to deal with this is to completely flush the TLB. 


Q.2. The time taken to switch between user and kernel modes of execution is t1 while the time taken to switch between two processes is t2. Which of the following is TRUE? (GATE-CS-2011) 
(a) t1 > t2 
(b) t1 = t2 
(c) t1 < t2 
(d) nothing can be said about the relation between t1 and t2. 
Ans: (c)
Explanation: Process switching involves a mode switch. Context switching can occur only in kernel mode.

The document Introduction to Process Management | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Introduction to Process Management - Operating System - Computer Science Engineering (CSE)

1. What is the difference between a program and a process?
Ans. A program is a set of instructions or code that is stored on a computer's storage device, while a process refers to the execution of a program. In other words, a program is a passive entity, whereas a process is an active entity that is running in the computer's memory.
2. How does process management ensure efficient use of system resources?
Ans. Process management plays a crucial role in ensuring efficient use of system resources. It allocates and manages system resources such as CPU time, memory, and I/O devices to different processes. By controlling the execution of processes and prioritizing them based on their importance and requirements, process management helps optimize resource utilization, improve system performance, and prevent resource conflicts.
3. What are some common process management techniques?
Ans. Some common process management techniques include process scheduling, which determines the order in which processes are executed; process synchronization, which ensures that processes cooperate and coordinate their actions; and process communication, which allows processes to exchange data and information. Additionally, process creation and termination, memory management, and I/O management are also important aspects of process management.
4. How does process management handle multitasking in modern operating systems?
Ans. Process management in modern operating systems handles multitasking by using techniques such as time-sharing and context switching. Time-sharing allows the CPU to be shared among multiple processes, giving each process a certain amount of time to execute before switching to another. Context switching refers to the process of saving and restoring the state of a process, allowing it to resume execution from where it left off when it regains CPU access.
5. What is the role of process management in ensuring system stability and reliability?
Ans. Process management plays a crucial role in ensuring system stability and reliability. It monitors the execution of processes, detects and handles errors and exceptions, and prevents processes from interfering with each other or the operating system. By enforcing process isolation and protection mechanisms, process management helps maintain system integrity and prevents the spread of errors or malicious activities. Additionally, it facilitates error recovery and system restart in case of failures, enhancing the overall reliability of the system.
10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

pdf

,

Introduction to Process Management | Operating System - Computer Science Engineering (CSE)

,

Objective type Questions

,

video lectures

,

ppt

,

MCQs

,

Introduction to Process Management | Operating System - Computer Science Engineering (CSE)

,

study material

,

mock tests for examination

,

practice quizzes

,

Extra Questions

,

Exam

,

Sample Paper

,

Viva Questions

,

Free

,

Introduction to Process Management | Operating System - Computer Science Engineering (CSE)

,

Summary

,

Previous Year Questions with Solutions

,

Semester Notes

,

past year papers

,

Important questions

,

shortcuts and tricks

;