Lecture 1 - Introduction To Operating Systems
Lecture 1 - Introduction To Operating Systems
Chapter One
Introduction to Operating System
and its Structures
(Materials partly taken from Operating System Concepts by Silberschatz, Galvin and Gagne, 2005 – 7th Edition, chapter 1-2)
• Computing environments
• Operating system-views
• Reading Assignments
Operating Systems
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.
• It’s a resource allocator Manages all resources
• Decides between conflicting requests for efficient and fair
resource use
• It’s a control program
• Controls the execution of programs to prevent errors and
improper use of the computer
4
Computer System structure
Components of a
computer:
• User
•machine/person /computer
•Application programs
• a special software used to solve
particular problems of users
•Operating system
•Controls and coordinates use of
hardware among various users and
applications
•Computer hardware
•I/O device, Memory, CPU
Operating Systems
Computer-System Operation
7
Computer Startup
8
Interrupts
• An interruption of the normal sequence of execution
• Improves processing efficiency
• Allows the processor to execute other instructions while an
I/O operation is in progress
• A suspension of a process caused by an event external to that
process and performed in such a way that the process can be
resumed
• Interrupt Handler:
• A program that determines nature of the interrupt and
performs whatever actions are needed
• Control is transferred to this program
• Generally part of the operating system
May 21, 2019 Operating System 9
Operating Systems
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.
• Incoming interrupts are disabled while another interrupt is
being processed to prevent a lost interrupt.
• A trap is a software-generated interrupt caused either by an
error or a user request.
• An operating system is interrupt driven.
10
Operating System Structure
• Multiprogramming is needed for
efficiency
• A single user cannot keep CPU and I/O
devices busy at all times
• Multiprogramming increases CPU
utilization by organizing 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 Memory Layout for
multiprogramed system
May 21, 2019 Operating Systems
11
Operating System Structure (contd.)
• Timesharing (multitasking) is a logical extension of multiprogramming
in which CPU executes jobs by switching among them
• The switch occurs so frequently that users can interact with each job
while it is running, creating an interactive computing
•The user gives instruction to the operating system or the program
running using an input device and waits for immediate result on an
output device
Therefore, the response time should be < 1 second
•Since the time a command/action takes in such systems is short, little
CPU time is needed for each user
This allows many users to share the computer simultaneously
•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
May 21, 2019 Operating Systems 12
Operating-System Operations
• Interrupt driven by hardware
• Software (program) error or request creates exception or trap
– Division by zero, request for operating system service
• Other process problems include infinite loop, processes modifying each
other or the operating system
• In order to ensure an appropriate execution of operating system code and
user defined code, most systems provide a hardware support
• Dual-mode operation allows OS to protect itself and other system
components
– User mode: execution done on behalf of a user.
– Monitor mode (also kernel mode or system mode) : execution
done on behalf of operating system.
• Mode bit added to computer hardware to indicate the current mode:
monitor (0) or user (1).
• Some instructions designated as privileged are only executable in
kernel mode
• System call changes mode to kernel, return from call resets it to
user mode
May 21, 2019 Operating Systems
13
Transition from User to Kernel Mode
• Timer to prevent infinite loop / process hogging resources
• Set interrupt after specific period
• Operating system decrements counter
• When counter zero generate an interrupt
• Set up before scheduling process to regain control or
terminate program that exceeds allotted time
14
Computing Environments
15
Computing Environments (contd.)
• Traditional
• Office environment
• PCs connected to a network, terminals attached to
mainframe or minicomputers providing batch and
timesharing
• Now portals allowing networked and remote systems
access to same resources
• Home networks
• Used to be single system, then modems
• Now firewalled, networked
Operating Systems
Computing Environments (Cont.)
• Client-Server Environment
• Dumb terminals supplanted by smart PCs
• Many systems now servers, responding to requests
generated by clients
Compute-server provides an interface to client to request
services (i.e. database)
File-server provides interface for clients to store and
retrieve files
17
Peer-to-Peer Environment
• Another model of distributed system
• P2P does not distinguish clients and servers
• Instead all nodes are considered peers
• Each node may act as client, server or both
• Node must join P2P network
• Registers its service with central lookup service on
network, or
• Broadcast request for service and respond to requests
for service via discovery protocol
18
Web Based Environment
• The Web has become ubiquitous
• PCs most prevalent devices
• More devices becoming networked to allow web access
• New category of devices to manage web traffic among
similar servers: load balancers
• Use of operating systems like Windows 95, client-side, have
evolved into Linux and Windows XP, which can be clients
and servers
Operating Systems
Operating-System View
Operating Systems
Component view: Process management
• Operations:
• Creation and termination
• Suspension and resumption
• Due to interrupts, context switches
• Synchronizing processes
• Making sure that a process that is waiting on an I/O
waits till it is completed and does not wait forever, i.e.,
wakes-up soon after an I/O process terminates.
• Communication
• Between two processes enabling them to cooperate.
• Deadlock detection and avoidance.
Operating Systems
Component view: Storage management
• Managing main memory
• Allocating main memory to active processes
• Maintaining a map of allocated vs. free memory
• De-allocating currently used memory to make a room for other
processes.
• Managing secondary storage
• Managing the free sectors/tracks on the disk
• Allocating this storage to programs
• Scheduling access requests to the disk
Operating Systems
Component view: I/O Management
• Devices
• Device drivers
• Accepting an I/O request and invoking appropriate device driver
• Buffering, caching, spooling
• Files
• Non-volatile representation of users/system programs and data.
• File systems
• A file is a collection of related information defined by its creator.
• Support logical organization of data that the user might want to see
• Map data onto the physical storage devices and orchestrate their access
and update.
• Operations
• Creation, manipulation and deletion of files and directories
• Moving files from primary to secondary storage while maintaining structure.
• Interaction with the memory manager
• Backup and protection
May 21, 2019 27
Operating Systems
Component view: Networking
• Support to communication in a distributed system
• FTP
• http
• Network file system
Component view: Protection
• Controlling the access of programs, processes, or users to
the resources defined by the computer system.
Operating Systems
Services view
1. Command Interpreters
• User interface between users and the kernel
2. System calls
• Programming interface to the services provided by the OS
• Typically written in high level language like 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)
3. System programs
• System programs provide convenient environment for program
execution and development.
May 21, 2019 29
Operating Systems
Services View (contd.)
System programs ( contd.)
• Some are user interfaces to system calls; some are more complex.
• Each system call is usually supported by a system program.
• They can be divided into:
• File manipulation
• Status information
• File modification
• Programming language support
• Program loading and execution
• Communications
• Application programs
Operating Systems
Shell: an OS interface
• Program that sits on the kernel as an interface between users
and the kernel.
• It is a command interpretor and also has programming
capability of its own
• Interactive access to the OS system calls
• copy from File to File
• Contains a simple programming language
• Popularized by UNIX
• Before UNIX: JCL, OS CLs (command languages)
• Bourne shell, C shell (csh), Korn shell (ksh), Bourne-again
shell (bash), etc.
May 21, 2019 31
Operating Systems
Structure View: Simple Structure
• MS-DOS – written to provide
the most functionality in the
least space
• Not divided into modules
• Although MS-DOS has some
structure, its interfaces and
levels of functionality are
not well separated
• MSDOS is vulnerable to
errant (or malicious)
programs
Operating Systems
Structure View: Layered Approach
• The operating system is
divided into a number of
layers (levels), each built on
top of lower layers. The
bottom layer (layer 0), is the
hardware; the highest (layer
N) is the user interface.
Operating Systems
Structure View: Layered Approach
• UNIX – limited by hardware functionality, the original UNIX
operating system had limited structuring. The UNIX OS consists of
two separable parts:
• Systems programs
• The kernel
Consists of everything below the system-call interface and
above the physical hardware
Provides the file system, CPU scheduling, memory
management, and other operating-system functions; a
large number of functions for one level
Operating Systems
Structure View: Layered Approach
Operating Systems
Structure View: Microkernel
• Moves as much from the kernel into “user” space
• Communication takes place between user modules using
message passing
• Benefits:
• Easier to extend a microkernel
• Easier to port the operating system to new architectures
• More reliable (less code is running in kernel mode)
• More secure
• Detriments:
• Performance overhead of user space to kernel space
communication
Operating Systems
Structure View: Microkernel (contd.)
Mac OS X Structure
May 21, 2019 37
Operating Systems
Structure View: Modules
• Most modern operating systems
implement kernel modules
• Uses object-oriented
approach
• Each core component is
separate
• Each talks to the others over
known interfaces
• Each is loadable as needed
within the kernel
• Overall, similar to layers but Solaris Modular Approach
with more flexible nature
May 21, 2019 38
Operating Systems
Structure View: Virtual Machines
• A virtual machine takes the layered approach to its logical conclusion.
It treats hardware and the operating system kernel as though they were
all hardware
• A virtual machine provides an interface identical to the underlying bare
hardware
• The operating system creates the illusion of multiple processes, each
executing on its own processor with its own (virtual) memory
• The resources of the physical computer are shared to create the virtual
machines
• CPU scheduling can create the appearance that users have their own
processor
• Spooling and a file system can provide virtual card readers and virtual
line printers
• A normal user time-sharing terminal serves as the virtual machine
operator’s console
May 21, 2019 39
Operating Systems
Structure View: Virtual Machines (contd.)
Operating Systems
Structure View: Virtual Machines (contd.)
• The virtual-machine concept provides complete protection of
system resources since each virtual machine is isolated from all
other virtual machines. This isolation, however, permits no direct
sharing of resources.
Operating Systems
Structure View: Virtual Machines (contd.)
VMware Architecture
May 21, 2019 42
Operating Systems
The Java Virtual Machine
Operating Systems
Reading Assignments
1. As discussed in today’s lecture, OS can be viewed from different perspectives.
Read more about the functional and service views.
2. What are the uses of system calls and system programs. Identify their different
types
3. What is cache memory? Discuss its advantages?
4. Operating system provides helpful services to users which are categorized in to
two groups:
• User interface, program execution, I/O operation, File-system
Manipulation, Communications, Error detection
• Resource Allocation, Accounting, Protection and Security
Study the functions each of the services in the two categories
5. Read about the following operating systems and list out the major characteristics
of each:
• Serial processing
• Simple batch systems
• Multiprogrammed batch systems
• Timesharing systems
May 21, 2019 44
Operating Systems
Recommended Websites
• The Operating System Resource Center: A useful collection of documents
and papers on a wide range of operating system topics.
• Review of Operating Systems: A comprehensive review of commercial,
free, research and hobby operating systems.
• Operating System Technical Comparison: Includes a substantial amount
of information on a variety of operating systems.
• ACM Special Interest Group on Operating Systems: Information on
SIGOPS publications and conferences.
• IEEE Technical Committee on Operating Systems and Application
Environments: Includes an online newsletter and links to other sites.
• The comp. os. research FAQ: Lengthy and worthwhile FAQ covering
operating system design issues.
Operating Systems
May 21, 2019 Operating Systems
46