Operating Systems:
Introduction
Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013
Introduction
What Operating Systems Do?
Computer-System Organisation
Computer-System Architecture
Operating-System Structure
Operating-System Operations
Computing Environments
Operating System Services
System Calls and its types
Operating System Concepts – 9th Edition 1.2 Silberschatz, Galvin and Gagne ©2013
Objectives
To describe the basic organisation of computer systems
To provide a grand tour of the major components of operating systems
To give an overview of the many types of computing environments
To explore several open-source operating systems
To describe the services an operating system provides to users,
processes, and other systems
Operating System Concepts – 9th Edition 1.3 Silberschatz, Galvin and Gagne ©2013
What is an Operating System?
A program that acts as an intermediary between a user of a
computer and the computer hardware
Operating system goals:
Execute user programs and make solving user problems
easier
Make the computer system convenient to use
Use the computer hardware in an efficient manner
Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne ©2013
Four Components of a Computer System
Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne ©2013
What Do Operating Systems Do
Depends on the point of view
Users want convenience, ease of use and good performance
Don’t care about resource utilization
But shared computer such as mainframe or minicomputer must
keep all users happy
Users of dedicate systems such as workstations have dedicated
resources but frequently use shared resources from servers
Handheld computers are resource poor, optimized for usability
and battery life
Some computers have little or no user interface, such as
embedded computers in devices and automobiles
Operating System Concepts – 9th Edition 1.6 Silberschatz, Galvin and Gagne ©2013
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 – 9th Edition 1.7 Silberschatz, Galvin and Gagne ©2013
Operating System Definition (Cont.)
“Everything a vendor ships when you order an operating system” is a
good approximation
But varies wildly
“The one program running at all times on the computer” is the kernel.
Everything else is either
a system program (ships with the operating system) , or
an application program.
Operating System Concepts – 9th Edition 1.8 Silberschatz, Galvin and Gagne ©2013
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 – 9th Edition 1.9 Silberschatz, Galvin and Gagne ©2013
Computer-System Architecture
Most systems use a single general-purpose processor
Most systems have special-purpose processors as well
Multiprocessors systems growing in use and importance
Also known as parallel systems, tightly-coupled systems
Advantages include:
1. Increased throughput
2. Economy of scale
3. Increased reliability – graceful degradation or fault tolerance
Two types:
1. Asymmetric Multiprocessing – each processor is assigned a
specie task.
2. Symmetric Multiprocessing – each processor performs all tasks
Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne ©2013
A Dual-Core Design
Multi-chip and multicore
Systems containing all chips
Chassis containing multiple separate systems
Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne ©2013
Symmetric Multiprocessing Architecture
Operating System Concepts – 9th Edition 1.12 Silberschatz, Galvin and Gagne ©2013
Operating System Structure
Multiprogramming (Batch system) needed for efficiency
Single user cannot keep CPU and I/O devices busy at all times
Multiprogramming organizes jobs (code and data) so CPU always has one
to execute
A subset of total jobs in system is kept in memory
One job selected and run via job scheduling
When it has to wait (for I/O for example), OS switches to another job
Timesharing (multitasking) is logical extension in which CPU switches jobs
so frequently that users can interact with each job while it is running, creating
interactive computing
Response time should be < 1 second
Each user has at least one program executing in memory process
If several jobs ready to run at the same time CPU scheduling
If processes don’t fit in memory, swapping moves them in and out to run
Virtual memory allows execution of processes not completely in memory
Operating System Concepts – 9th Edition 1.13 Silberschatz, Galvin and Gagne ©2013
Memory Layout for Multiprogrammed System
Operating System Concepts – 9th Edition 1.14 Silberschatz, Galvin and Gagne ©2013
How a Modern Computer Works
A von Neumann architecture
Operating System Concepts – 9th Edition 1.15 Silberschatz, Galvin and Gagne ©2013
Operating-System Operations
Interrupt driven (hardware and software)
Hardware interrupt by one of the devices
Software interrupt (exception or trap):
Software error (e.g., division by zero)
Request for operating system service
Other process problems include infinite loop, processes
modifying each other or the operating system
Operating System Concepts – 9th Edition 1.16 Silberschatz, Galvin and Gagne ©2013
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
Interrupt architecture must save the address of the
interrupted instruction
A trap or exception is a software-generated interrupt
caused either by an error or a user request
An operating system is interrupt driven
Operating System Concepts – 9th Edition 1.17 Silberschatz, Galvin and Gagne ©2013
Interrupt Handling
The operating system preserves the state of the CPU by
storing registers and the program counter
Determines which type of interrupt has occurred:
polling
vectored interrupt system
Separate segments of code determine what action should
be taken for each type of interrupt
Operating System Concepts – 9th Edition 1.18 Silberschatz, Galvin and Gagne ©2013
I/O Structure
After I/O starts, control returns to user program only upon I/O
completion
Wait instruction idles the CPU until the next interrupt
Wait loop (contention for memory access)
At most one I/O request is outstanding at a time, no
simultaneous I/O processing
After I/O starts, control returns to user program without waiting
for I/O completion
System call – request to the OS to allow user to wait for
I/O completion
Device-status table contains entry for each I/O device
indicating its type, address, and state
OS indexes into I/O device table to determine device
status and to modify table entry to include interrupt
Operating System Concepts – 9th Edition 1.19 Silberschatz, Galvin and Gagne ©2013
Operating-System Operations (cont.)
Dual-mode operation allows OS to protect itself and other system
components
User mode and kernel mode
Mode bit 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 changes mode to kernel, return from call resets
it to user
Increasingly CPUs support multi-mode operations
i.e. virtual machine manager (VMM) mode for guest VMs
Operating System Concepts – 9th Edition 1.20 Silberschatz, Galvin and Gagne ©2013
Transition from User to Kernel Mode
Timer to prevent infinite loop / process hogging resources
Timer is set to interrupt the computer after some time period
Keep a counter that is decremented by the physical clock.
Operating system set the counter (privileged instruction)
When counter zero generate an interrupt
Set up before scheduling process to regain control or terminate
program that exceeds allotted time
Operating System Concepts – 9th Edition 1.21 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services
Operating System Concepts – 9th Edition 2.22 Silberschatz, Galvin and Gagne ©2013
Operating System Services
Operating systems provide an environment for execution of programs
and services to programs and users
One set of operating-system services provides functions that are
helpful to the user:
User interface - Almost all operating systems have a user
interface (UI).
Varies between Command-Line (CLI), Graphics User
Interface (GUI), Batch
Program execution - The system must be able to load a
program into memory and to run that program, end execution,
either normally or abnormally (indicating error)
I/O operations - A running program may require I/O, which may
involve a file or an I/O device
Operating System Concepts – 9th Edition 2.23 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
One set of operating-system services provides functions that are helpful to
the user (Cont.):
File-system manipulation - The file system is of particular interest.
Programs need to read and write files and directories, create and delete
them, search them, list file Information, permission management.
Communications – Processes may exchange information, on the same
computer or between computers over a network
Communications may be via shared memory or through message
passing (packets moved by the OS)
Error detection – OS needs to be constantly aware of possible errors
May occur in the CPU and memory hardware, in I/O devices, in user
program
For each type of error, OS should take the appropriate action to
ensure correct and consistent computing
Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system
Operating System Concepts – 9th Edition 2.24 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
Another set of OS functions exists for ensuring the efficient operation of the
system itself via resource sharing
Resource allocation - When multiple users or multiple jobs running
concurrently, resources must be allocated to each of them
Many types of resources - CPU cycles, main memory, file storage,
I/O devices.
Accounting - To keep track of which users use how much and what
kinds of computer resources
Protection and security - The owners of information stored in a
multiuser or networked computer system may want to control use of
that information, concurrent processes should not interfere with each
other
Protection involves ensuring that all access to system resources is
controlled
Security of the system from outsiders requires user authentication,
extends to defending external I/O devices from invalid access
attempts
Operating System Concepts – 9th Edition 2.25 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services
Operating System Concepts – 9th Edition 2.26 Silberschatz, Galvin and Gagne ©2013
User Operating System Interface - CLI
CLI or command interpreter allows direct command entry
Sometimes implemented in kernel, sometimes by systems
program
Sometimes multiple flavors implemented – shells
Primarily fetches a command from user and executes it
Sometimes commands built-in, sometimes just names of
programs
If the latter, adding new features doesn’t require shell
modification
Operating System Concepts – 9th Edition 2.27 Silberschatz, Galvin and Gagne ©2013
User Operating System Interface - GUI
User-friendly desktop metaphor interface
Usually mouse, keyboard, and monitor
Icons represent files, programs, actions, etc
Various mouse buttons over objects in the interface cause
various actions (provide information, options, execute function,
open directory (known as a folder)
Invented at Xerox PARC
Many systems now include both CLI and GUI interfaces
Microsoft Windows is GUI with CLI “command” shell
Apple Mac OS X is “Aqua” GUI interface with UNIX kernel
underneath and shells available
Unix and Linux have CLI with optional GUI interfaces (CDE,
KDE, GNOME)
Operating System Concepts – 9th Edition 2.28 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services
Operating System Concepts – 9th Edition 2.29 Silberschatz, Galvin and Gagne ©2013
System Calls
Programming interface to the services provided by the OS
Typically written in a high-level language (C or C++)
Mostly accessed by programs via a high-level
Application Programming Interface (API) rather than
direct system call use
Three most common APIs are Win32 API for Windows,
POSIX API for POSIX-based systems (including virtually
all versions of UNIX, Linux, and Mac OS X), and Java API
for the Java virtual machine (JVM)
Note that the system-call names used throughout this
text are generic
Operating System Concepts – 9th Edition 2.30 Silberschatz, Galvin and Gagne ©2013
System Call Implementation
Typically, a number associated with each system call
System-call interface maintains a table indexed according to
these numbers
The system call interface invokes the intended system call in OS
kernel and returns status of the system call and any return values
The caller need know nothing about how the system call is
implemented
Just needs to obey API and understand what OS will do as a
result call
Most details of OS interface hidden from programmer by API
Managed by run-time support library (set of functions built
into libraries included with compiler)
Operating System Concepts – 9th Edition 2.31 Silberschatz, Galvin and Gagne ©2013
API – System Call – OS Relationship
Operating System Concepts – 9th Edition 2.32 Silberschatz, Galvin and Gagne ©2013
Types of System Calls
Process control
create process, terminate process
end, abort
load, execute
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
Dump memory if error
Debugger for determining bugs, single step execution
Locks for managing access to shared data between processes
Operating System Concepts – 9th Edition 2.33 Silberschatz, Galvin and Gagne ©2013
Types of System Calls
File management
create file, delete file
open, close file
read, write, reposition
get and set file attributes
Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
Operating System Concepts – 9th Edition 2.34 Silberschatz, Galvin and Gagne ©2013
Course Logistics
Lecture on Monday
2 hours labs on the following days in the same week
Java is the main programming language. No need to panic as there won’t
be programming assessment for this unit. It is meant to help you understand
the contents/algorithms better for the OS concept.
Operating System Concepts – 9th Edition 2.35 Silberschatz, Galvin and Gagne ©2013
Assessment
One piece of assessment (100% weighting)
Quiz test on Moodle, 90 minutes single attempt
20 quiz questions
15 single choice ones (2.5 marks each)
5 Descriptive ones (12.5 marks each)
Operating System Concepts – 9th Edition 2.36 Silberschatz, Galvin and Gagne ©2013