Introduction and OS
Introduction and OS
Chapter 1: Introduction
Operating System Concepts – 7th Edition, Jan 12, 2005 1.2 Silberschatz, Galvin and Gagne ©2005
Objectives
Operating System Concepts – 7th Edition, Jan 12, 2005 1.3 Silberschatz, Galvin and Gagne ©2005
What is an Operating System?
Operating System Concepts – 7th Edition, Jan 12, 2005 1.4 Silberschatz, Galvin and Gagne ©2005
Computer System Structure
Operating System Concepts – 7th Edition, Jan 12, 2005 1.5 Silberschatz, Galvin and Gagne ©2005
Four Components of a Computer System
Operating System Concepts – 7th Edition, Jan 12, 2005 1.6 Silberschatz, Galvin and Gagne ©2005
Operating System Definition
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair
resource use
OS is a control program
Controls execution of programs to prevent errors and improper
use of the computer
Operating System Concepts – 7th Edition, Jan 12, 2005 1.7 Silberschatz, Galvin and Gagne ©2005
Operating System Definition (Cont.)
Operating System Concepts – 7th Edition, Jan 12, 2005 1.8 Silberschatz, Galvin and Gagne ©2005
Computer Startup
Operating System Concepts – 7th Edition, Jan 12, 2005 1.9 Silberschatz, Galvin and Gagne ©2005
Computer System Organization
Computer-system operation
One or more CPUs, device controllers connect through
common bus providing access to shared memory
Concurrent execution of CPUs and devices competing for
memory cycles
Operating System Concepts – 7th Edition, Jan 12, 2005 1.10 Silberschatz, Galvin and Gagne ©2005
Computer-System Operation
I/O devices and the CPU can execute concurrently (see the figure
in slide 14).
Each device controller is in charge of a particular device type.
Each device controller has a local buffer.
CPU moves data from/to main memory to/from local buffers
I/O is from the device to local buffer of controller.
Device controller informs CPU that it has finished its operation by
causing an interrupt.
Any event occurrence is usually signaled by an interrupt from the
hardware or the software.
Hardware may trigger an interrupt at any time by sending a
signal to the CPU throw the system bus.
Software may trigger interrupt by executing a special operation
called system call (monitor call).
Operating System Concepts – 7th Edition, Jan 12, 2005 1.11 Silberschatz, Galvin and Gagne ©2005
Common Functions of Interrupts
Interrupt transfers control to the interrupt service routine generally, through
the interrupt vector, which contains the addresses of all the service routines,
those addresses for all services are loaded by the OS at the OS initialization
phase.
We have the interrupt vector (imagine it as an array) which contains the
addresses of all the service routines, when the CPU is interrupted it
stops what it is doing and immediately transfer execution to a fixed
location, this location is the starting address where the service routine for
the interrupt is stored.
Interrupt architecture must save the address of the interrupted instruction.
When the CPU is interrupted it stop what is doing and start to execute
the new interrupt, when it finishes the execution for the current interrupt
it should return to the previous interrupted computation by retrieving its
address (so this address should be saved).
Incoming interrupts are disabled while another interrupt is being processed
to prevent a lost interrupt.
A trap (exception) is a software-generated interrupt caused either by an error
(ex: division by zero or invalid memory access) or a user program request.
We need a trap software to issue interrupts to the CPU when needed (ex:
division by zero).
An operating system is interrupt driven.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.12 Silberschatz, Galvin and Gagne ©2005
Interrupt Handling
Operating System Concepts – 7th Edition, Jan 12, 2005 1.13 Silberschatz, Galvin and Gagne ©2005
Interrupt Timeline
Operating System Concepts – 7th Edition, Jan 12, 2005 1.14 Silberschatz, Galvin and Gagne ©2005
Each device has a controller which maintains local buffer and special purpose
registers.
The device controller is responsible for moving data between the peripheral
devices that it controls and its local buffer storage.
OS have a device driver for each device controller to understand the device
controller and presents a uniform interface to the device to the rest of the
operating system.
To start an I\O operation:
the driver loads the appropriate registers within the device controller (ex:
loads instructions that mean: “read a specific data from hard disk”).
The controller examines the contents for these registers to determine what
action to take (ex: the action is: transfer a data).
Then the controller starts the transfer of data from the device to its local
buffer. (at this stage we have two options to continue this transfer of data,
we will see them in the next slide)
Operating System Concepts – 7th Edition, Jan 12, 2005 1.15 Silberschatz, Galvin and Gagne ©2005
I/O Structure
1) After I/O starts, control returns to user program only upon I/O completion. (suitable for small
amounts of data).
Wait instruction idles the CPU until the next interrupt
Wait loop (contention for memory access). the CPU waits until the data transfer
completed and the device controller inform the device driver that it is finished form
transferring data to the device buffer.
At most one I/O request is outstanding at a time, no simultaneous I/O processing.
2) After I/O starts, control returns to user program without waiting for I/O completion. (suitable
for large amounts of data (bulk data)).
System call – request to the operating system to allow user to wait for I/O completion
and the CPU execute other tasks until it is interrupted again by the device driver which
have been tolled by the device controller that it have finished its I\O job.
In this case the device controller use direct memory access (DMA) to perform its job
while the CPU execute other job.
Device-status table contains entry for each I/O device indicating its type, address, and
state.
Operating system indexes into I/O device table to determine device status and to
modify table entry to include interrupt.
Operating System Concepts – 7th Edition, Jan 12, 2005 1.16 Silberschatz, Galvin and Gagne ©2005
Device-Status Table
Operating System Concepts – 7th Edition, Jan 12, 2005 1.17 Silberschatz, Galvin and Gagne ©2005
Direct Memory Access (DMA) Structure
Operating System Concepts – 7th Edition, Jan 12, 2005 1.18 Silberschatz, Galvin and Gagne ©2005
Storage Structure
Main memory – only large storage media that the CPU can access
directly.
Secondary storage – extension of main memory that provides large
nonvolatile storage capacity.
Magnetic disks – rigid metal or glass platters covered with
magnetic recording material
Disk surface is logically divided into tracks, which are
subdivided into sectors.
The disk controller determines the logical interaction
between the device and the computer.
Operating System Concepts – 7th Edition, Jan 12, 2005 1.19 Silberschatz, Galvin and Gagne ©2005
Storage Hierarchy
Operating System Concepts – 7th Edition, Jan 12, 2005 1.20 Silberschatz, Galvin and Gagne ©2005
Storage-Device Hierarchy
Operating System Concepts – 7th Edition, Jan 12, 2005 1.21 Silberschatz, Galvin and Gagne ©2005
Caching
Operating System Concepts – 7th Edition, Jan 12, 2005 1.22 Silberschatz, Galvin and Gagne ©2005
Performance of Various Levels of Storage
Operating System Concepts – 7th Edition, Jan 12, 2005 1.23 Silberschatz, Galvin and Gagne ©2005
Migration of Integer A from Disk to Register
Multitasking environments must be careful to use most recent value (
because we could have more than one copy for a certain data, ex: variable x
can be changed at cache while it is still not changed at hard disk), no matter
where it is stored in the storage hierarchy
Operating System Concepts – 7th Edition, Jan 12, 2005 1.25 Silberschatz, Galvin and Gagne ©2005
Operating System Structure
Operating System Concepts – 7th Edition, Jan 12, 2005 1.26 Silberschatz, Galvin and Gagne ©2005
Memory Layout for Multiprogrammed System
Operating System Concepts – 7th Edition, Jan 12, 2005 1.27 Silberschatz, Galvin and Gagne ©2005
Operating-System Operations
Modern OS systems are interrupt driven by hardware.
Software error or request creates exception or trap (like interrupt but generated by
SW error or request. without this (trap generated SW) the OS will not be able to
serve more than one process (ex: enter an infinite loop without a tool to stop it (i.e.
trap generated SW))).
Division by zero
request for operating system service
Other process problems include infinite loop, processes modifying each other or the
operating system
Dual-mode operation allows OS to protect itself and other system components
User mode and kernel mode (also called supervisor mode, privileged mode,
and system mode) are used to distinguish between the OS code and the user
code.
Mode bit ( 0 for kernel, and 1 for user) provided by hardware
Provides ability to distinguish when system is running user code or kernel
code
Some instructions designated as privileged, only executable in kernel mode
System call, trap, and interrupt changes mode to kernel.
System call is issued when a user application requests a service from the OS.
Operating System Concepts – 7th Edition, Jan 12, 2005 1.28 Silberschatz, Galvin and Gagne ©2005
Transition from User to Kernel Mode
Operating System Concepts – 7th Edition, Jan 12, 2005 1.29 Silberschatz, Galvin and Gagne ©2005
Process Management Activities
Operating System Concepts – 7th Edition, Jan 12, 2005 1.30 Silberschatz, Galvin and Gagne ©2005
Protection and Security
Operating System Concepts – 7th Edition, Jan 12, 2005 1.31 Silberschatz, Galvin and Gagne ©2005
Protection and Security
A system can have adequate protection but still be prone to failure and allow
inappropriate access (stolen authentication information), so we need security.
Security – defense of the system against internal and external attacks
Huge range, including denial-of-service, worms, viruses, identity theft, theft
of service
Systems generally first distinguish among users, to determine who can do
what, this can be done by:
User identities (user IDs, security IDs) include name and associated
number, one per user
User ID then associated with all files, processes of that user to determine
access control
Group identifier (group ID) allows set of users to be defined and controls
managed, then also associated with each process, file
Privilege escalation (raising) allows user to change to effective ID with
more rights
Operating System Concepts – 7th Edition, Jan 12, 2005 1.32 Silberschatz, Galvin and Gagne ©2005
End of Chapter 1