Unit 2: Process and Memory Management (CS 4001 / CB/IT 4001)

 (Course Code: CS 4001 / CB/IT 4001 – Operating Systems – 4th Semester Polytechnic CS)

📌 These notes are provided by Garima Kanwar on the blog Rajasthan Polytechnic. Stay connected for more study materials. For PDF versions, join our WhatsApp and Telegram groups.

📢 🔔 Important:
👉 Full PDF available in our WhatsApp Group | Telegram Channel
👉 Watch the full lecture on YouTube: BTER Polytechnic Classes

Process and Memory management

2.1 Process Management

Process management is one of the core functionalities of an operating system. A process is a program in execution. The OS is responsible for handling process creation, scheduling, execution, and termination.

2.1.1 Process Concepts

A process consists of multiple components, including:

  • Program Code – Contains the executable instructions.

  • Process Control Block (PCB) – Stores process-related information such as process ID, process state, registers, and scheduling details.

  • Process States:

    • New: The process is created but not yet ready for execution.

    • Ready: The process is waiting for CPU time.

    • Running: The process is currently executing.

    • Waiting: The process is waiting for an I/O operation.

    • Terminated: The process has completed execution.

📌 Diagram of Process States:

      New ---> Ready ---> Running ---> Terminated  
                  |             |  
                  v             v  
              Waiting <-------> Running  
process states in os

2.1.2 Operations on Processes

The OS performs the following operations on processes:

  • Process Creation: A new process is created by the parent process.

  • Process Termination: The process completes execution or is forcibly terminated.

  • Process Execution: The process moves through different states during its lifecycle.

  • Process Scheduling: Determines which process gets CPU time.

operations on processes

2.1.3 Inter-Process Communication (IPC)

Inter-Process Communication (IPC) allows processes to exchange data and synchronize execution.

Types of IPC:

  • Shared Memory: Processes communicate by accessing the same memory space.

  • Message Passing: Processes send and receive messages via communication channels.

📌 Example: Shared Memory vs. Message Passing

Process A   <---- Shared Memory ---->   Process B  

Process A   <---- Message Queue ---->   Process B  
inter process communication (IPC) & types

2.2 Process Scheduling

Process scheduling ensures efficient CPU utilization by determining the order in which processes execute.

process scheduling in os

2.2.1 First-Come, First-Served (FCFS)

  • Jobs execute in the order of arrival (like a queue).

  • Non-preemptive scheduling.

  • Disadvantage – Long waiting times (Convoy Effect).

📌 Example:

Processes:   P1  P2  P3  
Arrival Time: 0   1   2  
Burst Time:   5   3   2  

FCFS Execution Order: P1 → P2 → P3  

2.2.2 Shortest Job First (SJF)

  • The process with the shortest execution time runs first.

  • Can be preemptive or non-preemptive.

  • Disadvantage – Requires prior knowledge of execution time.

📌 Example:

Processes:   P1  P2  P3  
Burst Time:   7   2   5  

SJF Execution Order: P2 → P3 → P1  

2.2.3 Priority Scheduling

  • Each process is assigned a priority.

  • Highest priority process executes first.

  • Can be preemptive or non-preemptive.

📌 Example:

Processes:   P1  P2  P3  
Priority:     3   1   2  

Execution Order: P2 → P3 → P1  

2.2.4 Round Robin (RR)

  • Each process gets a fixed time quantum (e.g., 4ms).

  • If a process does not finish, it goes to the end of the queue.

📌 Example:

Time Quantum: 4ms  
Processes:    P1  P2  P3  
Burst Time:    5   3   7  

Execution Order: P1 → P2 → P3 → P1 → P3  

2.3 Multi-Threaded Programming

A thread is a lightweight process that runs within a process.

  • User Threads – Managed at the user level.

  • Kernel Threads – Managed by the OS.

Advantages:
✅ Faster context switching
✅ Efficient resource sharing
✅ Parallel execution


2.4 Memory Management

Memory management ensures efficient allocation and deallocation of memory.

2.4.1 Memory Allocation

  • Static Allocation: Fixed memory at compile time.

  • Dynamic Allocation: Memory allocated at runtime.


2.4.2 Swapping

  • Processes move between RAM and disk to free up memory.

  • Allows more processes to run than available RAM.

📌 Diagram:

+-----------+   +-----------+  
| Process A |   | Process B |  
+-----------+   +-----------+  
↕ Swapping  
+-----------+   +-----------+  
| Process C |   | Process D |  
+-----------+   +-----------+  
swapping in os

2.4.3 Paging

  • Memory is divided into fixed-size pages.

  • Reduces external fragmentation but may cause page faults.


2.4.4 Segmentation

  • Memory is divided into variable-sized segments.

  • Better for handling logical divisions of programs.


2.5 Virtual Memory

Virtual memory allows execution of processes larger than available RAM.

  • Uses disk as an extension of RAM.

  • Implements demand paging and swapping.

  • Enhances multitasking capabilities.


Conclusion

This concludes Unit 2: Process and Memory Management in Operating Systems (CS 4001/CB/IT 4001).

🔗 For more notes, visit our blog regularly!
📌 Join our WhatsApp & Telegram groups for PDFs.
📺 Watch full lectures on our YouTube channel: BTER Polytechnic Classes!

📢 🔔 Download PDF & Join Study Groups:
📥 WhatsApp Group: Join Now
📥 Telegram Channel: Join Now
📺 Watch Lecture on YouTube: BTER Polytechnic Classes
👉 📖 More Notes: Next Chapter – File Management
📍 Stay connected for more study materials! 🚀

Post a Comment

0 Comments