Lecture 1 Operating System Fundamentals
Lecture 1 Operating System Fundamentals
Operating System
Chapter 1: Introduction
• What Operating Systems Do?
• Operating System-Structure
• Operating Systems Operations
• Process Management
• Memory Management
• Protection and Security
• Kernel Data Structures
• Computing Environments
Objectives
• Describe the general organization of a computer system and the
role of interrupts
• Describe the components in a modern, multiprocessor computer
system
• Illustrate the transition from user mode to kernel mode
• Discuss how operating systems are used in various computing
environments
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
Computer System Structure
• Computer system can be divided into four
components:
• Hardware – provides basic computing resources
• CPU, memory, I/O devices
• Operating system
• Controls and coordinates use of hardware among
various applications and users
• Application programs – define the ways in which the
system resources are used to solve the computing
problems of the users
• Word processors, compilers, web browsers, database
systems, video games
• Users
• People, machines, other computers Abstract View of Components of Computer
What 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
• Operating system is a resource allocator and control program making efficient use of HW
and managing execution of user programs
• Users of dedicate systems such as workstations have dedicated resources but
frequently use shared resources from servers
• Mobile devices like smartphones and tables are resource poor, optimized for
usability and battery life
• Mobile user interfaces such as touch screens, voice recognition
• Some computers have little or no user interface, such as embedded computers in
devices and automobiles
• Run primarily without user intervention
Defining Operating Systems
• Term OS covers many roles
• Because of myriad designs and uses of OSes
• Present in toasters through ships, spacecraft, game machines, TVs and
industrial control systems
• Born when fixed use computers for military became more general
purpose and needed resource management and program control
Operating System Definition
• No universally accepted definition
• “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, part
of the operating system
• Everything else is either
• A system program (ships with the operating system, but not part of the kernel) , or
• An application program, all programs not associated with the operating system
• Today’s OSes for general purpose and mobile computing also include
middleware – a set of software frameworks that provide additional services
to application developers such as databases, multimedia, graphics
Overview of the Computer
System Structure
Operating System
Computer System Organization
• Computer-system operation
• One or more CPUs, device
• Concurrent execution of CPUs and devices competing for memory
cycles
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
Interrupt Timeline
Interrupt Handling
• The operating system preserves the state of the CPU by storing
the registers and the program counter
• Determines which type of interrupt has occurred:
• Separate segments of code determine what action should be
taken for each type of interrupt
Interrupt-drive I/O Cycle
CPU I/O controller
1
interrupt handler
processes data,
returns from interrupt
CPU resumes
processing of
interrupted task
I/O Structure
• Two methods for handling I/O
• After I/O starts, control returns to user program only upon I/O
completion
• After I/O starts, control returns to user program without waiting for I/O
completion
I/O Structure (Cont.)
• 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
Computer Startup
• Typically stored in ROM or EPROM, generally known
as firmware
• Initializes all aspects of system
• Loads operating system kernel and starts execution
Storage Structure
Operating System
Storage Structure
• Main memory – only large storage media that the CPU can access directly
• Random access
• Typically volatile
• 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
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
• Mounting and unmounting
• Free-space management
• Storage allocation
• Disk scheduling
• Partitioning
• Protection
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
Characteristics of Various Types of Storage
processes
processes
processes processes
programming
kernel kernel kernel
interface
VM1 VM2 VM3
kernel
virtual machine
manager
hardware
hardware
(a) (b)
Distributed System
• Collection of separate, possibly heterogeneous, systems
networked together
• Network is a communications path, TCP/IP most common
• Local Area Network (LAN)
• Wide Area Network (WAN)
• Metropolitan Area Network (MAN)
• Personal Area Network (PAN)
• Network Operating System provides features between systems
across network
• Communication scheme allows systems to exchange messages
• Illusion of a single system
Computer System
Architecture
Operating System
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
Symmetric Multiprocessing Architecture
Dual-Core Design
Operating System
Computing Environments
• Traditional
• Mobile
• Client Server
• Peer-to-Peer
• Cloud computing
• Real-time Embedded
Traditional
• Stand-alone general-purpose machines
• But blurred as most systems interconnect with others (i.e., the
Internet)
• Portals provide web access to internal systems
• Network computers (thin clients) are like Web terminals
• Mobile computers interconnect via wireless networks
• Networking becoming ubiquitous – even home systems use
firewalls to protect home computers from Internet attacks
Mobile
• Handheld smartphones, tablets, etc.
• What is the functional difference between them and a
“traditional” laptop?
• Extra feature – more OS features (GPS, gyroscope)
• Allows new types of apps like augmented reality
• Use IEEE 802.11 wireless, or cellular data networks for
connectivity
• Leaders are Apple iOS and Google Android
Client Server
• Client-Server Computing
• Dumb terminals supplanted by smart PCs
• Many systems now servers, responding to requests generated by clients
• Compute-server system provides an interface to client to request services (i.e.,
database)
• File-server system provides interface for clients to store and retrieve files
client
desktop
Server client
Network
laptop
client
smartphone
Peer-to-Peer
• Another model of distributed system
• P2P does not distinguish clients and servers
• Instead all nodes are considered peers
• May each 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
• Examples include Napster and Gnutella, Voice over IP (VoIP) such as
Skype
Cloud Computing
• Delivers computing, storage, even apps as a service across a
network
• Logical extension of virtualization because it uses virtualization
as the base for it functionality.
• Amazon EC2 has thousands of servers, millions of virtual machines,
petabytes of storage available across the Internet, pay based on usage
Cloud Computing (Cont.)
• Many types
• Public cloud – available via Internet to anyone willing to pay
• Private cloud – run by a company for the company’s own use
• Hybrid cloud – includes both public and private cloud components
• Software as a Service (SaaS) – one or more applications available via the
Internet (i.e., word processor)
• Platform as a Service (PaaS) – software stack ready for application use
via the Internet (i.e., a database server)
• Infrastructure as a Service (IaaS) – servers or storage available over
Internet (i.e., storage available for backup use)
Cloud Computing (cont.)
Internet
• Cloud computing environments customer
requests
tools
load balancer cloud
management
commands
Operating System
Kernel Data Structure
• Many similar to standard programming data structures
• Singly linked list
data data data null
• • •
6 14 32 40
Kernel Data Structures
• Hash function can create a hash
map
hash_function(key)