Lecture 1b
OPERATING SYSTEMS
Operating System Concepts – 9th Edition 1.1 Silberschatz, Galvin and Gagne ©2013
Interrupt-drive I/O Cycle
Operating System Concepts – 9th Edition 1.2 Silberschatz, Galvin and Gagne ©2013
Interrupt Timeline
Operating System Concepts – 9th Edition 1.3 Silberschatz, Galvin and Gagne ©2013
Storage-Device Hierarchy
Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne ©2013
Types of OS
Batch Operating System
Multitasking/Time Sharing OS
Multiprocessing OS
Real Time OS
Distributed OS
Network OS/ Clustered
Mobile OS
Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne ©2013
Memory Layout for Multiprogrammed System
Process Management
A process is a program in execution. It is a unit of work within the system. Program is a passive
entity, process is an active entity.
Process needs resources to accomplish its task
CPU, memory, I/O, files
Initialization data
Process termination requires reclaim of any reusable resources
Single-threaded process has one program counter specifying location of next instruction to
execute
Process executes instructions sequentially, one at a time, until completion
Multi-threaded process has one program counter per thread
Typically system has many processes, some user, some operating system running concurrently
on one or more CPUs
Concurrency by multiplexing the CPUs among the processes / threads
Operating System Concepts – 9th Edition 1.7 Silberschatz, Galvin and Gagne ©2013
Timer
Timer to prevent infinite loop (or 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
Memory Management
To execute a program all (or part) of the instructions must be in memory
All (or part) of the data that is needed by the program must be in memory.
Memory management determines what is in memory and when
Optimizing CPU utilization and computer response to users
Memory management activities
Keeping track of which parts of memory are currently being used and by whom
Deciding which processes (or parts thereof) and data to move into and out of
memory
Allocating and deallocating memory space as needed
Operating System Concepts – 9th Edition 1.9 Silberschatz, Galvin and Gagne ©2013
Storage Management
OS provides uniform, logical view of information storage
Abstracts physical properties to logical storage unit - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-transfer rate, access method
(sequential or random)
File-System management
Files usually organized into directories
Access control on most systems to determine who can access what
OS activities include
Creating and deleting files and directories
Primitives to manipulate files and directories
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media
Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne ©2013
Mass-Storage Management
Usually disks used to store data that does not fit in main memory or data that must be kept for a “long”
period of time
Proper management is of central importance
Entire speed of computer operation hinges on disk subsystem and its algorithms
OS activities
Free-space management
Storage allocation
Disk scheduling
Some storage need not be fast
Tertiary storage includes optical storage, magnetic tape
Still must be managed – by OS or applications
Varies between WORM (write-once, read-many-times) and RW (read-write)
Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne ©2013
Caching
Important principle, performed at many levels in a computer (in hardware,
operating system, software)
Information in use copied from slower to faster storage
temporarily
Faster storage (cache) checked first to determine if information is there
If it is, information used directly from the cache (fast)
If not, data copied to cache and used there
Cache smaller than storage being cached
Cache management important design problem
Cache size and replacement policy
Protection and Security
Protection – Mechanism for controlling access of processes or users to resources defined by
the OS
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
• User identities (user IDs, security IDs) include name and associated number, one per
user, 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 allows user to change to effective ID with more rights
A View of Operating System Services
• OS provides environment for program execution.
Operating System Services
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
File-system manipulation - The file system is of particular interest. Obviously,
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
Error detection – OS needs to be constantly aware of possible errors
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 - Some (such as CPU cycles, main memory, and file
storage) may have special allocation code, others (such as I/O devices) may have
general request and release code
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
User Operating System Interface - CLI
Command Line Interface (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
A shell is a piece of software that provides an interface for users to
an operating system which provides access to the services of a kernel
Shell
Bourne Shell Command Interpreter
User Operating System Interface - GUI
User-friendly desktop 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)
Many systems now include both CLI and GUI interfaces
Microsoft Windows is GUI with CLI “command” shell
Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells
available
Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)
System Call
A system call is the programmatic way in which a computer
program requests a service from the kernel of the operating
system
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 Program 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)
Why use APIs rather than system calls?
(Note: system-call names used throughout are generic)
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 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)
API – System Call – OS
Relationship
Standard C Library Example
C program invoking printf() library call, which calls write() system call