Operating Systems


Introduction to OS

An Operating System (OS) acts as an intermediary between the user and computer hardware. It manages resources like CPU, memory, and storage. Examples: Windows, Linux, macOS.

Processes and Threads

A process is a program in execution. It has its own memory space. A thread is a lightweight unit within a process that shares memory.

#include 
void* thread_func(void* arg) {
    printf("Thread running\n");
    return NULL;
}
// Creating a thread in C

CPU Scheduling

CPU scheduling decides which process runs next. Common algorithms: First-Come-First-Served (FCFS), Round-Robin, Shortest Job First.

Memory Management

OS allocates memory to processes. Techniques include paging (dividing memory into fixed-size pages) and segmentation.

Deadlocks

A deadlock occurs when processes wait for each other forever. Conditions: mutual exclusion, hold and wait, no preemption, circular wait.

File Systems

File systems organize data on disk. Common types: FAT, NTFS, ext4. They handle directories, permissions, and access.

Virtual Memory

Virtual memory allows programs to use more memory than physically available by using disk space as swap.

Table of Contents