munotes®

What an Operating System Is

Get access to whole semester resourcesSemester Pass

Chapter One

Syllabus topic Module 1, "Fundamentals of Operating systems - Definition of Operating System"

Pages 1 to 4 of 452

In one line

An operating system is the program that starts first, stays running, and stands between every other program and the machine.

In the words you can write in an examination: an operating system is the software that manages the computer's hardware, provides a platform on which application programs can run, and acts as an intermediary between the user and the hardware.

Both of those say the same thing. The first is what it means. The second is what to write.

Why there is one at all

Imagine a computer with no operating system on it. It has a processor, some memory, a disk, a keyboard and a screen. Now try to write a program on it that adds two numbers and prints the answer.

You cannot print the answer, because printing means putting characters into the right place in the screen's memory, and the position depends on which screen is fitted. You cannot read the two numbers, because reading means noticing that a key has been pressed, working out which key, and waiting while the person types. You cannot store the answer, because storing means asking the disk controller for a particular block, on a particular surface, and then waiting for the disk to turn. And if a second program were running, nothing would stop it from writing over your numbers, because memory is just memory.

Every one of those jobs has two things in common. They are the same for every program, and they depend on the hardware fitted rather than on the problem being solved. Writing them once and letting every program share them is the whole idea of an operating system. The program that adds two numbers gets to be a program about adding two numbers.

A useful test: if a job is needed by every program and nobody wants to write it twice, it belongs in the operating system.

The definition, in three parts

A definition of anything this large has to say what it does, what it hides, and who it serves. An operating system:

  1. Manages the hardware. It decides which program gets the processor, which gets memory,

which gets the disk next, and it hands each one out and takes it back.

  1. Provides a platform. It offers every program the same set of services, asked for in the

same way, whatever hardware is underneath. A program that reads a file does not know whether the file is on a hard disk, a solid state drive, a memory card or another computer.

  1. Acts as an intermediary. The person at the keyboard and the machine do not speak to each

other directly. Everything one says to the other passes through the operating system.

munotes.in1

What an Operating System Is

Two words that are easy to swap. A resource is anything a program needs and cannot have all of: the processor, memory, disk space, a printer. A service is something the operating system will do for a program if it asks: open a file, start another program, send a message. Resources are handed out. Services are performed. The next chapter is about the first and Chapter seven is about the second.

What it is, on a real machine

Four things are commonly called "the operating system" in ordinary speech, and only one of them is the operating system in the sense this paper means.

NameWhat it really is
The kernelthe operating system proper: the part that is always in memory and always in control
The shellan ordinary program that reads your commands and asks the kernel to carry them out
The utilitiesordinary programs, ls, cp, grep, shipped alongside
The distributionthe kernel, the shell, the utilities and thousands of other programs, packaged together and given a name such as Ubuntu

The lab machine can show that these are genuinely different things, because they have different version numbers and come from different projects.

$ uname -s
Linux
$ uname -r
6.8.0-117-generic
$ ls --version | head -1
ls (GNU coreutils) 9.4
$ bash --version | head -1
GNU bash, version 5.2.21(1)-release (aarch64-unknown-linux-gnu)
$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Ubuntu 24.04.5 LTS"

Four different version numbers for four different things. uname -r is the kernel, which is the operating system. ls belongs to GNU coreutils, a separate project, and is a program that the kernel runs like any other. bash is another such program. Ubuntu 24.04 is the distribution, which is the box all of it came in.

That the shell is an ordinary program is worth proving, because it is the single most common misunderstanding at this stage.

$ which bash
/usr/bin/bash
$ ls -l /usr/bin/bash
-rwxr-xr-x 1 root root 1543048 Sep  1 14:30 /usr/bin/bash

It is a file, of a size, with an owner and permissions, sitting in a directory. The kernel is not a file you can list like that while it is running: it was loaded before any file system existed to list it from.

Worked example: what happens when you type a command

Anita sits at the machine and types ls and presses Enter. Eight things happen, and every one of them is a topic later in this book.

  1. The keyboard raises an interrupt. The processor stops what it was doing and the kernel's

keyboard handler runs (Chapter three).

  1. The kernel puts the characters where the shell can read them, and wakes the shell up, because

the shell had asked to be woken when a line arrived (Chapter seventeen).

munotes.in2

What an Operating System Is

  1. The shell reads the line and works out that ls is not one of its own built in commands, so

it must be a program on the disk.

  1. The shell asks the kernel to make a copy of itself, with fork (Chapter nineteen).
  2. The copy asks the kernel to replace it with the program /usr/bin/ls, with exec (Chapter

twenty).

  1. The kernel finds the file on the disk, gives the new program some memory, loads it, and puts

it in the queue of programs waiting for the processor (Chapters fifteen and seventeen).

  1. ls asks the kernel to read the directory, and asks the kernel to write its output. It never

touches the disk or the screen itself (Chapter nine).

  1. ls finishes. The kernel tells the shell, which prints a new prompt (Chapter twenty one).

Notice what Anita did and what the operating system did. Anita named a program. The operating system found it, loaded it, ran it, read a directory for it, printed for it, and cleaned up after it. That is the intermediary in the definition.

Distinctions that carry marks

Operating systemApplication program
Startswhen the machine is switched onwhen somebody or something starts it
Runs inkernel mode, with full control of the hardwareuser mode, with no direct access to hardware
Purposeto run other programsto do a job for a person
Knows aboutthe hardware fittedthe problem being solved
ExampleLinux, Windows, Android, iOSa browser, a compiler, ls
KernelOperating system, loosely used
Meaningthe part always resident and always in controlthe kernel plus the programs shipped with it
Sizeone programthousands of programs
In this paperthis is what "operating system" meansthis is what a shop means by it

What it does not mean

It is not the part you can see. The desktop, the windows and the mouse pointer are programs running on the operating system, not the operating system. A machine with no screen attached still has one, fully working.

It is not a program you run. Every other program is started by something. The operating system is started by the hardware, which is a topic of its own: a small program in the machine's own memory loads a bootstrap program from the disk, which loads the kernel.

It is not only for big machines. A washing machine, a car's engine controller and a smart watch all run one. What changes is how much of it there is, not whether there is one.

It is not optional in a machine that runs more than one program. Two programs sharing one processor and one memory need somebody to decide who gets what, and that somebody must be a program with more power than either of them.

munotes.in3

What an Operating System Is

Quick revision

  • An operating system manages the hardware, provides a platform for programs, and acts as the

intermediary between the user and the machine.

  • It is the program that starts first and stays in control.
  • A resource is handed out (processor, memory, disk); a service is performed (open a

file, start a program).

  • The kernel is the operating system proper. The shell, the utilities and the

distribution are not.

  • The kernel runs in kernel mode; every other program runs in user mode.
  • On the lab machine the kernel is Linux 6.8, the shell is bash 5.2, ls is GNU coreutils 9.4,

and the distribution is Ubuntu 24.04. Four version numbers, four different things.

  • A job belongs in the operating system when every program needs it and it depends on the

hardware rather than on the problem.

Test yourself

  1. Define an operating system in one sentence. Software that manages the computer's hardware,

provides a platform on which application programs run, and acts as an intermediary between the user and the hardware.

  1. Why can a program not print to the screen by itself? Because printing means writing to the

particular hardware fitted, which differs from machine to machine, and because two programs writing at once would interfere. The operating system does it once, for everybody.

  1. Is the shell part of the operating system? No. It is an ordinary program, in a file, with

permissions and a version of its own. It asks the kernel to do things, exactly as any other program does.

  1. Give one example each of a resource and a service. Resource: the processor, or memory.

Service: opening a file, or starting another program.

  1. What is the difference between Linux and Ubuntu? Linux is the kernel, which is the

operating system. Ubuntu is a distribution: the kernel plus a shell, utilities and thousands of programs, packaged and named. 6. A microwave oven has a timer, a display and three buttons. Does it have an operating system? It may or may not, and the test is whether more than one thing has to be managed at once. If a single program can poll the buttons and drive the display in a loop, none is needed. As soon as there are several activities to be scheduled, something must schedule them, and that something is an operating system however small.

munotes.in4

The rest of this subject

These notes are cut from the University's printed syllabus. Open the syllabus itself, or the past papers, for the same subject.

Issue
Done!