Computer Science
Grade 11
20 min
Process Management
Process Management
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Define a process and differentiate it from a program.
Illustrate the five-state process model (New, Ready, Running, Waiting, Terminated).
Explain the structure and purpose of a Process Control Block (PCB).
Trace the execution of code involving `fork()` and `exec()` system calls.
Analyze the performance of the First-Come, First-Served (FCFS) scheduling algorithm by calculating average waiting and turnaround times.
Describe two methods of Inter-Process Communication (IPC).
Ever wonder how your computer can stream music, run a code editor, and download a file all at once without mixing everything up? 🤔 That's the magic of process management!
This tutorial explores how an operating system juggles multiple tasks simultaneously. We will learn about what...
2
Key Concepts & Vocabulary
TermDefinitionExample
ProcessA program in execution. It's an active entity that has a program counter, stack, and data section, unlike a program, which is a passive file on a disk.When you double-click the icon for a web browser, the operating system loads the browser's code into memory and starts it as a process.
Process Control Block (PCB)A data structure in the operating system kernel that contains all the information needed to manage a particular process.A PCB for a running text editor process would store its Process ID (PID), its current state (e.g., 'Running'), CPU register values, and a list of open files.
Process StateThe current status of a process in its lifecycle, such as running on the CPU, ready to run, or waiting for an event like I/O.A process downloadin...
3
Core Syntax & Patterns
The `fork()` System Call Pattern
pid = fork();
if (pid == 0) {
// Child process code
} else if (pid > 0) {
// Parent process code
} else {
// Fork failed
}
Used to create a new process. `fork()` is called once but returns twice: it returns 0 to the newly created child process and the Process ID (PID) of the child to the parent process. This allows for different code paths for the parent and child.
The `exec()` System Call Family
execvp("new_program", args_array);
Used to replace the current process's memory space with a new program. When a process calls `exec()`, it ceases to exist, and the new program starts executing in its place. It's often used by a child process after a `fork()` to run a different program.
First-Come, First-Served (FCFS)...
4 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Easy
Which statement best describes the primary difference between a program and a process?
A.process is a passive file on a disk, while a program is an active entity in memory.
B.process is an active instance of a program that is currently in execution.
C.program and a process are interchangeable terms for the same concept.
D.program is a data structure in the OS kernel, while a process is a set of instructions.
Easy
What is the main purpose of a Process Control Block (PCB)?
A.To store all the information the OS needs to manage a specific process.
B.To list all programs currently stored on the disk.
C.To execute the process's instructions directly on the hardware.
D.To manage Inter-Process Communication channels exclusively.
Easy
When the scheduler selects a process from the 'Ready' queue to execute, what state does the process transition into?
A.Waiting
B.Terminated
C.New
D.Running
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free