Operating System Concepts: Memory Management, File Systems, and Processes

1 – Logical vs. Physical Address Space and Memory Allocation

Logical Address

A logical address, or virtual address, is generated by the CPU during program execution. It’s a reference point within the program’s address space and doesn’t correspond to a physical memory location.

Physical Address

A physical address specifies the actual location of data in memory. The Memory Management Unit (MMU) translates logical addresses to physical addresses before accessing data.

Drawbacks of Contiguous Memory Allocation

  • External Fragmentation: Unused memory spaces between allocated blocks can’t be utilized efficiently.
  • Internal Fragmentation: Wasted space within an allocated block if the process doesn’t use the entire block.

Measures to Remove Drawbacks

  • Paging: Divides memory into fixed-size pages, reducing external fragmentation.
  • Segmentation: Divides memory into variable-size segments based on logical units, reducing internal fragmentation.

2 – Deadlocks and Recovery Methods

Deadlock Definition

A deadlock occurs when multiple processes are blocked, each holding a resource and waiting for a resource held by another process, resulting in a standstill.

Necessary Conditions for Deadlock

  • Mutual Exclusion: Only one process can use a resource at a time.
  • Hold and Wait: A process holds at least one resource and waits for others.
  • No Preemption: Resources can’t be forcibly taken away.
  • Circular Wait: Processes form a circular chain of waiting for resources.

Deadlock Recovery Methods

  • Deadlock Prevention: Restrict resource requests to avoid deadlock conditions.
  • Deadlock Avoidance: Analyze resource allocation to prevent unsafe states.
  • Deadlock Detection and Recovery: Detect deadlocks and recover by aborting processes or preempting resources.
  • Deadlock Ignorance: Assume deadlocks are rare and handle them through system reboots.

3 – Semaphores and Critical Section Problem

Semaphores

Semaphores are integer variables used for process synchronization. They employ wait and signal operations to control access to shared resources.

Types of Semaphores

  • Counting Semaphores: Unrestricted integer values representing available resources.
  • Binary Semaphores: Restricted to 0 or 1, indicating resource availability.

Advantages of Semaphores

  • Mutual Exclusion: Ensures only one process accesses the critical section at a time.
  • No Busy Waiting: Processes wait without wasting CPU time.
  • Machine Independence: Implemented in machine-independent code.

Disadvantages of Semaphores

  • Complexity: Requires careful implementation to avoid deadlocks.
  • Modularity Loss: Wait and signal operations can hinder structured design.
  • Priority Inversion: Low-priority processes may block high-priority ones.

4 – Disk Scheduling Algorithms

First-Come, First-Served (FCFS)

Services requests in arrival order, regardless of disk head position.

Shortest Seek Time First (SSTF)

Selects the request closest to the current disk head position, minimizing seek time.

SCAN (Elevator)

Moves the disk head in one direction, servicing requests along the way, then reverses direction.

5 – File System Concepts

(i) Attributes of Files

Properties like name, type, size, location, permissions, owner, and timestamps associated with files.

(ii) Directory Structure

Hierarchical organization of files and directories in a tree-like structure for efficient storage and retrieval.

(iii) Access Matrix

A security model defining access rights of subjects (users/processes) to objects (files/resources).

6 – Operating System Overview

Definition

Software managing hardware resources, providing services to applications, and facilitating communication between hardware and software.

Advantages

  • Resource Management
  • Abstraction
  • User Interface
  • Security
  • Process Management
  • Memory Management
  • File System Management
  • Device Management

Types of Operating Systems

  • Single-User, Single-Tasking
  • Single-User, Multi-Tasking
  • Multi-User
  • Real-Time
  • Embedded
  • Distributed

7 – File Access and Protection

(a) Concept of Files and Access Methods

Files are named collections of data stored on storage devices. Access methods include sequential, direct, and indexed access.

(b) Principle and Goals of Protection

Protection safeguards system resources from unauthorized access. Goals include confidentiality, integrity, availability, authentication, authorization, auditing, and isolation.

8 – Paging and Fragmentation

Paging

Divides physical memory into frames and logical memory into pages, enabling efficient memory allocation and address translation.

Eliminating Fragmentation

  • Internal Fragmentation: Reduced by using fixed-size pages.
  • External Fragmentation: Reduced by allowing non-contiguous memory allocation.

9 – Belady’s Anomaly

An unusual behavior where increasing page frames can lead to more page faults in certain page replacement algorithms.

10 – System Diagrams

(i) Android OS Architecture

Layered architecture with Linux Kernel, HAL, ART, Native Libraries, Android Framework, and Applications.

(ii) Resource Allocation Graph

Graphical representation of resource allocation and dependencies between processes and resources.

(iii) File Access Methods

Diagrams illustrating sequential, direct, and indexed access methods.

11 – Processes and PCBs

Process

A program in execution, representing the basic unit of work in a computer system.

Program vs. Process

A program is a passive set of instructions, while a process is an active instance of a program in execution.

Process Control Block (PCB)

A data structure containing information about a process, such as ID, state, registers, memory, I/O, and scheduling details.

12 – System Calls

Definition

Functions provided by the operating system for user processes to request kernel services.

Types of System Calls

  • Process Control (e.g., fork())
  • File System (e.g., open())
  • Memory Management (e.g., malloc())
  • Input/Output (e.g., read())

13 – I/O Request Handling and Device Drivers

Device Manager

Handles I/O requests by queuing, selecting device drivers, communicating with drivers, monitoring status, and notifying applications.

Device Driver Functions

  • Device Initialization
  • Device Control and Configuration
  • Data Transfer
  • Interrupt Handling
  • Error Handling and Recovery
  • Power Management

14 – Linux File System Features

  • Hierarchical Directory Structure
  • File Types
  • File Permissions
  • File System Hierarchy Standard (FHS)
  • Symbolic Links
  • File System Journaling
  • File System Compression
  • Extended Attributes
  • Sparse Files
  • Access Control Lists (ACLs)