[go: up one dir, main page]

0% found this document useful (0 votes)
67 views49 pages

Interrupts

An interrupt is a signal that causes the CPU to stop executing the current program and switch to an interrupt handler routine. There are different types of interrupts including program, timer, I/O, and hardware failure interrupts. When an interrupt occurs, the program counter is stored and loaded with the interrupt service routine address. After the ISR completes, execution resumes from where it left off. Operating systems support multiple interrupts through prioritization or disabling interrupts during processing.

Uploaded by

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

Interrupts

An interrupt is a signal that causes the CPU to stop executing the current program and switch to an interrupt handler routine. There are different types of interrupts including program, timer, I/O, and hardware failure interrupts. When an interrupt occurs, the program counter is stored and loaded with the interrupt service routine address. After the ISR completes, execution resumes from where it left off. Operating systems support multiple interrupts through prioritization or disabling interrupts during processing.

Uploaded by

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

Interrupts

An interrupt is a signal from a device attached to a


computer or from a program within the computer that
requires the operating system to stop and figure out what
to do next.
Classes of interrupts
● Program
● Timer
● I/O
● Hardware Failure
Processor handle interrupts

Whenever an interrupt occurs, it causes the CPU to stop executing the current
program. Then, comes the control to interrupt handler or interrupt service routine.

These are the steps in which ISR handles interrupts. These are as follows −

Step 1 − When an interrupt occurs let assume processor is executing i'th


instruction and program counter will point to the next instruction (i+1)th.

Step 2 − When an interrupt occurs the program value is stored on the process
stack and the program counter is loaded with the address of interrupt service
routine.
Step 3 − Once the interrupt service routine is completed the address on the
process stack is popped and placed back in the program counter.

Step 4 − Now it executes the resume for (i+1)th line.


Multiple interrupts
Two approaches can be taken to dealing with multiple interrupts:
● Disabling interrupts while an interrupt is being processed.

● Defining priorities for interrupts.


Memory hierarchy
•The Computer memory hierarchy looks like a pyramid structure
which is used to describe the differences among memory types. It
separates the computer storage based on hierarchy.

•Level 0: CPU registers


•Level 1: Cache memory
•Level 2: Main memory or primary memory
•Level 3: Magnetic disks or secondary memory
•Level 4: Optical disks or magnetic types or tertiary Memory
What is an Operating System?

•An operating system acts as an intermediary between the user of a computer and
computer hardware. The purpose of an operating system is to provide an
environment in which a user can execute programs conveniently and efficiently.
•An operating system (OS) is system software that manages computer hardware,
software resources, and provides common services for computer programs.
•A more common definition is that the operating system is the one program
running at all times on the computer (usually called the kernel), with all else being
application programs.
Objectives of Operating system

•Convenience: An OS makes a computer more convenient to use.


•Efficiency: An OS allows the computer system resources to be used efficiently.
•Ability to Evolve: An OS should be constructed in such a way as to permit the
effective development, testing, and introduction of new system functions at the
same time without interfering with service.
•Throughput: An OS should be constructed so that It can give maximum
throughput(Number of tasks per unit time).
Feature of OS
Here is a list of some significant functions of an Operating System, which is found common, is almost all
operating system:
•Memory Management
•Processor Managing
•Device Managing
•File handling
•Security Handling
•System performance controlling
•Job accounting and handling
•Error detecting and handling
•Synchronization with other software and users
Functions of an operating System
1.Security – The operating system uses password protection to protect user data and similar other
techniques. it also prevents unauthorized access to programs and user data.
2.Control over system performance – Monitors overall system health to help improve performance.
records the response time between service requests and system response to having a complete view of
the system health. This can help improve performance by providing important information needed to
troubleshoot problems.
3.Job accounting – Operating system Keeps track of time and resources used by various tasks and users,
this information can be used to track resource usage for a particular user or group of users.
4.Error detecting aids – The operating system constantly monitors the system to detect errors and avoid
the malfunctioning of a computer system.
5.Coordination between other software and users – Operating systems also coordinate and assign
interpreters, compilers, assemblers, and other software to the various users of the computer systems.
6.Memory Management –
•The operating system manages the Primary Memory or Main Memory. Main memory is made up of a
large array of bytes or words where each byte or word is assigned a certain address. Main memory is fast
storage and it can be accessed directly by the CPU. For a program to be executed, it should be first
loaded in the main memory. An Operating System performs the following activities for memory
management:
•It keeps track of primary memory, i.e., which bytes of memory are used by which user program. The
memory addresses that have already been allocated and the memory addresses of the memory that has
not yet been used. In multiprogramming, the OS decides the order in which processes are granted access
to memory, and for how long. It Allocates the memory to a process when the process requests it and
deallocates the memory when the process has terminated or is performing an I/O operation.
7.Processor Management –
•In a multiprogramming environment, the OS decides the order in which processes have access to the
processor, and how much processing time each process has. This function of OS is called process
scheduling. An Operating System performs the following activities for processor management.
•Keeps track of the status of processes. The program which performs this task is known as a traffic
controller. Allocates the CPU that is a processor to a process. De-allocates processor when a process is
no more required.
8.Device Management –
•An OS manages device communication via their respective drivers. It performs the following activities for
device management. Keeps track of all devices connected to the system. designates a program
responsible for every device known as the Input/Output controller. Decides which process gets access to
a certain device and for how long. Allocates devices in an effective and efficient way. Deallocates devices
when they are no longer required.
9.File Management –
•A file system is organized into directories for efficient or easy navigation and usage. These directories
may contain other directories and other files. An Operating System carries out the following file
management activities. It keeps track of where information is stored, user access settings and status of
every file, and more… These facilities are collectively known as the file system.
Evolution of OS-Serial
•Since 1950, the operating system started to be in use. Before 1950, there were no operating systems,
and programmers had to directly communicate with the hardware. And before 1950, if a programmer
wants to execute the programs, the programmer had to follow the following steps:
•First, type a program or punched card.
•Translate the punch card into a card reader.
•The translated card reader is submitted to the computer, and if any error has occurred, then with the help
of the light, an error is indicated.
•The Programmer looks at the main memory and register to verify the reason behind the error.
•Then outputs are taken from the printers.
•Then the program is ready to execute another program.
Drawback of Serial Processing
•The serial processing is tough for the users because, in serial processing, more time is required. The
user cannot start executing another program if the previous program does not complete its execution. In
serial processing, the programs are submitted to the computer one-by-one. That’s the reason behind the
name of serial processing.
Batch processing
Batch processing is a technique in which an Operating System collects the programs and data together in a batch
before processing starts. An operating system does the following activities related to batch processing −
• The OS defines a job which has predefined sequence of commands, programs and data as a single unit.
• The OS keeps a number a jobs in memory and executes them without any manual information.
• Jobs are processed in the order of submission, i.e., first come first served fashion.
• When a job completes its execution, its memory is released and the output for the job gets copied into an output
spool for later printing or processing.
Advantages
•Batch processing takes much of the work of the operator to the computer.
•Increased performance as a new job get started as soon as the previous job is finished, without
any manual intervention.
Disadvantages
•Difficult to debug program.
•A job could enter an infinite loop.
•Due to lack of protection scheme, one batch job can affect pending jobs.
Multitasking/Time sharing
Multitasking is when multiple jobs are executed by the CPU simultaneously by switching between them. Switches occur
so frequently that the users may interact with each program while it is running. An OS does the following activities
related to multitasking −
• The user gives instructions to the operating system or to a program directly, and receives an immediate response.
• The OS handles multitasking in the way that it can handle multiple operations/executes multiple programs at a time.
• Multitasking Operating Systems are also known as Time-sharing systems.
• These Operating Systems were developed to provide interactive use of a computer system at a reasonable cost.
• A time-shared operating system uses the concept of CPU scheduling and multiprogramming to provide each user
with a small portion of a time-shared CPU.
• Each user has at least one separate program in memory.
• A program that is loaded into memory and is executing is commonly referred to as a process.
• When a process executes, it typically executes for only a very short time before it either finishes or needs to perform I/O.
• Since interactive I/O typically runs at slower speeds, it may take a long time to complete. During this time, a CPU can be
utilized by another process.
• The operating system allows the users to share the computer simultaneously. Since each action or command in a time-shared
system tends to be short, only a little CPU time is needed for each user.
• As the system switches CPU rapidly from one user/program to the next, each user is given the impression that he/she has his/her
own CPU, whereas actually one CPU is being shared among many users.
Multiprogramming
● Sharing the processor, when two or more programs reside in memory at the same
time, is referred as multiprogramming. Multiprogramming assumes a single shared
processor. Multiprogramming increases CPU utilization by organizing jobs so that the
CPU always has one to execute.
● The following figure shows the memory layout for a multiprogramming system.
● An OS does the following activities related to
multiprogramming.
• The operating system keeps several jobs in memory at a time.
• This set of jobs is a subset of the jobs kept in the job pool.
• The operating system picks and begins to execute one of the
jobs in the memory.
• Multiprogramming operating systems monitor the state of all
active programs and system resources using memory
management programs to ensures that the CPU is never idle,
unless there are no jobs to process.
● Advantages
• High and efficient CPU utilization.
• User feels that many programs are allotted CPU almost
simultaneously.
● Disadvantages
• CPU scheduling is required.
• To accommodate many jobs in memory, memory management is
required.
Real-Time Operating System
● A real-time operating system (RTOS) is intended to serve real-time applications that
process data without buffer delays. A real-time system is a time-bound system with
well-defined and fixed time constraints, and processing must be done within the
defined constraints; otherwise, the system will fail. In a real-time operating system,
processing time requirements are measured in tenths of seconds.
● Example –
○ The operating system of the microwave oven.
○ The operating system of the Washing machine.
○ The operating system of the airplane.
○ The operating system of digital cameras and many more.
○ Missile launch system.
Types of Real-Time System

A real-time operating system is divided into two systems, such as:


1. Hard real-time system
2. Soft real-time system
Hard Real-Time System
● A hard real-time system considers timelines as a deadline, and it should not be
omitted in any circumstances. Hard real-time Systems do not use any permanent
memory, so their processes must be complete properly in the first time itself.
Examples of Hard Real-Time Systems
• Flight Control Systems
• Missile Guidance Systems
• Weapons Defense System
• Medical System
• Inkjet printer system
• Railway signaling system
• Air traffic control systems
• Nuclear reactor control systems
Soft Real-Time System
● A soft real-time system is a system whose operation is degraded if results are not
produced according to the specified timing requirement. In a soft real-time system, the
meeting of deadline is not compulsory for every task, but the process should get
processed and give the result.
Examples of Soft Real-Time Systems
• Personal computer
• Audio and video systems
• Set-top boxes
• DVD Players
• Weather Monitoring Systems
• Electronic games
• Multimedia system
• Web browsing
Interactivity
● Interactivity refers to the ability of users to interact with a computer system. An
Operating system does the following activities related to interactivity −
• Provides the user an interface to interact with the system.
• Manages input devices to take inputs from the user. For example, keyboard.
• Manages output devices to show outputs to the user. For example, Monitor.
● The response time of the OS needs to be short, since the user submits and waits for the
result.
Distributed Environment
● A distributed environment refers to multiple independent CPUs or processors
in a computer system. An operating system does the following activities
related to distributed environment −
• The OS distributes computation logics among several physical processors.
• The processors do not share memory or a clock. Instead, each processor has
its own local memory.
• The OS manages the communications between the processors. They
communicate with each other through various communication lines.
What is Process?
● A process is basically a program in
execution. The execution of a
process must progress in a
sequential fashion.
● When a program is loaded into the
memory and it becomes a process,
it can be divided into four sections ─
stack, heap, text and data.
Components of process
● Stack: The process Stack contains the temporary data such as method/function parameters, return
address and local variables.

● Heap: This is dynamically allocated memory to a process during its run time.

● Text: This includes the current activity represented by the value of Program Counter and the
contents of the processor's registers.

● Data: This section contains the global and static variables.


Process life cycle
● When a process executes, it passes through different states. These stages
may differ in different operating systems, and the names of these states are
also not standardized.
● In general, a process can have one of the following five states at a time.
States of process life cycle
● Start: This is the initial state when a process is first started/created.

● Ready: The process is waiting to be assigned to a processor. Ready processes are waiting to have the
processor allocated to them by the operating system so that they can run. Process may come into this state
after Start state or while running it by but interrupted by the scheduler to assign CPU to some other process.

● Running: Once the process has been assigned to a processor by the OS scheduler, the process state is set
to running and the processor executes its instructions.

● Waiting: Process moves into the waiting state if it needs to wait for a resource, such as waiting for user
input, or waiting for a file to become available.

● Terminated or Exit: Once the process finishes its execution, or it is terminated by the operating system, it is
moved to the terminated state where it waits to be removed from main memory.
Process Control Block (PCB)
● A Process Control Block is a data structure maintained by the Operating
System for every process. The PCB is identified by an integer process ID
(PID). A PCB keeps all the information needed to keep track of a process
PCB
Information associated with each process
(also called task control block)
● Process state – running, waiting, etc.
● Program counter – location of instruction to next execute
● CPU registers – contents of all process-centric registers
● CPU scheduling information- priorities, scheduling queue pointers
● Memory-management information – memory allocated to the process
● Accounting information – CPU used, clock time elapsed since start, time limits
● I/O status information – I/O devices allocated to process, list of open files
Two state process model
● The simplest model in the process state will be a two-state model as it consists of only two states
that are given below:
● Running State- A state in which the process is currently being executed.
● Not Running State- A state in which the process is waiting for execution.
Queuing Diagram
Process State of five state model
● As a process executes, it changes state
○ new: The process is being created
○ running: Instructions are being executed
○ waiting: The process is waiting for some event to occur
○ ready: The process is waiting to be assigned to a processor
○ terminated: The process has finished execution
Diagram of Process States
Process States of five state model
1.New: A program which is going to be picked up by the OS into the main memory is called a new
process.

2. Ready: Whenever a process is created, it directly enters in the ready state, in which, it waits for the
CPU to be assigned. The OS picks the new processes from the secondary memory and put all of them in
the main memory.
The processes which are ready for the execution and reside in the main memory are called ready state
processes. There can be many processes present in the ready state.

3. Running: One of the processes from the ready state will be chosen by the OS depending upon the
scheduling algorithm. Hence, if we have only one CPU in our system, the number of running processes for
a particular time will always be one. If we have n processors in the system then we can have n processes
running simultaneously.
4. Block or wait
● From the Running state, a process can make the transition to the block or wait state depending
upon the scheduling algorithm or the intrinsic behavior of the process.
● When a process waits for a certain resource to be assigned or for the input from the user then the
OS move this process to the block or wait state and assigns the CPU to the other processes.

5. Completion or termination
● When a process finishes its execution, it comes in the termination state. All the context of the
process (Process Control Block) will also be deleted the process will be terminated by the Operating
system.
6. Suspend ready
● A process in the ready state, which is moved to secondary memory from the main memory due to
lack of the resources (mainly primary memory) is called in the suspend ready state.
● If the main memory is full and a higher priority process comes for the execution then the OS have to
make the room for the process in the main memory by throwing the lower priority process out into
the secondary memory. The suspend ready processes remain in the secondary memory until the
main memory gets available.
7. Suspend wait
● Instead of removing the process from the ready queue, it's better to remove the blocked process
which is waiting for some resources in the main memory. Since it is already waiting for some
resource to get available hence it is better if it waits in the secondary memory and make room for
the higher priority process. These processes complete their execution once the main memory gets
available and their wait is finished.

You might also like