0% found this document useful (0 votes)
15 views17 pages

Lec 4

The document outlines the functionality of an operating system (OS) focusing on process management, including process states, control blocks, scheduling, and system calls. It explains context switching, the role of schedulers and dispatchers, and the importance of interrupts in managing processes. Additionally, it details the types of system calls and interrupts, emphasizing their necessity for resource management and process execution.

Uploaded by

pandaplays437
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)
15 views17 pages

Lec 4

The document outlines the functionality of an operating system (OS) focusing on process management, including process states, control blocks, scheduling, and system calls. It explains context switching, the role of schedulers and dispatchers, and the importance of interrupts in managing processes. Additionally, it details the types of system calls and interrupts, emphasizing their necessity for resource management and process execution.

Uploaded by

pandaplays437
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/ 17

OPERATING

SYSTEM:
COCSC301/
CACSC301
FUNCTIONALITY OF OS

Functionality of OS

Process Memory I/O File


Security
Management Management Management Management
CONCEPT OF PROCESS MANAGEMENT

Contents to be Discussed:

1. Process management
▪ Process and its state diagram
▪ Process Control Block
2. Context switching
3. Schedular and dispatcher
4. System calls and interrupts

4
1. PROCESS MANAGEMENT S

• A Program does nothing unless its instructions are executed by a CPU. A program in
execution is called a process.

• There may exist more than one process in the system which may require the same
resource at the same time. Therefore, the operating system has to manage all the processes
and the resources in a convenient and efficient way.

The operating system is responsible for the following activities in connection with
Process Management:

✓ Scheduling processes and threads on the CPUs.


✓ Creating and deleting both user and system processes.
✓ Suspending and resuming processes.
✓ Providing mechanisms for process synchronization.
✓ Providing mechanisms for process communication.
1. CONCEPT OF PROCESS
DOUBLE
CLICKING/
Program COMMAND LINE Process
(executable file) EXECUTION OF (active entity)
Passive entity PROG.EXE OR
A.OUT

HDD

RAM
Process: Program under execution
called process • Processes can be described as either:

• I/O-bound process – spends more time doing I/O than computations.

• CPU-bound process – spends more time doing computations.

5
2. CPU SWITCH FROM PROCESS TO PROCESS
• When CPU switches to another
process, the system must save the
state of the old process and load the
saved state for the new process.

• Context-switch time is overhead; the


system does no useful
work while switching.

• Time dependent on hardware support.

Fig: Diagram showing CPU switch from process to process


2. ATTRIBUTES AND PCB OF A PROCESS
The Attributes of the process are used by the Operating System to create the process
control block (PCB) for each of them. This is also called context of the process.
Attributes which are stored in the PCB are described below:

1. Process ID: When a process is created, a unique id is assigned to the process


which is used for unique identification of the process in the system.

2. Program counter: A program counter stores the address of the last instruction of
the process on which the process was suspended. The CPU uses this address when
the execution of this process is resumed.

3. Process State: The Process, from its creation to the completion, goes through
various states which are new, ready, running and waiting.

4. Priority: Every process has its own priority. The process with the highest priority
among the processes gets the CPU first. This is also stored on the process control
ATTRIBUTES AND PCB OF A PROCESS
5. General Purpose Registers: Every process has its own set of registers which
are used to hold the data which is generated during the execution of the process.

6. List of open files: During the Execution, Every process uses some files which
need to be present in the main memory. OS also maintains a list of open files in the
PCB.

7. List of open devices: OS also maintain the list of all open devices which are
used during the execution of the process.
ATTRIBUTES AND PCB OF A PROCESS

Process Control Block or Task Control Block or


Process Descriptor: PCB serves as repository that
contains attributes of process. Attributes may include
process state, process number, program counter, list of
open files, registers, process priority etc. Each process in
the system is represented by a PCB

Figure- Process control block


(PCB)
3. SCHEDULERS
Scheduler are responsible for selecting a process for scheduling. Three types of scheduler
are:
Note: The long-term scheduler controls the degree of multiprogramming. Medium term
scheduler reduce the degree of multiprogramming The degree of multiprogramming tells
us how many processes a single-
processor system can handle well
DISPATCHER

• It is the module that gives control of the CPU to the process selected by the short-time
scheduler.

• A dispatcher switches execution from one process to another process called context switching.
It also setup user registers, memory mapping, etc.

• Dispatch latency: amount of time taken by the system to stop one process and give permission
to another process to being execution.

18
4.1 SYSTEM CALLS IN OS

A system call is a method for a computer program to request a service from the kernel of
the operating system on which it is running. It is the only method to access the kernel system.
All programs or processes that require resources for execution must use system calls
Why do you need system calls in Operating System?
Following are some of the situations when system calls are required:
o It is required when a file system wants to create or delete a file.
o If you want to access hardware devices, including a printer, scanner, you need a system call.
o During creation and management of new processes
Types of System Calls Windows
TYPES OF SYSTEM CALLS Linux
CreateProcess()
fork()
ExitProcess()
Process Control exit()
WaitForSingleObject()
wait()

CreateFile() open()
ReadFile() read()
File Management WriteFile() write()
CloseHandle() close()

SetConsoleMode() ioctl()
ReadConsole() read()
Device Management
WriteConsole() write()

GetCurrentProcessID() getpid()
SetTimer() alarm()
Information Maintenance
Sleep() sleep()

CreatePipe()
pipe()
CreateFileMapping()
Communication shmget()
MapViewOfFile()
mmap()
4.2. WHAT IS INTERRUPT IN OS?

An interrupt is a signal emitted by hardware or software when a process or an event


needs immediate attention. It alerts the processor to a high-priority process requiring
interruption of the current working process. In I/O devices, one of the bus control lines
is dedicated for this purpose and is called the Interrupt Service Routine (ISR0).
When a device raises an interrupt at the process, the processor first completes the
execution of an instruction. Then it loads the Program Counter (PC) with the address
of the first instruction of the ISR. Before loading the program counter with the address,
the address of the interrupted instruction is moved to a temporary location. Therefore,
after handling the interrupt, the processor can continue with the process.
TYPES OF INTERRUPT

1. Hardware Interrupts
A hardware interrupt is a condition related to the state of the hardware that may be
signaled by an external hardware device, e.g., an interrupt request (IRQ) line on a PC, or
detected by devices embedded in processor logic to communicate that the device needs
attention from the operating system. For example, pressing a keyboard key or moving a
mouse triggers hardware interrupts that cause the processor to read the keystroke or
mouse position.
2. Software Interrupts
The processor requests a software interrupt upon executing particular instructions or
when certain conditions are met. Software interrupts may also be unexpectedly triggered
by program execution errors. These interrupts are typically called traps or exceptions.
HOW INTERRUPT HANDLING IS DONE ?

Whenever an interruption occurs the processor finishes the current


instruction execution and starts the execution of the interrupt known as
interrupt handling.
The interrupt handling mechanism of an operating system accepts a
number which is an address and then selects what specific action to be
taken which is already mentioned in the interrupt service routine. In
most architecture, the address is stored in a table known as a vector
table. Interrupt handling by OS scheme is shown as follows:
THANK YOU
?

You might also like