You are on page 1of 54

Chapter 1: Introduction

Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013
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

Operating System Concepts – 9th Edition 1.2 Silberschatz, Galvin and Gagne ©2013
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

Operating System Concepts – 9th Edition 1.3 Silberschatz, Galvin and Gagne ©2013
Four Components of a Computer System

Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne ©2013
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
 Users of dedicate systems such as workstations have dedicated
resources but frequently use shared resources from servers
 Handheld computers are resource poor, optimized for usability
and battery life
 Some computers have little or no user interface, such as
embedded computers in devices and automobiles

Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne ©2013
Operating System Definition

 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

Operating System Concepts – 9th Edition 1.6 Silberschatz, Galvin and Gagne ©2013
Operating System Definition (Cont.)

 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.
 Everything else is either
 a system program (ships with the operating system) , or
 an application program.

Operating System Concepts – 9th Edition 1.7 Silberschatz, Galvin and Gagne ©2013
Computer Startup

 bootstrap program is loaded at power-up or reboot


 Typically stored in ROM or EPROM, generally known
as firmware
 Initializes all aspects of system
 Loads operating system kernel and starts execution

Operating System Concepts – 9th Edition 1.8 Silberschatz, Galvin and Gagne ©2013
Instruction Cycle

An instruction cycle, also known as fetch-decode-execute cycle is the


basic operational process of a computer. This process is repeated
continuously by CPU from boot up to shut down of computer.
Following are the steps that occur during an instruction cycle:
1.Fetch
2.Decode
3.Read
4.Execute

Operating System Concepts – 9th Edition 1.9 Silberschatz, Galvin and Gagne ©2013
Instruction Cycle

Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne ©2013
Instruction Cycle

1. Fetch the Instruction


The instruction is fetched from memory address that is stored in
PC(Program Counter) and stored in the instruction register IR. At the end of
the fetch operation, PC is incremented by 1 and it then points to the next
instruction to be executed.

2. Decode the Instruction


The instruction in the IR is executed by the decoder.

Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne ©2013
Instruction Cycle

3. Read the Effective Address


If the instruction has an indirect address, the effective address is read from
the memory. Otherwise operands are directly read in case of immediate
operand instruction.

4. Execute the Instruction


The Control Unit passes the information in the form of control signals to the
functional unit of CPU. The result generated is stored in main memory or
sent to an output device.

Operating System Concepts – 9th Edition 1.12 Silberschatz, Galvin and Gagne ©2013
Interrupt
 In system programming, an interrupt is a signal to the processor emitted
by hardware or software indicating an event that needs immediate
attention.
 An interrupt alerts the processor to a high-priority condition requiring the
interruption of the current code the processor is executing.
 The processor responds by suspending its current activities, saving its
state, and executing a function called an interrupt handler (or an interrupt
service routine, ISR) to deal with the event.
 This interruption is temporary, and, after the interrupt handler finishes,
unless handling the interrupt has emitted a fatal error, the processor
resumes normal activities

Operating System Concepts – 9th Edition 1.13 Silberschatz, Galvin and Gagne ©2013
Types of Interrupt

Operating System Concepts – 9th Edition 1.14 Silberschatz, Galvin and Gagne ©2013
Types of Interrupt

Hardware Interrupts
When the signal for the processor is from an external device or hardware
then this interrupts is known as hardware interrupt.
Let us consider an example: when we press any key on our keyboard to
do some action, then this pressing of the key will generate an interrupt
signal for the processor to perform certain action. Such an interrupt can be
of two types:
Maskable Interrupt

The hardware interrupts which can be delayed when a much high priority
interrupt has occurred at the same time.
Non Maskable Interrupt

The hardware interrupts which cannot be delayed and should be processed


by the processor immediately.

Operating System Concepts – 9th Edition 1.15 Silberschatz, Galvin and Gagne ©2013
Types of Interrupt
 Software Interrupts
The interrupt that is caused by any internal system of the computer system
is known as a software interrupt. It can also be of two types:

 Normal Interrupt
The interrupts that are caused by software instructions are called normal
software interrupts.

 Exception
Unplanned interrupts which are produced during the execution of some
program are called exceptions, such as division by zero.

Operating System Concepts – 9th Edition 1.16 Silberschatz, Galvin and Gagne ©2013
Memory Hierarchy

In the Computer System Design, Memory Hierarchy is an enhancement to


organize the memory such that it can minimize the access time.

In computer architecture, the memory hierarchy separates computer


storage into a hierarchy based on response time. Since response time,
complexity, and capacity are related, the levels may also be distinguished
by their performance and controlling technologies

Memory hierarchy affects performance in computer architectural design,


algorithm predictions, and lower level programming constructs involving
locality of reference.

Operating System Concepts – 9th Edition 1.17 Silberschatz, Galvin and Gagne ©2013
Memory Hierarchy

Operating System Concepts – 9th Edition 1.18 Silberschatz, Galvin and Gagne ©2013
Memory Hierarchy

This Memory Hierarchy Design is divided into 2 main types:


External Memory or Secondary Memory –
Comprising of Magnetic Disk, Optical Disk, Magnetic Tape i.e. peripheral
storage devices which are accessible by the processor via I/O Module.
Internal Memory or Primary Memory –
Comprising of Main Memory, Cache Memory & CPU registers. This is
directly accessible by the processor

Operating System Concepts – 9th Edition 1.19 Silberschatz, Galvin and Gagne ©2013
Memory Hierarchy

We can infer the following characteristics of Memory Hierarchy Design from


above figure:
Capacity:
It is the global volume of information the memory can store. As we move
from top to bottom in the Hierarchy, the capacity increases.
Access Time:
It is the time interval between the read/write request and the availability of
the data. As we move from top to bottom in the Hierarchy, the access time
increases.

Operating System Concepts – 9th Edition 1.20 Silberschatz, Galvin and Gagne ©2013
Memory Hierarchy
 Performance:
Earlier when the computer system was designed without Memory
Hierarchy design, the speed gap increases between the CPU registers
and Main Memory due to large difference in access time. This results in
lower performance of the system and thus, enhancement was required.
This enhancement was made in the form of Memory Hierarchy Design
because of which the performance of the system increases. One of the
most significant ways to increase system performance is minimizing how
far down the memory hierarchy one has to go to manipulate data.
 Cost per bit:
As we move from bottom to top in the Hierarchy, the cost per bit
increases i.e. Internal Memory is costlier than External Memory.

Operating System Concepts – 9th Edition 1.21 Silberschatz, Galvin and Gagne ©2013
Cache Memory
 Cache Memory is a special very high-speed memory. It is used to speed up
and synchronizing with high-speed CPU. Cache memory is costlier than main
memory or disk memory but economical than CPU registers. Cache memory is
an extremely fast memory type that acts as a buffer between RAM and the
CPU. It holds frequently requested data and instructions so that they are
immediately available to the CPU when needed.
 Cache memory is used to reduce the average time to access data from the
Main memory. The cache is a smaller and faster memory which stores copies
of the data from frequently used main memory locations. There are various
different independent caches in a CPU, which stored instruction and data.

Operating System Concepts – 9th Edition 1.22 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 1.23 Silberschatz, Galvin and Gagne ©2013
Levels of memory
 Levels of memory:
 Level 1 or Register –
It is a type of memory in which data is stored and accepted that are
immediately stored in CPU. Most commonly used register is accumulator,
Program counter, address register etc.
 Level 2 or Cache memory –
It is the fastest memory which has faster access time where data is
temporarily stored for faster access.
 Level 3 or Main Memory –
It is memory on which computer works currently it is small in size and once
power is off data no longer stays in this memory
 Level 4 or Secondary Memory –
It is external memory which is not fast as main memory but data stays
permanently in this memory

Operating System Concepts – 9th Edition 1.24 Silberschatz, Galvin and Gagne ©2013
 Level 1 (L1) cache or Primary Cache
L1 is the primary type cache memory. The Size of the L1 cache very small
comparison to others that is between 2KB to 64KB, it depend on computer
processor. It is a embedded register in the computer
microprocessor(CPU).The Instructions that are required by the CPU that
are  firstly searched in L1 Cache. Example of registers are accumulator,
address register,, Program counter etc.

 Level 2 (L2) cache or Secondary Cache


L2 is secondary type cache memory. The Size of the L2 cache is more
capacious than L1 that is between 256KB to 512KB. L2 cache is Located
on computer microprocessor. After searching the Instructions in L1 Cache, if
not found then it searched into L2 cache by computer microprocessor. The
high-speed system bus interconnecting the cache to the microprocessor.

Operating System Concepts – 9th Edition 1.25 Silberschatz, Galvin and Gagne ©2013
 Level 3 (L3) cache or Main Memory
The L3 cache is larger in size but also slower in speed than L1 and L2,it's
size is between 1MB to 8MB.In Multicore processors, each core may have
separate L1 and L2,but all core share a common L3 cache. L3 cache double
speed than the RAM.

Operating System Concepts – 9th Edition 1.26 Silberschatz, Galvin and Gagne ©2013
Modes of Transfer
Mode of Transfer:
The binary information that is received from an external device is usually stored
in the memory unit. The information that is transferred from the CPU to the
external device is originated from the memory unit. CPU merely processes the
information but the source and target is always the memory unit. Data transfer
between CPU and the I/O devices may be done in different modes.
Data transfer to and from the peripherals may be done in any of the three
possible ways
Programmed I/O.
Interrupt- initiated I/O.
Direct memory access( DMA).

Operating System Concepts – 9th Edition 1.27 Silberschatz, Galvin and Gagne ©2013
Programmed I/O
Programmed I/O:
 It is due to the result of the I/O instructions that are written in the computer
program. Each data item transfer is initiated by an instruction in the program.
Usually the transfer is from a CPU register and memory. In this case it requires
constant monitoring by the CPU of the peripheral devices
Example of Programmed I/O:
 In this case, the I/O device does not have direct access to the memory unit. A
transfer from I/O device to memory requires the execution of several
instructions by the CPU, including an input instruction to transfer the data from
device to the CPU and store instruction to transfer the data from CPU to
memory. In programmed I/O, the CPU stays in the program loop until the I/O
unit indicates that it is ready for data transfer. This is a time consuming process
since it needlessly keeps the CPU busy.

Operating System Concepts – 9th Edition 1.28 Silberschatz, Galvin and Gagne ©2013
Interrupt- initiated I/O
Interrupt- initiated I/O:
 Since in the above case we saw the CPU is kept busy unnecessarily. This
situation can very well be avoided by using an interrupt driven method for data
transfer. By using interrupt facility and special commands to inform the interface
to issue an interrupt request signal whenever data is available from any device.
In the meantime the CPU can proceed for any other program execution. The
interface meanwhile keeps monitoring the device. Whenever it is determined
that the device is ready for data transfer it initiates an interrupt request signal to
the computer. Upon detection of an external interrupt signal the CPU stops
momentarily the task that it was already performing, branches to the service
program to process the I/O transfer, and then return to the task it was originally
performing.

Operating System Concepts – 9th Edition 1.29 Silberschatz, Galvin and Gagne ©2013
Both the methods programmed I/O and Interrupt-driven I/O require the active
intervention of the processor to transfer data between memory and the I/O
module, and any data transfer must transverse a path through the processor.
Thus both these forms of I/O suffer from two inherent drawbacks.
 The I/O transfer rate is limited by the speed with which the processor
can test and service a device.
 The processor is tied up in managing an I/O transfer; a number of
instructions must be executed for each I/O transfer.

Operating System Concepts – 9th Edition 1.30 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access:
Direct Memory Access:
DMA is a method of transferring data from the computer's RAM to another part
of the computer without processing it using the CPU. While most data that is
input or output from your computer is processed by the CPU, some data does
not require processing, or can be processed by another device. In these
situations, DMA can save processing time and is a more efficient way to move
data from the computer's memory to other devices.

For example, a sound card may need to access data stored in the computer's
RAM, but since it can process the data itself, it may use DMA to bypass the
CPU. Video cards that support DMA can also access the system memory and
process graphics without needing the CPU

Operating System Concepts – 9th Edition 1.31 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access:

Direct Memory Access:

Operating System Concepts – 9th Edition 1.32 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access:

Operating System Concepts – 9th Edition 1.33 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access:

Operating System Concepts – 9th Edition 1.34 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access:
Bus Request :
It is used by the DMA controller to request the CPU to relinquish the control of
the buses.
Bus Grant :
 It is activated by the CPU to Inform the external DMA controller that the buses
are in high impedance state and the requesting DMA can take control of the
buses. Once the DMA has taken the control of the buses it transfers the data.
This transfer can take place in many ways.

Operating System Concepts – 9th Edition 1.35 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access:
Types of DMA transfer using DMA controller:
Burst Transfer :
DMA returns the bus after complete data transfer. A register is used as a byte count,
being decremented for each byte transfer, and upon the byte count reaching zero, the
DMAC will release the bus. When the DMAC operates in burst mode, the CPU is
halted for the duration of the data transfer.
Steps involved are:
 Bus grant request time.
 Transfer the entire block of data at transfer rate of device because the device is
usually slow than the speed at which the data can be transferred to CPU.
 Release the control of the bus back to CPU
So, total time taken to transfer the N bytes
= Bus grant request time + (N) * (memory transfer rate) + Bus release control
time.

Operating System Concepts – 9th Edition 1.36 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access:
Cyclic Stealing :
In this DMA controller transfers one word at a time after which it must return the
control of the buses to the CPU. The CPU merely delays its operation for one
memory cycle to allow the direct memory I/O transfer to “steal” one memory cycle.
Steps Involved are:
 Buffer the byte into the buffer
 Inform the CPU that the device has 1 byte to transfer (i.e. bus grant request)
 Transfer the byte (at system bus speed)
 Release the control of the bus back to CPU.

Operating System Concepts – 9th Edition 1.37 Silberschatz, Galvin and Gagne ©2013
Types of Operating Systems
Following are some of the most widely used types of Operating system.
1.Simple Batch System
2.Multiprogramming Batch System
3.Multiprocessor System
4.Desktop System
5.Distributed Operating System
6.Clustered System
7.Realtime Operating System
8.Handheld System

Operating System Concepts – 9th Edition 1.38 Silberschatz, Galvin and Gagne ©2013
Batch Operating System
 In this type of system, there is no direct interaction between
user and the computer.
 The user has to submit a job (written on cards or tape) to a
computer operator.
 Then computer operator places a batch of several jobs on an input
device.
 Jobs are batched together by type of languages and requirement.
 Then a special program, the monitor, manages the execution of
each program in the batch.
 The monitor is always in the main memory and available for
execution.

Advantages of Simple Batch Systems


 No interaction between user and computer.
 No mechanism to prioritise the processes.

Operating System Concepts – 9th Edition 1.39 Silberschatz, Galvin and Gagne ©2013
Multiprogramming Operating System
 In this the operating system picks up and begins to execute one of the jobs
from memory.
 Once this job needs an I/O operation operating system switches to another job
(CPU and OS always busy).
 Jobs in the memory are always less than the number of jobs on disk(Job Pool).
 If several jobs are ready to run at the same time, then the system chooses
which one to run through the process of CPU Scheduling.
 In Non-multiprogrammed system, there are moments when CPU sits idle and
does not do any work.
 In Multiprogramming system, CPU will never be idle and keeps on processing.
 Time Sharing Systems are very similar to Multiprogramming batch systems. In
fact time sharing systems are an extension of multiprogramming systems.
 In Time sharing systems the prime focus is on minimizing the response time,
while in multiprogramming the prime focus is to maximize the CPU usage.

Operating System Concepts – 9th Edition 1.40 Silberschatz, Galvin and Gagne ©2013
Multiprogramming Operating System

Operating System Concepts – 9th Edition 1.41 Silberschatz, Galvin and Gagne ©2013
Multiprocessor Systems
A Multiprocessor system consists of several processors that share a common
physical memory. Multiprocessor system provides higher computing power and
speed. In multiprocessor system all processors operate under single operating
system. Multiplicity of the processors and how they do act together are transparent
to the others.

Advantages of Multiprocessor Systems


Enhanced performance
Execution of several tasks by different processors concurrently, increases the
system's throughput without speeding up the execution of a single task.
If possible, system divides task into many subtasks and then these subtasks can
be executed in parallel in different processors. Thereby speeding up the execution
of single tasks.

Operating System Concepts – 9th Edition 1.42 Silberschatz, Galvin and Gagne ©2013
Desktop Systems

PC operating systems therefore were neither multiuser nor multitasking.


However, the goals of these operating systems have changed with time;
instead of maximizing CPU and peripheral utilization, the systems opt for
maximizing user convenience and responsiveness.

Operating System Concepts – 9th Edition 1.43 Silberschatz, Galvin and Gagne ©2013
Distributed System

 The motivation behind developing distributed operating systems is the


availability of powerful and inexpensive microprocessors and advances
in communication technology.
 These advancements in technology have made it possible to design and
develop distributed systems comprising of many computers that are inter
connected by communication networks. The main benefit of distributed
systems is its low price/performance ratio.
Types of Distributed Operating Systems
Following are the two types of distributed operating systems used:
1. Client-Server Systems
2. Peer-to-Peer Systems

Operating System Concepts – 9th Edition 1.44 Silberschatz, Galvin and Gagne ©2013
Common Functions of Interrupts

 Centralized systems today act as server systems to


satisfy requests generated by client systems. Server
Systems can be broadly categorized as: Compute
Servers and File Servers.
 Compute Server systems, provide an interface to which
clients can send requests to perform an action, in response
to which they execute the action and send back results to
the client.
 File Server systems, provide a file-system interface where
clients can create, update, read, and delete files.

Operating System Concepts – 9th Edition 1.45 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 1.46 Silberschatz, Galvin and Gagne ©2013
  the computer networks used in these applications consist of a collection of
processors that do not share memory or a clock. Instead, each processor
has its own local memory. The processors communicate with one another
through various communication lines, such as high-speed buses or
telephone lines. These systems are usually referred to as loosely coupled
systems ( or distributed systems)

Operating System Concepts – 9th Edition 1.47 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 1.48 Silberschatz, Galvin and Gagne ©2013
Kernel
 A kernel is the core component of an operating system. Using interprocess
communication and system calls, it acts as a bridge between applications
and the data processing performed at the hardware level.
 When an operating system is loaded into memory, the kernel loads first and
remains in memory until the operating system is shut down again. The
kernel is responsible for low-level tasks such as disk management, task
management and memory management.
 A computer kernel interfaces between the three major computer hardware
components, providing services between the application/user interface and
the CPU, memory and other hardware I/O devices.

Operating System Concepts – 9th Edition 1.49 Silberschatz, Galvin and Gagne ©2013
The kernel is responsible for:

1.Process management for application execution


2.Memory management, allocation and I/O
3.Device management through the use of device drivers
4.System call control, which is essential for the execution of kernel services

Operating System Concepts – 9th Edition 1.50 Silberschatz, Galvin and Gagne ©2013
Kernel vs OS
BASIS FOR
KERNEL OPERATING SYSTEM
COMPARISON
Basic Kernel is an important part of the operating system. Operating System is a system program.

Interface Kernel is an interface between software and hardware of the Operating System is an interface
computer. between user and hardware of the
computer.

Type Monolithic kernels and Microkernels. Single and Multiprogramming batch


system, Distributed operating system,
Realtime operating system.

Purpose Kernel memory management, process management, task In addition to the responsibilities of
management, disk management. Kernel, Operating System is
responsible for protection and security
of the computer.

Operating System Concepts – 9th Edition 1.51 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 1.52 Silberschatz, Galvin and Gagne ©2013
Types of Kernels
 Monolithic Kernels: All operating system services run along the main kernel
thread in a monolithic kernel, which also resides in the same memory area,
thereby providing powerful and rich hardware access.
 Microkernels: Define a simple abstraction over hardware that use primitives
or system calls to implement minimum OS services such as multitasking,
memory management and interprocess communication.
 Hybrid Kernels: Run a few services in the kernel space to reduce the
performance overhead of traditional microkernels where the kernel code is
still run as a server in the user space.
 Nano Kernels: Simplify the memory requirement by delegating services,
including the basic ones like interrupt controllers or timers to device drivers.
 Exo Kernels: Allocate physical hardware resources such as processor time
and disk block to other programs, which can link to library operating
systems that use the kernel to simulate operating system abstractions.

Operating System Concepts – 9th Edition 1.53 Silberschatz, Galvin and Gagne ©2013
End of Chapter 1

Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013

You might also like