intermediate

opertng system concept

Comprehensive AI-generated study curriculum with 3 detailed note modules.

0 students cloned 1 views 3 notes

Course Syllabus

  1. Introduction to Processes
  2. Process Control Block (PCB) and Representation
  3. Process Scheduling Fundamentals
  4. Context Switching
  5. Process Creation
  6. Process Termination

Study Notes

Introduction to Processes

Introduction to Processes

TL;DR

A process is a program that's currently running, and it has multiple parts like code, data, and a stack. As a process runs, its state changes, tracking activity from creation to termination. The Operating System (OS) uses a Process Control Block (PCB) to manage each process.

1. The Mental Model

Think of a process as a recipe being actively cooked. The recipe book is the program code, the ingredients are data, the chef's notes are the stack, and the actual cooking is the execution. The OS is like the kitchen manager, keeping track of all the cooking processes.

2. The Core Material

What is a Process?

A process is essentially a program in execution. Its execution happens step-by-step, in a sequential fashion. Processes are made up of several key parts:

  • Program Code (text section): This is the actual set of instructions.
  • Current Activity: Includes the program counter (which instruction to execute next) and other processor contents (like CPU registers).
  • Stack: Holds temporary data such as function parameters, return addresses, and local variables.
  • Data Section: Contains global variables used by the program.
  • Heap: Memory that's dynamically allocated during the program's runtime.

It's common for one program to become several processes. For example, if multiple users open the same application (like a web browser), each user's instance is a separate process.

Process States

A process doesn't stay static; it changes its state as it executes. Here are the five main states:

  • new: The process is being created.
  • running: Its instructions are actively being executed by the CPU.
  • waiting: The process is paused, waiting for some event to happen (e.g., waiting for input/output to complete or a resource to become available).
  • ready: The process is ready to run and waiting to be assigned to a CPU.
  • terminated: The process has finished its execution.
graph TD
    subgraph Process Life Cycle
        New --> Ready;
        Ready --> Running;
        Running --> Waiting;
        Waiting --> Ready;
        Running --> Terminated;
    end

Process Control Block (PCB)

The OS uses a Process Control Block (PCB), sometimes called a Task Control Block, to manage each process. Think of it as a process's ID card and status report. The PCB contains all the information associated with that specific process, inclu

Read full note →

Process Control Block (PCB) and Representation

Process Control Block (PCB) and Representation

TL;DR

A Process Control Block (PCB) is how your operating system keeps track of all the vital information about a process, like its state and resources. Every process executing on your computer has one. The PCB is critical for the OS to manage and switch between different running programs efficiently.

1. The Mental Model

Think of the Process Control Block (PCB) as a process's ID card and personal file rolled into one. It holds everything the OS needs to know about that specific process, enabling the system to pause it, resume it, or manage its resources without confusion.

2. The Core Material

A process is a program in execution. It's more than just the code; it also includes:
* The program code (text section): The actual instructions.
* Current activity: What the program is doing right now, tracked by the program counter (which instruction is next) and other processor contents.
* Stack: Temporary data like function parameters, return addresses, and local variables.
* Data section: Global variables.
* Heap: Memory that's dynamically allocated as the program runs.

One program can lead to several processes. For instance, if multiple people are running the same application, each user's instance is a separate process.

As a process runs, it changes its state. These states include:
* new: The process is being created.
* running: Instructions are actively being executed by the CPU.
* waiting: The process is paused, waiting for an event (like finishing I/O).
* ready: The process is prepared to run and is waiting for the CPU.
* terminated: The process has finished execution.

Process Control Block (PCB)

Each process is represented in the OS by its unique Process Control Block (PCB), sometimes called a task control block. The PCB is the central repository for all process-specific information.

The PCB contains crucial details that allow the OS to manage the process effectively, such as:
* Process state: Whether it's running, waiting, ready, etc.
* Program counter: Points to the next instruction to execute.
* CPU registers: Contents of the CPU's internal registers when the process was last active.
* CPU scheduling information: Priority, pointers to scheduling queues.
* Memory-management information: Base and limit registers, page tables, segment tables.
* **Accounting informatio

Read full note →

Process Scheduling Fundamentals

Process Scheduling Fundamentals

TL;DR

Process scheduling ensures your computer's CPU is always busy by carefully managing "processes," which are programs in execution. The operating system uses various queues and schedulers to move processes through different states, like waiting or running, to efficiently share the CPU. Understanding these fundamentals helps you grasp how multiple applications can run seemingly simultaneously.

1. The Mental Model

Think of your computer's CPU as a single chef in a busy kitchen. Many orders (processes) come in, but only one can be cooked (executed) at a time. Process scheduling is the system that helps the chef decide which order to work on next, ensuring no time is wasted and all orders eventually get prepared.

2. The Core Material

A process is essentially a program in execution. When you launch an application, it becomes a process. Each process needs to progress in a sequential fashion. To identify and manage each process, the operating system uses a Process Control Block (PCB), which holds all the critical information about that process.

Components of a Process Control Block (PCB)

The PCB is like a passport for a process, containing vital details:
* Process state: Shows whether the process is new, running, waiting, ready, or terminated.
* Program counter: Points to the exact memory address of the next instruction to be executed by that process.
* CPU registers: Stores the contents of the CPU's internal registers specific to the process.
* CPU scheduling information: Includes details like the process's priority and pointers to scheduling queues.
* Memory-management information: Tracks the memory allocated to the process.
* Accounting information: Records how much CPU time the process has used, how long it's been running, and any time limits.
* I/O status information: Lists any I/O devices assigned to the process and its open files.

Process States

As a process executes, it moves through different states:
* new: The process is being created.
* running: The process's instructions are currently being executed by the CPU.
* waiting: The process is paused, waiting for some event (like an I/O operation to complete).
* ready: The process is in main memory and waiting for the CPU to become available so it can run.
* terminated: The process has finished its execution.

```mermaid
graph TD
subgraph Process States

Read full note →