chapter_8
chapter_8
Think of it like a manager or middleman who makes sure everything runs smoothly between the software and
hardware.
# Two Main Goals of an Operating System:
1. Convenience
This means the OS is designed to make the computer easier for people to use.
● Instead of having to know how to control the hardware directly (which would be hard!), users can interact with
the computer using a simpler interface, like clicking icons or typing commands.
● It takes care of complex tasks for you — like saving files, opening apps, printing documents, or connecting to
the internet.
● Think of it like a translator: it helps people “talk” to the computer in a way that’s easy for them to understand.
Example:
When you want to open a photo, you just double-click it. The OS figures out which program to use, how to load the
image, and how to display it — all in the background.
2. Efficiency
This means the OS makes sure the computer's resources (like the CPU, memory, and storage) are used in
the best way possible.
● It manages the memory so that programs don’t interfere with each other.
● It controls how files are stored and retrieved from storage devices like hard drives or SSDs.
● It allows many users or programs to work at the same time without crashing the system.
Example:
If you're listening to music, browsing the web, and downloading a file at the same time, the OS makes sure
all those tasks get enough attention from the CPU without slowing each other down.
# The Operating System as a Bridge Between User and
Computer (the operating system as a user/computer interface)
1. Layered View of a Computer System
Imagine a computer as a layered system, like a cake. Each layer plays a role:
● Below that are applications like web browsers, games, or word processors.
● Then, you have programming languages that are used to create those applications.
● At the bottom, you have the hardware (CPU, memory, hard disk, etc.).
But you (the user) don’t directly deal with the hardware. You usually deal with applications. The Operating
System (OS) sits in the middle and connects everything together.
# Why Do We Need an OS?
If programmers had to write every program to directly control hardware (like telling the CPU exactly what to
do), it would be extremely difficult and time-consuming.
● Provide helpful tools and services so developers can build programs more easily.
● These tools are not always part of the OS, but the OS helps run and manage them.
2. Program Execution
● To run a program, many steps are needed: loading it into memory, starting it, managing files it uses,
etc.
● You just click "Run" or double-click an icon — the OS does the rest.
● Instead of making the programmer write all those instructions, the OS provides simple commands
like "read" and "write".
● This makes it easier to use devices without knowing how they work internally.
4. Controlled Access to Files
● Files are stored on devices like hard drives or USBs. These have different formats and ways of
working.
● The OS hides the complexity and gives you a simple way to open, save, or edit files.
● It also protects files, especially when many people use the same computer, making sure only
authorized users can access them.
● On shared computers (like in offices or schools), the OS controls who can log in, what they can
access, and what actions they can perform.
● The OS constantly checks for errors and tries to handle them smoothly — by restarting
programs, warning the user, or logging the problem.
○ Improve performance.
○ Plan upgrades.
○ In multi-user systems, it’s also used for billing (e.g., charging users based on how much
time or storage they used).
#Three Important Interfaces
The OS connects different layers of the computer system through interfaces. Here are three main ones:
● The OS has access to more powerful instructions (called system ISA) to control hardware.
● It includes system calls (requests from programs to the OS), and defines how programs interact with hardware.
● Helps programs run on different systems without rewriting the code, as long as they support the same ABI.
● This is a set of commands and tools that programmers use to write applications.
● APIs simplify tasks like opening a file, connecting to the internet, or displaying graphics.
● APIs help make software easier to write and more portable to other systems.
# The operating system as resource manager
What Does "Resource Manager" Mean?
A computer is made up of different parts, called resources, which do specific jobs:
● Memory (RAM) stores data and programs while they are being used.
● Storage devices (like hard drives) hold files and programs long-term.
● I/O devices (like keyboards, printers, and screens) allow input and output.
● Programs (software) do tasks the user wants, like editing documents or browsing the web.
The Operating System (OS) is in charge of managing all these resources, making sure they are
used efficiently, fairly, and safely.
# Does the OS Control the Computer Completely?
You might think the OS is always in control — like a boss giving orders. That’s partially true, but there’s something interesting about
how it works:
1. The OS is just software – It’s a program like any other. It runs on the same CPU as all other programs.
2. The OS gives up control – The OS runs for a short time to manage the system, then gives control to other programs. It
must trust the CPU to return control back to the OS when needed.
2. It gives control of the CPU to the music player so it can play the song.
4. If something important happens (like a new song is selected or you click a button), the CPU returns control to the OS.
So, the OS isn’t always active, but it orchestrates everything behind the scenes, making sure resources are shared fairly and
efficiently.
# Main Resources Managed by the OS (as shown in Figure 8.2)
1. Memory (Main Memory / RAM)
● A part of RAM is always used by the OS, especially the kernel (the core part of the OS that handles
basic functions).
● The rest of RAM is used by user programs (apps you run) and the data they use.
● The OS controls how memory is shared so that programs don’t interfere with each other.
2. Processor (CPU)
● If you have multiple programs open, the OS switches between them quickly so it feels like they’re
running at the same time.
● In systems with multiple CPUs, the OS must decide how to divide the work across all processors.
3. I/O Devices (Input/Output)
● Each device has its own way of working (its own "language").
● It lets programs use them without needing to know the hardware details.
● It makes sure files are saved properly and that programs don’t accidentally overwrite each other’s data.
5. Programs (Processes)
● It ensures they don’t crash into each other or take over the system.
# What Are Operating System "Types"?
Different operating systems (OS) are designed to work in different ways, depending on:
2. How many programs the system can handle at the same time.
This dimension is about how the user interacts with the computer.
● You give the computer commands or input, and it responds right away.
● You can use multiple applications, type, click, and get instant feedback.
Example: When you open a browser and type a search, the system responds quickly — that’s an interactive system.
● Users do not interact with the computer while their program runs.
● Programs (called jobs) from many users are collected (batched) and sent to the computer all at once.
● The OS runs each program one after another without user interaction.
● Once finished, the system gives users the output (like a printout).
Example: In the 1960s, engineers wrote programs on punch cards, gave them to an operator, and got printed results later.
2. Uniprogramming vs. Multiprogramming
This dimension is about how many programs the system can run at once.
● All of the computer's resources (CPU, memory) go to just that one program.
● If that program needs to wait (e.g., for input), the computer stays idle.
● Not efficient, especially when the CPU could be doing something else.
Example: Imagine a teacher helping only one student at a time, even if the student is reading a book and the teacher is just waiting.
● While one program is waiting (e.g., for input), another one can run.
Example: A teacher helps multiple students at once — while one is reading, she helps another one who has a question.
# What Were Early Computer Systems Like? (Late 1940s – Mid-1950s)
In the early days of computers, there was no operating system (OS). People used the computer by interacting directly with the
hardware. This was a time before Windows, Linux, or even DOS — computers were completely manual.
● Toggle switches – for entering data manually (like typing in binary numbers)
● Lights – that showed what the computer was doing (like which instruction or error it was on)
● Input devices – such as card readers (used to read punch cards with instructions)
1. Write the program in machine code (a series of binary instructions the CPU understands).
4. If there was an error, lights on the console would show the problem.
5. The programmer had to manually check memory and registers to figure out what went wrong.
1. 🕒 Scheduling Problems
● Computers were shared by many users, but only one person could use it at a time.
● People signed up for time slots on a sheet of paper, often in blocks of 30 minutes or 1 hour.
○ If a person ran into errors and needed more time, they had to stop before solving the problem.
This was inefficient and led to lots of idle (unused) computer time.
2. 🧰 Setup Time
○ Load the compiler into memory (a compiler turns source code into machine code).
○ Load and link the object code with other needed functions (like math functions).
● If there was an error at any step, you usually had to start over from the beginning.
So, a lot of time was wasted just getting things ready — not even counting the time it took for the program to run!
# This Was Called Serial Processing
● Only one person used the computer at a time.
So, to save time and use the computer more efficiently, a new system was created: the simple batch system.
🔄 What Changed with Batch Systems?
Instead of users running their programs directly on the computer:
● Users gave their jobs to a computer operator (on punched cards or magnetic tape)
● This batch was loaded into the computer all at once using an input device
🖥 What Is a Monitor?
A monitor is an early form of an operating system. It was just a program that:
The part of the monitor that stayed in memory all the time was called the resident monitor.
🧩 How Did a Batch System Work?
From the Monitor’s point of view:
1. The monitor reads one job from the batch.
This made sure the computer never sat idle waiting for the next user.
4. When the user job finishes or crashes, the processor switches back to running the monitor.
This switching between user programs and the monitor continues for every job in the batch.
⌨ What Is JCL (Job Control Language)?
When a job was submitted, it came with some special commands to help the monitor know what to do.
These commands were called Job Control Language (JCL). They started with a $ symbol, like:
FORTRAN instructions...
Data...
1. 🛡 Memory Protection
● Prevents the user program from changing or damaging the monitor’s memory area.
2. ⏱ Timer
● Prevents a user job from running too long.
● If the job takes too much time, a timer interrupt stops it, and control returns to the monitor.
3. 🔐 Privileged Instructions
● Some commands (like for I/O or system control) are only allowed for the monitor.
4. ⚡ Interrupts
● Allows the system to switch quickly between running the monitor and user programs.
● Helps the monitor regain control when needed (e.g., if a job finishes or crashes).
🧮 Was There a Downside?
Yes — the monitor: