Você está na página 1de 87

Lecture – 1

By: NIDAL SEERAT

O.S Lecture 1 1
O.S Lecture 1 2
Operating System
A program that controls the execution of application
programs OR
An interface between applications and hardware OR
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.

O.S Lecture 1 3
Operating System
Functions same way as ordinary computer software
It is program that is executed
Operating system relinquishes control of the
processor to execute other programs

O.S Lecture 1 4
Basic Elements of OS
Processor
Main Memory
referred to as real memory or primary memory
volatile
I/O modules
secondary memory devices
communications equipment
terminals
System bus
communication among processors, memory, and I/O
modules

O.S Lecture 1 5
Operating System
Objectives
Convenience
Makes the computer more convenient to use
Efficiency
Allows computer system resources to be used in an
efficient manner
Ability to evolve
Permit effective development, testing, and introduction
of new system functions without interfering with service

O.S Lecture 1 6
Layers of Computer
System

O.S Lecture 1 7
Services Provided by the
Operating System
1. Program development
 Editors and debuggers
1. Program execution
2. Access to I/O devices
3. Controlled access to files
4. System access
5. Error detection and response
 internal and external hardware errors
 memory error
 device failure
 software errors
 arithmetic overflow
 access forbidden memory locations

O.S Lecture 1 8
Services Provided by the
Operating System
7. Accounting
collect statistics
monitor performance
used to anticipate future enhancements
used for billing users

O.S Lecture 1 9
Operating System Roles
Resource allocator – manages and allocates
resource. Performs Job scheduling & CPU
scheduling.
Control program – controls the execution of
user programs and operations of I/O devices
Kernel – the one program running at all times (all
else being application programs).

O.S Lecture 1 10
Reasons for Evolution of an
Operating System
Hardware upgrades and new types of hardware
New services
Fixes

O.S Lecture 1 11
O.S Lecture 1 12
Evolution of Operating
Systems
Serial Processing
No operating system
Machines run from a console with display lights and
toggle switches, input device, and printer
In case of error ,Programmer had to examine registers
& main memory to detect source of error.
Setup included loading the compiler, source program
(in Assembly language), saving compiled program, and
loading and linking common functions.

O.S Lecture 1 13
Problems in Serial Processing
Scheduling
User may sign-up for 1 hour and may finish the job in
45 minutes, result in wasted CPU cycles.
Setup time
Setup included loading the compiler, source program
(in Assembly language), saving compiled program, and
loading and linking common functions.
Require mounting & dismounting of tapes.

O.S Lecture 1 14
Evolution of Operating
Systems
Simple Batch Systems
 Monitors
 Software that controls the running programs
 Batch jobs together
 Program branches back to monitor when finished
 Resident monitor is in main memory and available for execution
 Handled job scheduling & job setup time by attaching setup instruction to each job.
 Job Control Language (JCL)
 Special type of programming language
 Provides instruction to the monitor
 what compiler to use

 what data to use

O.S Lecture 1 15
Ctd…..Simple batch
systems
Hardware Features
 Memory protection
 do not allow the memory area containing the monitor to be altered
 Report error if a job is trying to access monitor’s memory area

 Timer
 prevents a job from monopolizing the system

 If time expires ,return the control to monitor

 Privileged Instructions
 Only executed by monitor
 If such instruction comes,job execution stops
 I/O requests are example.

O.S Lecture 1 16
O.S Lecture 1 17
Disadvantages of Simple
batch systems
Uni-programming
CPU cycles wasted due to I/O requests
Job execution in sequence

O.S Lecture 1 18
Multiprogrammed batch
systems
When one program waits for I/O, the CPU switch to
next job.
Several programs in memory at a time.
Supported I/O interrupt mechanism
Disadvantages:
No User Interface
Transaction Processing systems needs interactive user
interface

O.S Lecture 1 19
Mainframe Systems
Reduce setup time by batching similar jobs
Automatic job sequencing – automatically
transfers control from one job to another.
First rudimentary operating system.
Resident monitor
initial control in monitor
control transfers to job
when job completes control transfers pack to
monitor

O.S Lecture 1 20
Several jobs are kept in main memory at the same time, and the
CPU is multiplexed among them.

O.S Lecture 1 21
Uniprogramming
Processor must wait for I/O instruction to complete
before preceding

O.S Lecture 1 22
Multiprogramming
When one job needs to wait for I/O, the processor
can switch to the other job

O.S Lecture 1 23
Multiprogramming
Systems

O.S Lecture 1 24
Effects of
Multiprogramming
Uniprogramming Multiprogramming
Processor use 22% 43%
Memory use 30% 67%
Disk use 33% 67%
Printer use 33% 67%
Elapsed time 30 min. 15 min.
Throughput rate 6 jobs/hr 12 jobs/hr
Mean response time 18 min. 10 min.

O.S Lecture 1 25
Time Sharing
Systems……..interactive computing
 Using multiprogramming to handle multiple interactive jobs

 Processor’s time is shared among multiple users

 Multiple users simultaneously access the system through terminals

 The CPU is multiplexed among several jobs that are kept in memory and on disk

(the CPU is allocated to a job only if the job is in memory).

 A job swapped in and out of memory to the disk.

 On-line communication between the user and the system is provided; when the

operating system finishes the execution of one command, it seeks the next
“control statement” from the user’s keyboard.

 On-line system must be available for users to access data and code.

O.S Lecture 1 26
Batch Multiprogramming
versus Time Sharing
Batch Multiprogramming Time Sharing

Principal objective Maximize processor use Minimize response time

Source of directives Job control language Commands entered at the


to operating system commands provided with the terminal
job

O.S Lecture 1 27
Desktop Systems
Personal computers – computer system
dedicated to a single user.
I/O devices – keyboards, mice, display screens,
small printers.
User convenience and responsiveness.
Can adopt technology developed for larger
operating system’ often individuals have sole
use of computer and do not need advanced CPU
utilization of protection features.
May run several different types of operating
systems (Windows, MacOS, UNIX, Linux)

O.S Lecture 1 28
Parallel Systems
Multiprocessor systems with more than on CPU in
close communication.
Tightly coupled system – processors share memory
and a clock; communication usually takes place
through the shared memory.
Advantages of parallel system:
Increased throughput
Economical
Increased reliability
 graceful degradation
 fail-soft systems

O.S Lecture 1 29
Parallel Systems (Cont.)
Symmetric multiprocessing (SMP)
Each processor runs and identical copy of the
operating system.
Many processes can run at once without
performance deterioration.
Most modern operating systems support SMP
Asymmetric multiprocessing
Each processor is assigned a specific task; master
processor schedules and allocated work to slave
processors.
More common in extremely large systems

O.S Lecture 1 30
O.S Lecture 1 31
Distributed Systems
Distribute the computation among several
physical processors.
Loosely coupled system – each processor has
its own local memory; processors communicate
with one another through various
communications lines, such as high-speed buses
or telephone lines.
Advantages of distributed systems.
Resources Sharing
Computation speed up – load sharing
Reliability
Communications
O.S Lecture 1 32
Distributed Systems
(cont)
Requires networking infrastructure.
Local area networks (LAN) or Wide area
networks (WAN)
May be either client-server or peer-to-peer
systems.

O.S Lecture 1 33
O.S Lecture 1 34
Clustered Systems
Clustering allows two or more systems to share
storage.
Provides high reliability.
Asymmetric clustering: one server runs the
application while other servers standby.
Symmetric clustering: all N hosts are running the
application.

O.S Lecture 1 35
Real-Time Systems
Often used as a control device in a dedicated
application such as controlling scientific
experiments, medical imaging systems, industrial
control systems, and some display systems.
Well-defined fixed-time constraints.

O.S Lecture 1 36
Handheld Systems
Personal Digital Assistants (PDAs)
Cellular telephones
Issues:
Limited memory
Slow processors
Small display screens.

O.S Lecture 1 37
Major Achievements
Processes
Memory Management
Information protection and security
Scheduling and resource management
System structure

O.S Lecture 1 38
O.S Lecture 1 39
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).
O.S Lecture 1 40
O.S Lecture 1 41
Computer-System
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
I/O is from the device to local buffer of controller.
Device controller informs CPU that it has finished its
operation by causing an interrupt.

O.S Lecture 1 42
O.S Lecture 1 43
Instruction Cycle

O.S Lecture 1 44
Instruction Fetch and
Execute
1. The processor fetches the instruction from memory
2. Program counter (PC) holds address of the
instruction to be fetched next
3. Program counter is incremented after each fetch
4. Fetched instruction is loaded into CPU’s instruction
registers .
5. CPU reads & executes instruction.
6. increments PC

O.S Lecture 1 45
Interrupts
An interrupt is an asynchronous signal
from hardware indicating need for
attention

OR

it is synchronous event in software


indicating the need for a change in
execution.
O.S Lecture 1 46
Interrupts
It is an interruption of the normal sequence of execution.
An act of interrupting is called IRQ (interrupt request).
Bus lines are used to signal an interrupt.
Hardware interrupt:
Causes CPU to save its state of execution via context
switch & begin execution of an interrupt handler.
Software interrupt:
Are usually implemented as instruction in instruction set
which cause context switch to an interrupt handler.

O.S Lecture 1 47
Advantages of Interrupts
It is common technique for computer multi-tasking in
real time computing.
Improves processing efficiency.
Helps O.S by reducing time spent in in waiting for I/O
devices to complete their task.
Allows the processor to execute other instructions while
an I/O operation is in progress
A process is suspended in such a way that it can be
resumed later.

O.S Lecture 1 48
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.

O.S Lecture 1 49
Classes of Interrupts
Program
arithmetic overflow
division by zero
execute illegal instruction
reference outside user’s memory space
Timer
I/O
Hardware failure

O.S Lecture 1 50
Interrupt Handler
A program that determines nature of the interrupt and
performs whatever actions are needed
Control is transferred to handler
Generally it’s a part of the operating system

O.S Lecture 1 51
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

O.S Lecture 1 52
Interrupt Cycle

O.S Lecture 1 53
Interrupt Cycle
1. With interrupts, CPU can also execute other
instructions while an I/O is in progress.
2. After execution of each instruction, Processor
checks for interrupts.
3. If no interrupts fetch the next instruction for the
current program
4. If an interrupt is pending, suspend execution of the
current program, and execute the interrupt handler

O.S Lecture 1 54
Multiple Interrupts
1. Sequential Order
Disable interrupts so processor can complete task
Interrupts remain pending until the processor enables
interrupts
After interrupt handler routine completes, the
processor checks for additional interrupts

O.S Lecture 1 55
Multiple Interrupts
2. Priorities
Higher priority interrupts cause lower-priority
interrupts to wait
Causes a lower-priority interrupt handler to be
interrupted
Example when input arrives from communication line,
it needs to be absorbed quickly to make room for
more input

O.S Lecture 1 56
I/O Structure

O.S Lecture 1 57
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 operating system 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.
 Operating system indexes into I/O device table to determine
device status and to modify table entry to include interrupt.

O.S Lecture 1 58
Synchronous Asynchronous

59
Programmed I/O
Synchronous type
I/O module performs the action, not
the processor
Sets appropriate bits in the I/O status
register
No interrupts occur
Processor checks status until
operation is complete

O.S Lecture 1 60
Interrupt-Driven I/O
Asynchronous type
Processor is interrupted when I/O
module ready to exchange data
Processor is free to do other work
No needless waiting
Consumes a lot of processor time
because every word read or
written passes through the
processor

O.S Lecture 1 61
Direct Memory Access
(DMA)
Used for high-speed I/O devices able to transmit information
at close to memory speeds.
I/O exchanges occur directly with memory
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.
Processor grants I/O module authority to read from or write to
memory
Relieves the processor responsibility for the exchange
Processor is free to do other things

O.S Lecture 1 62
Direct Memory Access
Transfers a block of data
directly to or from memory
An interrupt is sent when the
task is complete
The processor is only involved
at the beginning and end of the
transfer

O.S Lecture 1 63
Kernel

O.S Lecture 1 64
O.S Lecture 1 65
Kernel

O.S Lecture 1 66
Kernel
A portion of O.S is always in the main memory, which
is called Kernel or Nucleus. It contains most
frequently used functions and currently used part of
the O.S and memory management.
It is a basic software component of an O.S
responsible for providing secure access to machine’s
hardware to various computer programs.
It provides low level abstraction layer for the
resources (such as memory, CPU & i/o devices) that
application software needs to perform its functions.
Kernel also decides when & how long a program will
use any hardware.
O.S Lecture 1 67
Kernel

O.S Lecture 1 68
ctd……..Kernel
 It make facilities available to application processes through IPC & system calls.

 It is always awake but dormant in the memory. It never sleeps.

 The “Boot Loader” starts executing the kernel then kernel initializes itself and starts
the first process.
 After this, kernel does not execute directly and only response to system calls(by
software) and interrupts (by hardware) to notify the events to kernel.
 Kernel has most frequently used functions.

 Basic facilities of kernel are:


 Process management

 Memory management

 Device management

 Systems Calls

O.S Lecture 1 69
O.S Lecture 1 70
Common O.S
Components
Process Management
Main Memory Management
File Management
I/O System Management
Secondary Management
Networking
Protection System
Command-Interpreter System

O.S Lecture 1 71
Process Management
A process is a program in execution. A process
needs certain resources, including CPU time,
memory, files, and I/O devices, to accomplish its
task.
The operating system is responsible for the
following activities in connection with process
management.
Process creation and deletion.
process suspension and resumption.
Provision of mechanisms for:
 process synchronization
 process communication

O.S Lecture 1 72
Main-Memory
Management
Memory is a large array of words or bytes, each
with its own address. It is a repository of quickly
accessible data shared by the CPU and I/O
devices.
Main memory is a volatile storage device. It loses
its contents in the case of system failure.
The operating system is responsible for the
following activities in connections with memory
management:
Keep track of which parts of memory are currently
being used and by whom.
Decide which processes to load when memory
space becomes available.
Allocate and de-allocate memory space as needed.
O.S Lecture 1 73
File Management
A file is a collection of related information defined by
its creator. Commonly, files represent programs (both
source and object forms) and data.
The operating system is responsible for the following
activities in connections with file management:
File creation and deletion.
Directory creation and deletion.
Support of primitives for manipulating files and
directories.
Mapping files onto secondary storage.
File backup on stable (nonvolatile) storage media.

O.S Lecture 1 74
I/O System
Management
The I/O system consists of:
A buffer-caching system
A general device-driver interface
Drivers for specific hardware devices

O.S Lecture 1 75
Secondary-Storage
Management
Since main memory (primary storage) is volatile and
too small to accommodate all data and programs
permanently, the computer system must provide
secondary storage to back up main memory.
Most modern computer systems use disks as the
principle on-line storage medium, for both programs
and data.
The operating system is responsible for the
following activities in connection with disk
management:
Free space management
Storage allocation
Disk scheduling

76
Networking (Distributed
Systems)
A distributed system is a collection processors that do not
share memory or a clock. Each processor has its own
local memory.
The processors in the system are connected through a
communication network.
Communication takes place using a protocol.
A distributed system provides user access to various
system resources.
Access to a shared resource allows:
 Computation speed-up
 Increased data availability
 Enhanced reliability

O.S Lecture 1 77
Protection System
Protection refers to a mechanism for controlling
access by programs, processes, or users to both
system and user resources.
The protection mechanism must:
distinguish between authorized and unauthorized
usage.
specify the controls to be imposed.
provide a means of enforcement.

O.S Lecture 1 78
Command-Interpreter
System
Many commands are given to the operating system
by control statements which deal with:
process creation and management
I/O handling
secondary-storage management
main-memory management
file-system access
protection
networking

O.S Lecture 1 79
Command-Interpreter
System (Cont.)
The program that reads and interprets control
statements is called variously:

command-line interpreter
shell (in UNIX)

Its function is to get and execute the next command


statement.

O.S Lecture 1 80
System Calls
 System calls provide the interface between a running program and
the operating system.
 Generally available as assembly-language instructions.
 Languages defined to replace assembly language for systems
programming allow system calls to be made directly (e.g., C, C+
+)

 Three general methods are used to pass parameters between a


running program and the operating system.
 Pass parameters in registers.
 Store the parameters in a table in memory, and the table address
is passed as a parameter in a register. (used by Linux)
 Push (store) the parameters onto the stack by the program, and
pop off the stack by operating system.

O.S Lecture 1 81
Types of System Calls
Process control
 end ,abort , load, execute, create & terminate proceess fork()
,wait,get & set process attributes
File management
 Create & delete file, open & close file, read,write
Device management
 Request,release,read,write device

Information maintenance
 Get/set date & time, get/set process/file/device attributes
Communications
 Create/delete comm connection,sen/receive msg,transfer
status info,attach/detach remote devices

O.S Lecture 1 82
Communication may take place using either
message passing or shared memory.

Message Passing Shared Memory


O.S Lecture 1 83
Virtual Machines
virtual machine (VM) is a software implementation
of a machine (computer) that executes programs like
a real machine.
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.
O.S Lecture 1 84
Virtual Machines (Cont.)
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.

O.S Lecture 1 85
Non-virtual Machine Virtual Machine

O.S Lecture 1 86
Advantages/Disadvantages of Virtual
Machines

 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.

 A virtual-machine system is a perfect vehicle for operating-systems

research and development. System development is done on the virtual

machine, instead of on a physical machine and so does not disrupt

normal system operation.

 The virtual machine concept is difficult to implement due to the effort

required to provide an exact duplicate to the underlying machine.

O.S Lecture 1 87

Você também pode gostar