Operating System Exam Notes: Scheduling and Memory Management

Alright Buddy 👍
Here are 4–5 line, exam-ready answers for each topic you listed:

Operating System Concepts: Part 1

1. FCFS (First Come First Serve) Scheduling

FCFS is a non-preemptive CPU scheduling algorithm where processes are executed in the order of their arrival. The process that arrives first gets the CPU first. It is simple to implement using a queue. However, it can cause long waiting times and the convoy effect.

2. SJF (Shortest Job First) Scheduling

SJF selects the process with the shortest CPU burst time for execution. It can be preemptive or non-preemptive. This algorithm minimizes the average waiting time. Its main drawback is that it requires knowing the burst time in advance.

3. Round Robin Scheduling

Round Robin is a preemptive scheduling algorithm where each process is given a fixed time quantum. After the quantum expires, the process is moved to the back of the queue. It ensures fairness and is suitable for time-sharing systems. A time quantum that is too small or too large affects performance.

4. FIFO (First In First Out) Page Replacement

FIFO replaces the oldest page in memory when a page fault occurs. It is easy to implement using a queue. However, it may suffer from Belady’s Anomaly, where increasing the number of frames increases page faults. It does not consider page usage frequency.

5. LRU (Least Recently Used) Page Replacement

LRU replaces the page that has not been used for the longest time. It is based on the Principle of Locality of Reference. It performs better than FIFO in most cases. However, it is expensive to implement due to the need for tracking recent usage.

6. Optimal Page Replacement

Optimal page replacement replaces the page that will not be used for the longest time in the future. It gives the minimum possible page faults. It is mainly used for comparison and is not practical because future references cannot be predicted.

7. File Directory and File Attributes

A file directory stores information about files such as name, location, and attributes. File attributes include size, type, permissions, creation date, and owner. Directories help the OS in file management and provide a logical organization of files.

8. Operating System (OS)

An Operating System is system software that acts as an interface between the user and the hardware. It manages the CPU, memory, files, and I/O devices. It also provides security and resource allocation. Examples include Windows, Linux, and Android.

9. Preemptive and Non-Preemptive Scheduling

In preemptive scheduling, a running process can be interrupted by the OS (e.g., Round Robin). In non-preemptive scheduling, once a process starts, it runs until completion (e.g., FCFS). Preemptive scheduling improves responsiveness, while non-preemptive is simpler.

10. Multiprogramming

Multiprogramming allows multiple processes to reside in memory at the same time. The CPU switches between processes to maximize utilization. It improves system efficiency; however, it increases memory management complexity.

11. Multitasking

Multitasking allows a single user to run multiple tasks simultaneously. The CPU rapidly switches between tasks to improve the user experience. Examples include running a web browser and a music player together.

12. Multiprocessing

Multiprocessing uses multiple CPUs or cores to execute processes in parallel. It increases throughput and reliability. It is commonly used in servers, though it is expensive and complex to manage.

If you want, Buddy 😊
I can also give:

  • Numerical solved examples
  • Diagrams
  • Last-minute revision notes
  • Important exam questions

Just tell me 👍 Alright Buddy 👍
Below are 4–5 line, exam-ready answers for each question. Keep revising from this.

Operating System Concepts: Part 2

1. Paging and Memory Mapping

Paging is a memory management technique where logical memory is divided into fixed-size pages and physical memory into frames. A page table maps each page number to a frame number.
Logical Address = (Page Number, Offset).
Physical Address = (Frame Number, Offset).
This technique removes external fragmentation.

2. Contiguous File Allocation

In contiguous allocation, a file occupies consecutive disk blocks. The directory stores the starting block and the length of the file. Advantages: Simple and fast access. Disadvantages: External fragmentation and the fact that file sizes cannot grow easily.

3. Page Fault & Min/Max Page Faults

A page fault occurs when a required page is not present in the main memory. Minimum Page Faults = Number of distinct pages (i). Maximum Page Faults = Length of the reference string (P). This is independent of the page replacement algorithm when frames are limited.

4. Disk Scheduling (FCFS & SSTF)

FCFS Total Head Movement: 748 cylinders. SSTF Total Head Movement: 174 cylinders. SSTF reduces seek time by serving the nearest request first, whereas FCFS is simple but often inefficient.

5. Preemptive vs Non-Preemptive Scheduling

Preemptive scheduling allows the OS to interrupt a running process (e.g., Round Robin). Non-preemptive scheduling runs a process until completion (e.g., FCFS). Preemptive improves response time, while non-preemptive is simpler to implement.

6. Critical Section Problem

The critical section is the part of the code accessing shared resources. The problem occurs when multiple processes enter it simultaneously. Requirements: Mutual Exclusion, Progress, and Bounded Waiting. The solution ensures data consistency.

7. Process vs Thread

A process is an independent program with its own address space. A thread is a lightweight unit within a process. Threads share memory and resources. Example: Browser tabs acting as threads within a single process.

8. Thrashing in Virtual Memory

Thrashing occurs when a system spends most of its time paging instead of executing. It happens due to a high degree of multiprogramming, causing CPU utilization to drop drastically. Solution: Reduce the number of processes or increase the number of frames.

9. Process Lifecycle & PCB

Process states include New, Ready, Running, Waiting, and Terminated. The PCB (Process Control Block) stores the process ID, state, registers, and scheduling info. Context switching saves the current PCB and loads the next PCB to enable multitasking.

10. Dining Philosopher Problem

This is a synchronization problem involving shared resources (forks). A deadlock may occur if all philosophers pick up one fork simultaneously. Semaphores are used to control fork access, ensuring mutual exclusion and avoiding deadlock.

11. Paging vs Segmentation

Paging uses fixed-size pages, while segmentation uses variable-size segments. Paging avoids external fragmentation and supports logical program structure. Paging can cause internal fragmentation, whereas segmentation causes external fragmentation.

12. Multiprogramming, Time Sharing, Real-Time OS

Multiprogramming keeps multiple jobs in memory to maximize CPU usage. Time-sharing gives CPU time slices to multiple users. A Real-Time OS (RTOS) responds within strict deadlines and is used in medical and control systems.

13. Time Sharing vs Multiprogramming

Time-sharing focuses on user interaction and uses a time quantum. Multiprogramming focuses on CPU utilization and does not necessarily require a fast response time.

14. Internal vs External Fragmentation

Internal fragmentation occurs within allocated memory blocks. External fragmentation occurs between free memory blocks. Paging reduces external fragmentation, while segmentation suffers from it.

15. Medium Term Scheduler

The medium-term scheduler manages the swapping of processes. It suspends or resumes processes to control the memory load and help reduce thrashing. It is commonly used in multiprogramming systems.

16. Multithreading Pros & Cons

Advantages: Better CPU utilization and responsiveness; resource sharing is efficient. Disadvantages: Complex synchronization and difficult debugging.

17. Thrashing (Why it Occurs)

Thrashing occurs due to insufficient memory frames. A high page fault rate overloads disk I/O, leaving the CPU idle. It is controlled by reducing the degree of multiprogramming.

18. Convoy Effect

The convoy effect occurs when a long process holds the CPU, making short processes wait unnecessarily. It is typically seen in FCFS scheduling and reduces overall system efficiency.

19. Batch Operating System

A Batch OS executes jobs in batches without user interaction. Jobs are processed sequentially. It was used in early mainframe systems for tasks like payroll processing.

20. Process States

States include New, Ready, Running, Waiting, and Terminated. A process moves between states based on specific events, and the scheduler manages these transitions. A state diagram shows this flow.

21. Belady’s Anomaly

Belady’s Anomaly is the phenomenon where increasing the number of frames increases page faults. This occurs in the FIFO algorithm and violates the stack property. It is not seen in LRU or Optimal algorithms.

22. Multiprogramming vs Multiprocessing vs Multitasking

Multiprogramming: Multiple jobs in memory. Multiprocessing: Multiple CPUs. Multitasking: Multiple tasks per user. Each improves system performance in different ways.

23. Scheduling Queues & Thread

Job queue, Ready queue, and Device queue are used by schedulers (Long-term, Short-term, and Medium-term). A thread is a lightweight execution unit that shares process resources.

24. Bakery Algorithm

The Bakery Algorithm is a software solution for mutual exclusion. It uses ticket numbers similar to a bakery system to ensure mutual exclusion, progress, and bounded waiting for multiple processes.

25. Race Condition

A race condition occurs when multiple processes access shared data concurrently, and the final result depends on the execution order. It is solved using synchronization techniques.

26. Different Time Quantum in Multilevel Queue

A smaller time quantum improves response for interactive jobs, while a larger time quantum reduces overhead for batch jobs. This balances performance and improves overall scheduling.

If you want, I can mark important questions, draw diagrams, or give last-day revision tips 📘🔥