Operating systems manage the hardware and software resources that every program depends on. This cheat sheet summarizes how an OS starts programs, shares the CPU, protects memory, stores files, and communicates with devices. Students need these ideas to understand why computers can run many programs safely at the same time.
It also helps connect programming concepts to the real machine underneath.
Key Facts
- Turnaround time = completion time - arrival time, and it measures the total time a process spends in the system.
- Waiting time = turnaround time - total CPU burst time, and it measures time spent ready but not running.
- Response time = first start time - arrival time, and it is important for interactive systems.
- CPU utilization = busy CPU time / total time x 100%, and higher utilization means less idle processor time.
- Throughput = number of completed processes / total time, and it measures how much work the system finishes per unit time.
- Effective access time = hit rate x fast access time + miss rate x slow access time, and it estimates average memory access cost.
- Physical address = frame base address + offset, and virtual memory uses this rule after translating a page number to a frame.
- A safe critical section must provide mutual exclusion, progress, and bounded waiting so shared data is not corrupted.
Vocabulary
- Kernel
- The core part of an operating system that controls hardware, memory, processes, files, and system calls.
- System call
- A controlled request from a user program to the operating system for a protected service such as file access or process creation.
- Process
- A running program with its own memory space, resources, and execution state.
- Thread
- A smaller unit of execution inside a process that shares the process memory but has its own program counter and stack.
- Virtual memory
- A memory system that gives each process the illusion of a large private address space by mapping virtual addresses to physical memory.
- Race condition
- An error that occurs when multiple threads or processes access shared data and the final result depends on timing.
Common Mistakes to Avoid
- Confusing a process with a thread is wrong because processes have separate memory spaces, while threads inside the same process share memory.
- Ignoring arrival times in scheduling problems is wrong because a process cannot run before it has entered the ready queue.
- Using waiting time = completion time - arrival time is wrong because that formula gives turnaround time, not waiting time.
- Assuming virtual memory means unlimited RAM is wrong because pages still need physical frames or slower disk storage when memory is full.
- Forgetting kernel mode and user mode protection is wrong because user programs must use system calls instead of directly controlling protected hardware.
Practice Questions
- 1 Three processes use FCFS scheduling: P1 arrives at 0 with burst 6, P2 arrives at 2 with burst 4, and P3 arrives at 4 with burst 2. Find each turnaround time and the average waiting time.
- 2 A system has total time 200 ms and the CPU is busy for 170 ms. Calculate CPU utilization as a percent.
- 3 A virtual memory system uses a page size of 1024 bytes. For virtual address 3500, find the page number and offset.
- 4 Explain why an operating system uses system calls instead of allowing user programs to directly access hardware devices.
Understanding Operating Systems Concepts
A program cannot directly take control of a disk, network card, or memory belonging to another program. It asks the operating system through a system call. Opening a file, creating a process, requesting more memory, and sending data over a network all use this controlled route.
The processor switches from user mode to kernel mode while the operating system handles the request. Kernel mode has powerful permissions, so mistakes there can affect the whole computer. This separation is one reason a faulty app usually crashes by itself instead of destroying the entire system.
A process is a running instance of a program with its own memory, saved processor state, and operating system resources. A web browser may create many processes to keep tabs or services apart. Threads are smaller paths of execution inside one process.
They can share data quickly, but shared data creates risks. If two threads update the same bank balance or game score at nearly the same moment, one update can overwrite the other.
A critical section is the part of code that touches shared data. Locks and similar tools control entry so the result stays correct.
CPU scheduling is a tradeoff, not a search for one perfect rule. Short jobs often finish quickly under short-job-first policies, while interactive programs need fast first responses to feel usable. A long calculation still needs regular CPU time, or it may wait too long.
This problem is called starvation. Priority systems can reduce delays for important work, yet priorities must be adjusted carefully because low-priority tasks still matter.
Context switching lets the CPU move between processes, but each switch takes time to save one state and load another. Too many switches can reduce useful work.
Virtual memory gives each process the impression of owning one large, continuous address space. In reality, memory is divided into fixed-size pages and frames. Only recently needed pages may stay in RAM.
Less active pages can remain on storage until needed. A page fault occurs when a required page is not in RAM. The operating system must fetch it, which is far slower than normal memory access.
This explains why a computer can become unresponsive when many large apps compete for limited RAM. File systems face similar tradeoffs.
They organize names, folders, permissions, and storage blocks, while buffering and caching avoid repeated slow device access. Backups matter because permissions prevent some accidents, not every hardware failure or user mistake.