Lesson 2 · Operating Systems

Types of Operating Systems

Operating systems are designed around different jobs. A desktop values interactive response, a factory controller must meet timing limits, and a tiny embedded device may have very little memory.

Types of Operating Systems concept diagramA visual explanation of the layout and operations shown in this lesson.BatchTime sharingReal timeEmbeddedServerDesktopMobiledifferent workloads lead to different scheduling, timing, and resource choices
1

Batch and multiprogramming systems

A batch system collects jobs and runs them with little or no interaction. Early systems used batches to keep expensive hardware busy. Multiprogramming improves utilization by keeping several jobs in memory and running another when one waits for input or output.

Throughput is important in these environments: the system tries to complete a large amount of work. A user may care less about an immediate response to each individual step.

  • Jobs are prepared before execution
  • Scheduling decides job order
  • Another job can run while one waits for I/O
2

Time-sharing systems

A time-sharing system rapidly switches the CPU among active users and programs. Short time slices create the experience of simultaneous interaction even when one CPU core executes only one thread at a time.

Response time and fairness matter. The scheduler must stop one compute-heavy program from preventing terminals, editors, or other interactive work from responding.

  • Preemption ends a time slice
  • Ready queues hold runnable work
  • Round-robin is a simple time-sharing policy
Key reference

Terms, operations, and practical uses

Workload categories

  • BatchRuns prepared jobs with little interactive input and emphasizes throughput.
  • Time sharingPreempts work frequently to keep many interactive programs responsive.
  • Real timeEvaluates correctness partly by whether deadlines are met.

Specialized systems

  • EmbeddedRuns inside a device with a narrow purpose and constrained resources.
  • MobileCoordinates radios, sensors, touch input, application sandboxes, and battery limits.
  • DistributedCoordinates services across multiple computers while hiding some machine boundaries.

Evaluation criteria

  • Response timeDelay before a request begins receiving service.
  • ThroughputAmount of work completed per unit of time.
  • PredictabilityAbility to bound when important work will finish.
Code example

Share CPU time with round-robin scheduling

from collections import deque

def round_robin(bursts, quantum):
    ready = deque(bursts)
    order = []
    while ready:
        name, remaining = ready.popleft()
        order.append(name)
        remaining -= min(quantum, remaining)
        if remaining:
            ready.append((name, remaining))
    return order
print(*round_robin([('A', 4), ('B', 3), ('C', 2)], 2))
vector<char> roundRobin(queue<pair<char,int>> ready, int quantum) {
    vector<char> order;
    while (!ready.empty()) {
        auto [name, remaining] = ready.front();
        ready.pop();
        order.push_back(name);
        remaining -= min(quantum, remaining);
        if (remaining > 0) ready.push({name, remaining});
    }
    return order;
}
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

class Main {
    static class Job {
        char name;
        int remaining;
        Job(char name, int remaining) {
            this.name = name;
            this.remaining = remaining;
        }
    }

    static List<Character> roundRobin(Queue<Job> ready, int quantum) {
        List<Character> order = new ArrayList<>();
        while (!ready.isEmpty()) {
            Job job = ready.remove();
            order.add(job.name);
            job.remaining -= Math.min(quantum, job.remaining);
            if (job.remaining > 0) ready.add(job);
        }
        return order;
    }
}
InputA=4 ms, B=3 ms, C=2 ms; quantum=2 ms
OutputA B C A B
Example

Run the example step by step

Output
3

Real-time and embedded systems

A real-time system is judged by whether work finishes before a deadline. In a hard real-time system, missing a deadline is unacceptable; soft real-time systems tolerate an occasional delay with reduced quality.

Embedded systems are built into devices such as routers, vehicles, appliances, and sensors. Some use a real-time OS, while simpler devices may run one dedicated control loop.

  • Hard deadlines must always be met
  • Soft deadlines guide priority
  • Memory and power limits influence design
4

Distributed, network, mobile, and general-purpose systems

Network operating systems provide shared files, identities, printing, and administration across connected machines. Distributed systems coordinate separate computers so users can work with a combined service.

Desktop, server, and mobile operating systems combine time sharing, networking, protection, virtual memory, and device management. Mobile systems add strict power control, touch interfaces, radios, and application sandboxing.

  • One product can fit more than one category
  • Servers emphasize throughput and availability
  • Mobile systems manage battery and background work