0% found this document useful (0 votes)
17 views54 pages

OS Ch-1 16092024

Uploaded by

taliqa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views54 pages

OS Ch-1 16092024

Uploaded by

taliqa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 54

CHAPTER 1

INTRODUCTION
INTRODUCTION

• What Operating Systems (OS) Do

• Computer-System Organization

• Computer-System Architecture

• Operating-System Operations

• Resource Management

• Security and Protection

• Virtualization

• Distributed Systems

• Kernel Data Structures

• Computing Environments

• Free/Libre and Open-Source Operating Systems


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
• Provide examples of free and open-source operating systems
WHAT DOES THE TERM OPERATING SYSTEM MEAN?

• An operating system is “fill in the blanks”


• What about:

Car

Airplane

Printer

Washing Machine

Toaster

Compiler

Etc.
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 (MS word, calculator, Skype, Whatsapp, FB,


Chrome, phone call, etc) 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, Secondary storage

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

o Machine User: For example a client/workstation uses the services provided by the
server
o For example, My computer is connected to the FB server so my computer is the
acting as a user
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
• Users of dedicate systems such as workstations have dedicated
resources but frequently use shared resources from servers
• Mobile devices like smartphones 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 countless 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
WHAT IS OPERATING SYSTEM?
• No universally accepted definition

“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) like
WIFI, Bluetooth, Calling a printer etc. OR
 An application program (browser, MS power point etc.), all programs not
associated with the operating system

 OS is a Resource Allocator
 Manage all resources (RAM, CPU, H/D etc.)

 Decides b/w conflicting request for efficient and fair use

OS is a Control Program


 Control execution of the programs to prevent errors and improper use of computer
Overview of Computer System Structure
COMPUTER SYSTEM ORGANIZATION

• Computer-system operation

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
COMPUTER SYSTEM ORGANIZATION

• A bus, in computing and digital technology, is an electronic pathway


through which data can be transferred.
• This pathway uses signals that move at different speeds and are sent
through different channels to communicate information between
components within a computer or network.
• The most common types of buses include

 System buses: Transfer data between the CPU and main memory

 Local buses: Connect various internal peripherals such as a printer


or hard drive to the system board
 Peripheral buses: Connect external devices such as keyboards,
mice, and monitors to your computer
COMPUTER-SYSTEM OPERATION
• I/O devices and the CPU can execute concurrently (at the same time)
• Each device controller is in charge of a particular device type
• Each device controller has a local buffer (small memory available for
transfer/copying/storage, few KBs/MBs)
• Each device controller type has an operating system device driver to
manage it
• 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
• A device driver is an operating system-specific and
hardware-dependent program, and it offers to
interrupt handling

• A device controller is a circuit board that interfaces


between the device and the OS.
• An interface between OS and I/O device
INTERRUPTS
• An OS is interrupt-driven
• H/W or S/W can generate an interrupt any time
• It is a signal to the CPU
• The CPU stops temporarily what it is doing and start execution the
interrupt by executing a special operation called a System Call or Monitor
Call
• In I/O devices, one of the bus control lines is dedicated for this purpose
and is called the Interrupt Service Routine (ISR).

Source: Javapoint Tutorial


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
INTERRUPT TIMELINE
INTERRUPT HANDLING/ REQUEST
• Devices raise an Interrupt Request (IRQ).
• The processor interrupts the program currently being executed.
• The device is informed that its request has been recognized and the device
deactivates the request signal.
• The requested action is performed.
• An interrupt is enabled and the interrupted program is resumed.

Source: GeeksforGeeks Tutorial


INTERRUPT HANDLING/ REQUEST

Source: GeeksforGeeks Tutorial


INTERRUPT HANDLING/ REQUEST STEPS

1. Any time that an interrupt is raised, it may either be an I/O interrupt


or a system interrupt.
2. The current state comprising registers and the program counter is
then stored in order to conserve the state of the process.
3. The current interrupt and its handler is identified through the
interrupt vector table in the processor.
4. This control now shifts to the interrupt handler, which is a function
located in the kernel space.
5. Specific tasks are performed by Interrupt Service Routine (ISR)
which are essential to manage interrupt.
6. The status from the previous session is retrieved so as to build on
the process from that point.
7. The control is then shifted back to the other process that was
pending and the normal process continues.
INTERRUPT HANDLING/ REQUEST STEPS

• The interrupt handling process consists of several steps:


Interrupt request: The device or program sends an interrupt request to the processor.

Interrupt service routine (ISR): The processor saves its current state and jumps to the

appropriate ISR. The ISR is a piece of code that handles the interrupt and performs
any necessary actions.
Interrupt masking: While the ISR is executing, the processor may mask (disable)

other interrupts to prevent them from interfering with the current ISR.
Interrupt acknowledgment: Once the ISR is complete, the processor sends an

acknowledgment signal to the device or program to indicate that the interrupt has
been handled.
Interrupt unmasking: The processor then unmasks (enables) any interrupts that were

previously masked.
Return from ISR: The processor returns to the point in the program where it was

interrupted and continues executing.


INTERRUPT-DRIVE I/O CYCLE
I/O STRUCTURE

• I/O Structure consists of


 Programmed I/O

 Interrupt driven I/O

 DMS

 CPU

 Memory

 External devices,

• These are all connected with the help of Peripheral I/O Buses and
General I/O Buses.

• Device Controller: A h/w components that works a bridge between h/w


and OS

• Device Driver: A piece of s/w that enables device (I/O) to communicate


with OS
I/O STRUCTURE: MODE OF TRANSFER

• Programmed I/O (PIO)

The CPU run programs periodically and checks the status of each
device one-by-one
When we write the input then the device should be ready to take the
data otherwise the program should wait for some time so that the device
or buffer will be free then it can take the input.
Once the input is taken then it will be checked whether the output device
or output buffer is free then it will be printed.
 This process is continued every time in transferring of the data.

A protocol for data transfer, Since it involves the CPU, the use of PIO
mode for data transfer can slow a computer down considerably.
I/O STRUCTURE: MODE OF TRANSFER
I/O STRUCTURE: MODE OF TRANSFER
I/O STRUCTURE: MODE OF TRANSFER

• I/O Interrupt

To initiate any I/O operation, the CPU first loads the registers to the
device controller. Then the device controller checks the contents of the
registers to determine what operation to perform.
There are two possibilities if I/O operations want to be executed. These
are as follows
 Synchronous I/O − The control is returned to the user process after the
I/O process is completed.
 Asynchronous I/O − The control is returned to the user process without
waiting for the I/O process to finish. Here, I/O process and the user
process run simultaneously.
I/O STRUCTURE: MODE OF TRANSFER
• I/O Interrupt

After the transfer is complete, CPU returns to the previous task it was
executing.
The branch address of the service can be chosen in two ways known as
vectored and non-vectored interrupt.
 In vectored interrupt, the source that interrupts, supplies the branch
information to the CPU while in case of non-vectored interrupt the branch
address is assigned to a fixed location in memory.
 For example: a microcontroller can be interrupted by a sensor when it has
a new value, or by a serial port when it receives data
I/O STRUCTURE: MODE OF TRANSFER
• I/O Interrupt

After the transfer is complete, CPU returns to the previous task it was executing.

Interface as converter or
interfaces
Register….give the data
parallel to CPU and get
serially

To synchronize the speed


between peripheral
devices and Processor

 Speed

Why Interface?  To convert signals from electromechanically to electrical


 To match the data format
I/O STRUCTURE: MODE OF TRANSFER
I/O STRUCTURE: MODE OF TRANSFER
I/O STRUCTURE: MODE OF TRANSFER

• Direct Memory Access (DMA)

 A method of handling I/O. Here the device controller directly


communicates with memory without CPU involvement.
 After setting the resources of I/O devices like buffers, pointers, and
counters, the device controller transfers blocks of data directly to
storage without CPU intervention I/O devices.
 Network cards, graphics cards, device drivers, and storage
controllers can directly access memory locations without constant
intervention from the processor
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

 The process of transferring data without the involvement of the


processor itself.
• Only one interrupt is generated per block, rather than the one
interrupt per byte

Advantages of DMA Controller

• Data Memory Access speeds up memory operations and data


transfer.
• CPU is not involved while transferring data.
• DMA requires very few clock cycles while transferring data.
• DMA distributes workload very appropriately.
• DMA helps the CPU in decreasing its load.
DIRECT MEMORY ACCESS STRUCTURE

• DMA Controller is a hardware device that allows I/O devices to directly


access memory with less participation of the processor.
• DMA controller needs the same old circuits of an interface to
communicate with the CPU and Input/Output devices.
• Direct Memory Access uses hardware for accessing the memory, that
hardware is called a DMA Controller
• It has the work of transferring the data between Input Output devices and
main memory with very less interaction with the processor
• The direct Memory Access Controller is a control unit, which has the work
of transferring data.
DIRECT MEMORY ACCESS STRUCTURE
DIRECT MEMORY ACCESS STRUCTURE
I/O STRUCTURE: MODE OF TRANSFER

• 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
Storage Structure
STORAGE STRUCTURE

• Main memory – only large storage media that the CPU can access directly

 Random access
 Typically volatile

 Typically random-access memory in the form of Dynamic Random-access Memory


(DRAM)
• Secondary storage – extension of main memory that provides large nonvolatile storage capacity
• A solid-state drive (SSD)

 A semiconductor-based storage device, Solid-state technology is transforming the storage with high
speed flash memory.
 Non-volatile storage

 Replace traditional hard disk drives (HDDs) in computers and perform the same basic functions as a
hard drive.
 Significantly faster in comparison. With an SSD, the device's operating system will boot up more
rapidly, programs will load quicker and files can be saved faster.
STORAGE STRUCTURE

• Primary Storage

 Primary storage is also known as the main memory and is the memory directly
accessible by the CPU. Some primary storage devices are −
• ROM

ROM is read only memory. This memory cannot be changed, it can only be read as
required.
 Since ROM is unchangeable memory, it is used by data and programs that are
frequently required and seldom changed, like the system boot program
• Cache Memory

Cache is used to store data and instructions that are frequently required by the CPU
so it doesn't have to search them in the main memory.
 A small memory that is also very fast.
STORAGE STRUCTURE (CONT.)

• Hard Disk Drives (HDD) – 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
• Non-volatile memory (NVM) devices– faster than hard disks,
nonvolatile

Various technologies

Becoming more popular as capacity and performance increases, price


drops
STORAGE STRUCTURE (CONT.)

• Hard Disk Drives (HDD) – 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
• Non-volatile memory (NVM) devices– faster than hard disks, nonvolatile
 Various technologies
 Becoming more popular as capacity and performance increases, price drops
STORAGE STRUCTURE (CONT.)
• Bit

 The binary number 1 or 0 is called a bit (for binary digit), which is the basic unit for storing
data in the computer memory.
 The circuit being on or off at a time, a bit in the memory is always storing some kind of
data.
• Byte

 A byte is a combination of 8-bits, that can store a single character of data (a letter,
numeral or special character).
 The capacity if the memory of the storage is expressed in terms of number of bytes it can
hold or store.
• Word

 The size of the register, is defined as the number of bits that constitute a common unit of
data
 The length of a word varies from computer to computer. Generally, the larger the word, the
more powerful is the computer.
STORAGE DEFINITIONS AND NOTATION REVIEW
STORAGE DEFINITIONS AND NOTATION REVIEW
STORAGE DEFINITIONS AND NOTATION REVIEW
STORAGE HIERARCHY
• Storage systems organized in hierarchy

Speed
Cost
Volatility
• Caching – copying information into faster storage system;
main memory can be viewed as a cache for secondary
storage
• Device Driver for each device controller to manage I/O

Provides uniform interface between controller and kernel


OVERVIEW OF MASS-STORAGE STRUCTURE
• Bulk of secondary storage for modern computers is hard disk drives
(HDDs) and nonvolatile memory (NVM) devices
• HDDs spin platters of magnetically-coated material under moving
read/write heads

 Drives rotate at 60 to 250 times per second

 Transfer rate is rate at which data flow between drive and computer

 Positioning time (random-access time) is time to move disk arm to desired


cylinder (seek time) and time for desired sector to rotate under the disk head
(rotational latency)
Head crash results from disk head making contact with the disk surface --
That’s bad
• Disks can be removable
STORAGE HIERARCHY
• Storage systems organized in hierarchy

Speed

Cost

Volatility
• Cache Memory

A form of random access memory (RAM) that stores recently


accessed data for quick retrieval.
Copying information into faster storage system; main memory
can be viewed as a cache for secondary storage
• Device Driver for each device controller to manage I/O

Provides uniform interface between controller and kernel


STORAGE HIERARCHY
STORAGE-DEVICE HIERARCHY
HOW A MODERN COMPUTER WORKS

Components:
 CPU
 Buses (A,D,C)
 Memory Unit

A von Neumann architecture

(Stored Memory Architecture)

1. Device driver loads controller register with instruction


2. Controller examines register content.
3. Controller transfer data from device to its local buffer
4. Controller informs device driver with an interrupt
5. Driver returns control to OS. Interplay of all components of a
computer system
HOW A MODERN COMPUTER WORKS
A von Neumann architecture (Stored Memory Architecture)

1. Timing Signal
2. Control Signal
OPERATING-SYSTEM OPERATIONS
• Bootstrap program – simple code to initialize the system, load
the kernel
• Kernel loads
• Starts system daemons (services provided outside of the
kernel)
• Kernel interrupt driven (hardware and software)
Hardware interrupt by one of the devices
Software interrupt (exception or trap):
 Software error (e.g., division by zero)
 Request for operating system service – system call
 Other process problems include infinite loop, processes modifying
each other or the operating system

You might also like