Fundamentals 33 min read

Operating System Fundamentals: Concurrency, Process Management, Memory Management, and Deadlock

This article provides a comprehensive overview of operating system fundamentals, covering concepts such as concurrency, shared resources, virtual memory, process and thread management, synchronization mechanisms, classic synchronization problems, memory paging and replacement algorithms, device management, disk scheduling, and deadlock detection and prevention.

Top Architect
Top Architect
Top Architect
Operating System Fundamentals: Concurrency, Process Management, Memory Management, and Deadlock

Overview

Concurrency : The ability to run multiple programs over a period of time, while parallelism requires hardware support such as multi‑core CPUs or distributed systems.

Sharing : Resources can be shared among concurrent processes, either mutually exclusive (critical resources) or simultaneous.

Virtualization : Physical entities are abstracted into multiple logical entities using time‑division and space‑division multiplexing.

Asynchrony : Processes progress in a non‑continuous, unpredictable manner.

Basic Functions

Process Management : Process control, synchronization, communication, deadlock handling, and scheduling.

Memory Management : Allocation, address mapping, protection, sharing, and virtual memory.

File Management : Storage space, directory, read/write, and protection.

Device Management : Handles I/O requests, buffering, allocation, and virtual devices.

System Calls

When a user‑mode process needs kernel services, it performs a system call, causing a transition to kernel mode.

Process Management

Process vs Thread : A process is the basic unit of resource allocation, described by a Process Control Block (PCB). Threads are the basic unit of scheduling and share the process’s resources.

Example PCB diagram omitted for brevity.

Synchronization

Critical Section : Code that accesses a critical resource.

// entry section
// critical section;
// exit section

Semaphores : Integer variables supporting down (P) and up (V) operations.

typedef int semaphore;
semaphore mutex = 1;
void P1() {
    down(&mutex);
    // critical section
    up(&mutex);
}
void P2() {
    down(&mutex);
    // critical section
    up(&mutex);
}

Producer‑Consumer Problem using semaphores:

#define N 100
typedef int semaphore;
semaphore mutex = 1;
semaphore empty = N;
semaphore full = 0;
void producer() {
    while (TRUE) {
        int item = produce_item();
        down(&empty);
        down(&mutex);
        insert_item(item);
        up(&mutex);
        up(&full);
    }
}
void consumer() {
    while (TRUE) {
        down(&full);
        down(&mutex);
        int item = remove_item();
        consume_item(item);
        up(&mutex);
        up(&empty);
    }
}

Classic Synchronization Problems such as the Dining Philosophers and Readers‑Writers are discussed with sample code and solutions to avoid deadlock.

Memory Management

Virtual Memory : Extends physical memory into a larger logical address space using paging; pages are mapped to frames on demand.

Paging System : Virtual address split into page number and offset; page tables map pages to frames.

Page Replacement Algorithms :

Optimal (OPT)

Least Recently Used (LRU)

Not Recently Used (NRU)

First‑In‑First‑Out (FIFO)

Second‑Chance

Clock

Device Management

Disk structure components (platter, track, sector, head, actuator, spindle) and disk scheduling algorithms (FCFS, SSTF, SCAN) are explained.

Deadlock

Necessary Conditions : Mutual exclusion, hold‑and‑wait, no preemption, circular wait.

Handling Methods include ignoring (ostrich), detection & recovery, prevention, and avoidance (banker’s algorithm).

Banker’s Algorithm for safety checking and resource allocation is illustrated with examples.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

deadlockprocess managementSchedulingSynchronizationOperating System
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.