Sie sind auf Seite 1von 29

Operating System Concepts

Reference: Operating System Concepts, 8th Edition, Abraham Silberschatz, Peter Baer Galvin, Greg
Gagne. John Wiley & Sons, Inc.

2/23/2017 Operating Systems Overview 1


Chapter1: Introduction

What is an Operating System?


An operating system is software that manages the computer hardware.

Which acts as an interface between the user of a computer and the computer
hardware.

And provide an environment in which a user can execute programs in a


convenient and efficient manner.
Because an operating system is large and complex, it must be created piece
by piece. Each of these pieces should be a well-delineated portion of the
system, with carefully defined inputs, outputs, and functions.

The hardware must provide appropriate mechanisms to ensure the correct


operation of the computer system and to prevent user programs from
interfering with the proper operation of the system.

2/23/2017 Operating Systems Overview 2


Chapter1: Introduction
Computer System Components
1. Hardware: provides basic computing
resources (CPU, memory, I/O
devices).
2. Operating system: controls and
coordinates the use of the hardware
among the various application
programs for the various users.
3. Applications programs: define the
ways in which the system resources
are used to solve the computing
problems of the users (compilers,
database systems, video games,
business programs).
4. Users: (people, machines, other
computers).

2/23/2017 Operating Systems Overview 3


Chapter1: Introduction
To understand more fully the operating systems role, we next explore operating
systems from two viewpoints:

User View
Easy of use
Rescores utilization (Mainframe (terminals)- Minicomputer Workstations)
A more common definition is that operating system is: The one program
running at all times on the computer is the kernel. Everything else is either a
system program or an application program

System view
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

2/23/2017 Operating Systems Overview 4


Chapter1: Introduction
Defining Operating System
Resource allocator manages and allocates resources.

Control program controls the execution of user programs and operations of


I/O devices .

Is the one program running at all times on the computerusually called the
kernel. Along with the kernel, there are two other types of programs:
System programs, which are associated with the operating system but are
not necessarily part of the kernel,
and application programs, which include all programs not associated
with the operation of the system.)
Mobile operating systems often include not only a core kernel but also
middlewarea set of software frameworks that provide additional services to
application developers.

2/23/2017 Operating Systems Overview 5


Chapter1: Introduction
Computer-System Organization
A modern general-purpose computer
system consists of 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.
To ensure orderly access to the
shared memory, a memory controller
synchronizes access to the memory.
Computer Startup : Bootstrap program is loaded at power-up or reboot which:
Typically stored in ROM or EPROM, generally known as firmware
Initializes all aspects of system
Loads operating system kernel and starts execution of the operating system and
it can start providing services to the system and its users.
2/23/2017 Operating Systems Overview 6
Chapter1: Introduction
Computer-System Organization Con.
Computer-System Operation:
Shared memory between CPU and I/O cards
Time slicing for multi-process operation
I/O devices and the CPU can execute concurrently.
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
Device controller informs CPU that it has finished its operation by causing
an interrupt.
The occurrence of an event is usually signaled by an interrupt from either
the hardware or software.
Hardware may trigger an interrupt at any time by sending a signal to the
CPU, usually by way of the system bus.
Software may trigger an interrupt by executing a special operation called a
system call (also called a monitor call)

2/23/2017 Operating Systems Overview 7


Chapter1: Introduction
Computer-System Organization Con.
Common Functions of Interrupts
When the CPU is interrupted, it stops what it is
doing and immediately transfers execution to a
fixed location.
The fixed location usually contains the starting
address where the service routine for the interrupt
is located.
The interrupt service routine executes; on
completion, the CPU resumes the interrupted
computation.
Interrupt mechanism
An operating system is interrupt driven.
Interrupt transfers control to the Interrupt Service Routine generally, through the
Interrupt Vector, which contains the addresses of all the service routines.
This array, or the interrupt vector, of addresses is then indexed by a unique device
number, given with the interrupt request, to provide the address of the interrupt service
routine for the interrupting device.
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.
2/23/2017 Operating Systems Overview 8
Chapter1: Introduction
Main memory:
Storage Structure
Computer programs must be in main memory (RAM) to be executed. It is
implemented in a semiconductor technology called dynamic random-access
memory (DRAM).
ROM and electrically erasable programmable read-only memory, EEPROM).
Because ROM only static programs, such as the bootstrap program are stored
there.
All forms of memory provide an array of bytes. Each byte has its own address.
Interaction is achieved through a sequence of load or store instructions to specific
memory addresses. The load instruction moves a byte or word from main
memory to an internal register within the CPU, whereas the store instruction
moves the content of a register to main memory.
Secondary storage
Large nonvolatile storage capacity.
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.
2/23/2017 Operating Systems Overview 9
Chapter1: Introduction
Storage Hierarchy

Storage organized in hierarchy


Speed
Cost
Volatility

Caching: copying information


into faster storage system; main
memory can be viewed as a last
cache for secondary storage.

2/23/2017 Operating Systems Overview 10


Chapter1: Introduction
Caching
Caching copying information into faster storage system; main memory can be
viewed as a last cache for secondary storage.

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
2/23/2017 Operating Systems Overview 11
Chapter1: Introduction
Migration of Integer A from Disk to Register

Multitasking environments must be careful to use most recent value, no matter


where it is stored in the storage hierarchy.
Multiprocessor environment must provide cache coherency in hardware such
that all CPUs have the most recent value in their cache.
Distributed computing environment is a model in which components of a
software system are shared among multiple computers to improve efficiency
and performance. A collection of independent computers that appears to its
users as a single coherent system

2/23/2017 Operating Systems Overview 12


Chapter1: Introduction
I/O Structure
A general purpose computer system consists of CPU and multiple device controllers that
are connected through a common bus.
A device controller maintains some local buffer storage and a special-purpose registers.
it responsible for moving the data between the peripheral devices that it controls and its
local buffer storage.
Operating system has a driver for each device controller.
For start an I/O operation, the device driver loads the appropriate registers within the
device controller.
The device controller, in turn examines the contents of these registers to determine what
a action to take (such read a character from the keyboard).
The controller starts the transfer of data from the device to its local buffer.
Once the transfer of data is complete , the device controller informs the device driver
then returns control to the operating system.
This form of interrupt-driven I/O is fine for moving small amounts of data but can
produce high overhead when used for bulk data movement such as disk I/O. To solve this
problem, direct memory access (DMA) is used. After setting up buffers, pointers, and
counters for the I/O device, the device controller transfers an entire block of data directly
to or from its own buffer storage to memory (DMA), with no intervention by the CPU.

2/23/2017 Operating Systems Overview 13


Chapter1: Introduction
I/O Structure

Synchronous Asynchronous

2/23/2017 Operating Systems Overview 14


Chapter1: Introduction
Direct Memory Access Structure

Used for high-speed I/O devices able to transmit information at


close to memory speeds.
Device controller transfers blocks of data from buffer storage
directly to main memory without CPU intervention.
Only one interrupt is generated per block, rather than the one
interrupt per byte.

2/23/2017 Operating Systems Overview 15


Chapter1: Introduction
Computer-System Architecture
A computer system can be organized in a number of different ways, which we can categorize
roughly according to the number of general-purpose processors used.
Single processor systems (one general purpose CPU) (from PDAs- mainframes) may be
having other special purpose processors (keyboard, graphics controllers).

Multiprocessor systems (parallel system or multicore system): two or processors


sharing system the computer bus and cache, memory, and peripheral device (Increased
throughput, Economy of scale, Increased reliability). The multiple-processor
systems in use today are of two types:
Can be Asymmetric (each processor is assigned a specific task, a master processor
or have predefined tasks).
Or Symmetric multiprocessing (SMP) in which each processor performs all tasks
within the operating system

Clustered systems (LAN WAN)

2/23/2017 Operating Systems Overview 16


Chapter1: Introduction
Operating-System Structure
Multiprogramming needed for efficiency
Multiprogramming organizes jobs (code and data) so CPU always has one
to execute.
in general, main memory is too small to accommodate all jobs, the jobs are
kept initially on the disk in the job pool, 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 multiprogramming, in which
CPU switches jobs so frequently that users can interact with each job while it is
running, creating interactive computing
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 dont fit in memory, swapping moves them in and out to run
Virtual memory allows execution of processes not completely in memory
A time-sharing ( multi-user multi-tasking ) OS requires:
Memory, Process, File system management, Job scheduling, Resource allocation strategies, Swap
space / virtual memory in physical memory, Interrupt handling, Protection and security, Inter-process
communications.

2/23/2017 Operating Systems Overview 17


Chapter1: Introduction
Operating-System Operations

Interrupt driven by hardware


Software error or request creates exception or trap
Division by zero, request for operating system service
Dual-mode operation allows OS to protect itself and other system components
User mode and kernel mode
Mode bit provided by hardware
o Provides ability to distinguish when system is running user code or kernel code
o Some instructions designated as privileged, only executable in kernel mode
o System call changes mode to kernel, return from call resets it to user
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
2/23/2017 Operating Systems Overview 18
Chapter1: Introduction
Operating-System Operations Con.
Dual-Mode and Multimode Operation Con.
The concept of modes can be extended beyond two, requiring more than a
single mode bit
CPUs that support virtualization use one of these extra bits to indicate when
the virtual machine manager, VMM.
The VMM has more privileges than ordinary user programs, but not so
many as the full kernel.
System calls are typically implemented in the form of software interrupts,
which causes the hardware's interrupt handler to transfer control over to an
appropriate interrupt handler, which is part of the operating system,
switching the mode bit to kernel mode in the process.
The interrupt handler checks exactly which interrupt was generated, checks
additional parameters ( generally passed through registers ) if appropriate,
and then calls the appropriate kernel service routine to handle the service
requested by the system call.

2/23/2017 Operating Systems Overview 19


Chapter1: Introduction
Operating-System Operations Con.

Timer
Before the kernel begins executing user code, a timer is set to
generate an interrupt.
The timer interrupt handler returns control back to the kernel.
This guarantees that no user process can take over the system.
Timer control is a privileged instruction, ( requiring kernel
mode. )

2/23/2017 Operating Systems Overview 20


Chapter1: Introduction
Operating-System Operations Con.
Process Management
An OS is responsible for the following tasks with regards to process management:
Creating and deleting both user and system processes
Ensuring that each process receives its necessary resources, without interfering with
other processes.
Suspending and resuming processes
Process synchronization and communication
Deadlock handling
Memory Management

An OS is responsible for the following tasks with regards to memory management:


Keeping track of which blocks of memory are currently in use, and by which
processes.
Determining which blocks of code and data to move into and out of memory, and
when.
Allocating and deallocating memory as needed. ( E.g. new, malloc )

2/23/2017 Operating Systems Overview 21


Chapter1: Introduction
Operating-System Operations Con.
Storage Management
File-System Management
Creating and deleting files and directories
Supporting primitives for manipulating files and directories. ( open, flush, etc. )
Mapping files onto secondary storage.
Backing up files onto stable permanent storage media.

Mass-Storage Management
Free disk space management
Storage allocation
Disk scheduling

Note the trade-offs regarding size, speed, longevity, security, and re-writability between
different mass storage devices, including floppy disks, hard disks, tape drives, CDs, DVDs,
etc.

2/23/2017 Operating Systems Overview 22


Chapter1: Introduction
Operating-System Operations Con.
Storage Management
Caching
The OS is responsible for determining what information to store in what level of cache, and when
to transfer data from one level to another.
The proper choice of cache management can have a profound impact on system performance.
Each step ( other than the registers ) will typically fetch more data than is immediately needed,
and cache the excess in order to satisfy future requests faster. For writing, small amounts of data
are frequently buffered until there is enough to fill an entire "block" on the next output device in
the chain.

Figure: Performance of various levels of storage

Figure: Migration of integer A from disk to register.


2/23/2017 Operating Systems Overview 23
Chapter1: Introduction
Operating-System Operations Con.
I/O Subsystems
One purpose of OS is to hide peculiarities of hardware devices from the user
I/O subsystem responsible for
A memory-management component that includes buffering (storing data
temporarily while it is being transferred), caching (storing parts of data in
faster storage for performance), and spooling (the overlapping of output of
one job with input of other jobs).
A general device-driver interface.
Drivers for specific hardware devices.
Protection and Security
Protection involves ensuring that no process access or interfere with resources
to which they are not entitled, either by design or by accident. ( E.g.
"protection faults" when pointer variables are misused. )
Security involves protecting the system from deliberate attacks, either from
legitimate users of the system attempting to gain unauthorized access and
privileges, or external attackers attempting to access or damage the system.
2/23/2017 Operating Systems Overview 24
Chapter1: Introduction
Kernel Data Structures
We turn next to a topic central to operating-system implementation: the way data are
structured in the system.
Lists, Stacks last in, first out (LIFO), and
Queues first in, first out (FIFO) principle

Figure Singly linked list.

Figure Doubly linked list.

Figure Circularly linked list.


2/23/2017 Operating Systems Overview 25
Chapter1: Introduction
Kernel Data Structures
Trees
Data values in a tree structure are linked
through parentchild relationships Binary search tree.

Hash Functions and Maps


A hash function takes data as its input,
performs a numeric operation on this
data, and returns a numeric
. value. This
numeric value can then be used as an Hash map.
index into a table (typically an array)
to quickly retrieve the data
Bitmaps
A bitmap is a string of n binary
digits that can be used to represent As an example, consider the bitmap shown
the status of n items. below: 001011101
The availability of each resource is Resources 2, 4, 5, 6, and 8 are unavailable;
indicated by the value of a binary resources 0, 1, 3, and 7 are available.
digit 0 or one
2/23/2017 26
Operating Systems Overview
Chapter1: Introduction
Computing Environments
How operating systems are used in a variety of computing environments.
Traditional Computing
Mobile Computing
Computing on small handheld devices such as smart phones or tablets.
May take advantage of additional built-in sensors, such as GPS...
Limited in storage capacity, memory capacity, and computing power relative to a PC.
Generally uses slower processors, that consume less battery power and produce less heat.
The two dominant OSes today are Google Android and Apple iOS.
Distributed Systems
Distributed Systems consist of multiple, possibly heterogeneous, computers connected together via a
network. Networks may range from small tight LANs to broad reaching WANs.
WAN = Wide Area Network, such as an international corporation
MAN =Metropolitan Area Network, covering a region the size of a city for example.
LAN =Local Area Network, typical of a home, business, single-site corporation, or university campus.
PAN = Personal Area Network, such as the bluetooth connection between your PC, phone, headset, etc.
Network access speeds, throughputs, reliabilities, are all important issues.
OS view of the network may range from just a special form of file access to complex well-coordinated
network operating systems.
Shared resources may include files, CPU cycles, RAM, printers, and other resources.
2/23/2017 Operating Systems Overview 27
Chapter1: Introduction
Computing Environments
ClientServer Computing
A defined server provides services ( HW or SW ) to
other systems which serve as clients.
A process may act as both client and server of either the
same or different resources.
Served resources may include disk space, CPU cycles,
time of day, IP name information, or other resources.

Peer-to-Peer Computing

Any computer or process on the network may provide


services to any other which requests it. There is no
clear "leader" or overall organization.

Virtualization
Allows one or more "guest" operating systems to
run on virtual machines hosted by a single physical
machine and the virtual machine manager.
2/23/2017 28
Operating Systems Overview
Chapter1: Introduction
Computing Environments
Cloud Computing: Delivers computing, storage, and applications as a service over a network. Of Types:
Public cloud - Available to anyone willing to pay for the
service.
Private cloud - Run by a company for internal use only.
Hybrid cloud - A cloud with both public and private
components.
Software as a Service - SaaS - Applications such as word
processors available via the Internet
Platform as a Service - PaaS - A software stack available
for application use, such as a database server
Infrastructure as a Service - IaaS - Servers or storage
available on the Internet, such as backup servers, photo
storage, or file storage.
Service providers may provide more than one type of
service
Real-Time Embedded Systems
Embedded into devices such as automobiles, climate control systems,
May involve specialized chips, or generic CPUs applied to a particular task.
Process control devices require real-time ( interrupt driven ) OSes.
Response time can be critical for many such devices.
2/23/2017 Operating Systems Overview 29

Das könnte Ihnen auch gefallen