System calls, processes and threads

Operating System Structure and System Calls

An operating system (OS) is the program that controls the hardware and gives every other program a cleaner, safer machine to run on. It plays two roles at once. As a resource manager it shares the CPU, memory, disks and devices among competing programs and keeps them from damaging each other.

10 min readQuick revision

Processes, PCB and Process States

A program is a passive file of instructions on disk. A process is a program in execution: the code together with a program counter, register values, a stack, a heap, open files and everything else the OS must remember to stop it and later continue it exactly where it left off.

8 min readFormulasQuick revision

Process Creation and fork()

In UNIX-like systems a new process is made in two separate steps. fork() creates a near-exact copy of the calling process; exec() then replaces the copy's program with a new one. A shell runs a command by forking, letting the child exec the command, and waiting for the child to finish.

9 min readFormulasQuick revision

Threads and Multithreading Models

A thread is a single stream of execution inside a process. A traditional process has one thread; a multithreaded process has several, all running the same program in the same address space.

8 min readFormulasQuick revision

CPU scheduling

CPU Scheduling: Criteria, FCFS, SJF, SRTF and Priority

When several processes are ready and there is one CPU, the short-term scheduler decides which runs next. The decision is made over and over, every few milliseconds, so the policy shapes how long jobs take, how responsive the system feels and whether some process can be postponed forever.

12 min readFormulasQuick revision

Round Robin and Multilevel Queue Scheduling

Interactive systems care about response time: a user who presses a key wants a reaction now, not after a long batch job finishes. Round robin (RR) achieves this by time slicing. Every ready process gets the CPU for at most one time quantum q, then goes to the back of the queue.

10 min readFormulasQuick revision

Concurrency, synchronization and IPC

Inter-Process Communication

Processes are isolated by design: each has its own address space, and one cannot read another's variables.

7 min readQuick revision

Semaphores, Mutexes and Monitors

Peterson's algorithm and TestAndSet loops solve mutual exclusion, but they are awkward to use and they busy-wait. Operating systems offer higher-level tools instead.

9 min readQuick revision

Classical Synchronization Problems

1) are the standard test bed for any new synchronization primitive. The bounded-buffer (producer-consumer) problem is about counting and waiting for space or data. The readers-writers problem is about letting many readers share while writers get exclusive access, and about who gets starved.

8 min readQuick revision

Deadlock

Memory management and paging

Paging, Page Tables and TLB

Paging removes external fragmentation by giving up contiguity. The logical address space of a process is cut into fixed-size pages, physical memory into frames of the same size, and any page can sit in any free frame.

11 min readFormulasQuick revision

Segmentation

A programmer does not think of a program as one linear array of bytes. It is a collection of logical units: the main code, a few library modules, global data, a heap and a stack, each of a different size and each able to grow on its own.

8 min readQuick revision

Virtual memory and page replacement

Virtual Memory and Demand Paging

Virtual memory separates the logical memory a program sees from the physical memory it occupies, so that a process need not be entirely in memory to run. Programs often contain error-handling code that rarely runs, arrays declared larger than they are used, and features few users touch.

11 min readFormulasQuick revision

Page Replacement Algorithms

When a page fault occurs and no frame is free, the operating system must evict a page already in memory: the victim. The choice matters.

12 min readFormulasQuick revision

File systems

File System Interface and Directory Structure

A file is a named collection of related information kept on secondary storage. To the user it is the smallest unit of storage: data reach the disk only inside files.

10 min readQuick revision

File Allocation Methods and Free-Space Management

A disk is an array of fixed-size blocks, and a file is a sequence of logical blocks 0, 1, 2 and so on. The allocation method decides which disk blocks hold a file and how the file system finds logical block i.

11 min readQuick revision

I/O and disk scheduling