DSA, Database System & Operating System — Operating System and Process Management, NEC licence examination syllabus (Nepal Engineering Council).
Types of Operating Systems
Batch, time-sharing, real-time, distributed, embedded — classified by what they are optimised to guarantee.
🌍 Where this lives: the classification matters when you pick a platform. Run a motor controller on standard Linux and it mostly works — until a garbage-collection pause or a page fault makes it miss a deadline by 50 ms and the machine damages something. That is why PREEMPT_RT patches and dedicated RTOSes (FreeRTOS, QNX, VxWorks) exist: not because they are faster on average, but because they bound the worst case. Every safety-critical system you rely on — anti-lock brakes, pacemakers, aircraft flight control — runs a hard real-time OS for exactly that reason. Search "hard vs soft real time scheduling guarantee".
The classification
1. BATCH OPERATING SYSTEM
jobs collected and executed without user interaction
· optimises THROUGHPUT
· no interactivity; turnaround measured in hours
· examples: IBM OS/360, modern equivalents are job
schedulers (Slurm, HTCondor, CI runners)
2. TIME-SHARING (multitasking)
CPU switched rapidly between users/processes
· optimises RESPONSE TIME
· needs a timer interrupt and preemptive scheduling
· examples: UNIX, Linux, macOS, Windows
3. REAL-TIME OPERATING SYSTEM (RTOS)
correctness depends on meeting DEADLINES
· HARD real-time: a missed deadline is a system FAILURE
flight control, pacemaker, airbag, industrial robot
· SOFT real-time: a missed deadline degrades quality
video playback, VoIP, live audio
· optimises PREDICTABILITY, not average speed
· examples: VxWorks, QNX, FreeRTOS, RTLinux
4. DISTRIBUTED OPERATING SYSTEM
many machines presented as one system
· resource sharing, load balancing, fault tolerance
· the hard problems are partial failure and no global clock
· examples: Amoeba, Plan 9; in practice today this role is
filled by cluster managers (Kubernetes) rather than a
single OS
5. NETWORK OPERATING SYSTEM
machines stay independent but share resources over a
network
· each machine has its own OS and its own users
· contrast with distributed: here the user KNOWS there are
several machines
· examples: file/print servers, NFS, Windows Server
6. EMBEDDED OPERATING SYSTEM
runs on dedicated hardware with tight resource limits
· small footprint, often no MMU, sometimes no processes
· may be a "superloop" with no OS at all
· examples: FreeRTOS, Zephyr, Contiki, embedded Linux
7. MOBILE OPERATING SYSTEM
time sharing plus energy and lifecycle management
· aggressive process suspension to save battery
· permission model per application
· examples: Android (Linux kernel), iOS (Darwin/XNU)
8. MULTIPROCESSOR / PARALLEL
several CPUs sharing memory
· SYMMETRIC (SMP): all CPUs equal, one OS copy — what every
modern desktop and phone uses
· ASYMMETRIC: one master CPU assigns work to slaves
· this machine: 10 cores under an SMP kernel
Hard versus soft real time — the distinction that matters
The difference is NOT speed. It is whether the worst case is
BOUNDED and GUARANTEED.
general-purpose OS average latency 50 µs, worst case
unbounded (could be 100 ms under load)
hard real-time OS average latency 80 µs, worst case
GUARANTEED under 200 µs
The RTOS is SLOWER on average and correct in the worst case.
For an airbag, only the second property matters.
WHAT A GENERAL-PURPOSE OS DOES THAT BREAKS DEADLINES:
· page faults — a memory access may take a disk read
· unbounded priority inversion — a low-priority task holding
a lock the high-priority task needs
· non-preemptible kernel sections
· interrupt storms
· garbage collection or JIT compilation pauses
· disk and network buffering
WHAT AN RTOS DOES DIFFERENTLY:
· PREEMPTIBLE KERNEL — even kernel code can be interrupted
· PRIORITY INHERITANCE — a lock holder temporarily inherits
the priority of the highest-priority waiter, bounding
inversion
· deterministic memory allocation, often pre-allocated pools
with no dynamic allocation at run time
· locked (non-pageable) memory, so no page faults
· bounded interrupt latency, measured and documented
THE MARS PATHFINDER BUG (1997) is the canonical case study. A
high-priority bus-management task blocked on a mutex held by a
low-priority meteorological task, which was itself preempted by
a medium-priority communications task. The high-priority task
missed its deadline, a watchdog fired, and the lander reset —
repeatedly, from Mars. The fix, uploaded remotely, was to
enable PRIORITY INHERITANCE on that mutex.
That is unbounded priority inversion, and it is the reason
priority inheritance is a standard RTOS feature rather than
an optional nicety.
Multiprocessor organisation, measured
smp.sh
# Measured on this machine (Darwin 25.5.0, arm64)
uname -srm
# Darwin 25.5.0 arm64
sysctl -n hw.ncpu hw.memsize hw.pagesize
# 10 <- 10 CPU cores, all equal (SMP)
# 17179869184 <- 16 GiB of RAM
# 16384 <- 16 KB pages (NOT the 4 KB most
# textbooks assume — Apple silicon uses
# 16 KB, which changes every page-table
# calculation)
ps ax | wc -l
# 599 <- 599 processes on an idle desktop.
# Multiprogramming is not a historical
# curiosity; it is the normal state.
sysctl -n kern.clockrate
# { hz = 100, tick = 10000, ... }
# hz = 100 → the timer interrupt fires 100 times a second,
# i.e. every 10 ms. That interrupt is what makes preemption
# possible: without it a runaway loop would never yield.# SMP vs ASMP, in one line each:
# SMP — 10 identical cores, one kernel, any process on any
# core. What this machine does.
# ASMP — one master core runs the OS and assigns work to the
# others. Simpler, but the master is a bottleneck and
# a single point of failure.
#
# Modern Apple silicon is actually HETEROGENEOUS SMP: some
# cores are performance cores and some are efficiency cores.
# The scheduler must decide not only WHEN to run a thread but
# on WHICH KIND of core — a genuinely new problem that
# classical SMP theory does not cover.
Three measured facts worth carrying:
10 CORES — so "concurrency" and "parallelism" are different
things here. Ten threads can run genuinely simultaneously;
the eleventh must wait. Concurrency is a structuring
concept; parallelism is a hardware capability.
16 KB PAGES — most textbooks assume 4 KB. Every page-table
and fragmentation calculation in the memory-management topic
changes by a factor of four on this machine. Always check
the page size rather than assuming it:
getconf PAGESIZE (portable)
sysctl hw.pagesize (BSD/macOS)
599 PROCESSES on an idle machine, with 10 cores. So at any
instant at most 10 are running and ~589 are blocked or
ready. That ratio is why scheduling matters and why the
1 − pⁿ utilisation model from the previous topic applies to
every machine you will ever use.
The 16 KB page size is a good reminder to verify environment assumptions rather than inherit them from a textbook. A page-table exercise that "works" with 4 KB pages gives a wrong answer on this hardware — and the same applies to word size, cache-line size and endianness. Measure, do not assume.
🌍 Go further: the sharpest current example of the classification breaking down is the heterogeneous scheduler problem. Apple's P/E cores and ARM's big.LITTLE mean the scheduler must pick a core type, trading throughput against battery, and getting it wrong shows up as a phone that feels slow or a laptop that runs hot. Linux's answer is Energy Aware Scheduling; Apple's is a private QoS-class system where you tag work as user-interactive or background and the kernel decides. Search "Linux energy aware scheduling big.LITTLE" and "macOS quality of service classes".
💡 Exam angle: name each type with what it optimises — batch/throughput, time-sharing/response time, real-time/deadlines, embedded/footprint. The most-asked distinction is hard versus soft real time: state clearly that the difference is a guaranteed bounded worst case, not average speed. Know SMP versus ASMP, and the distributed versus network OS difference (whether the user is aware of multiple machines). Priority inversion with the Pathfinder example and priority inheritance as the fix is a strong extra mark.