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. 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. 2 A system has total time 200 ms and the CPU is busy for 170 ms. Calculate CPU utilization as a percent.
  3. 3 A virtual memory system uses a page size of 1024 bytes. For virtual address 3500, find the page number and offset.
  4. 4 Explain why an operating system uses system calls instead of allowing user programs to directly access hardware devices.