Professional Documents
Culture Documents
Unit1 OS
Unit1 OS
Noida
Operating Systems
ACSE0403A
Unit: 1
Operating System
Dr Sandhya Umrao
Professor
B Tech IT-4th Sem Deptt. of CSE (AI)
CO1: Understand the fundamentals of an operating systems, functions and their structure and
functions.
CO2: Implement concept of process management policies, CPU Scheduling and thread
management.
CO3: Understand and implement the requirement of process synchronization and apply
deadlock handling algorithms.
CO4: Evaluate the memory management and its allocation policies.
CO5: Understand and analyze the I/O management and File systems
SUB CODE PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
ACSE0403A .1 3 3 2 2 1 2 - 2 3 2 2 3
ACSE0403A .2 3 3 3 2 2 3 2 2 3 - 1 3
ACSE0403A .3 3 3 2 2 2 2 2 2 2 3 1 3
ACSE0403A .4 3 2 2 3 1 2 2 - 2 - 2 3
ACSE0403A .5 3 1 2 2 2 2 - - 2 2 2 3
ACSE0403A .1 2 1 2 2
ACSE0403A .2 2 2 1 2
ACSE0403A .3 2 3 3 2
ACSE0403A .4 2 2 1 2
ACSE0403A .5 2 2 2 2
• PEO1:Apply sound knowledge in the field of information technology to fulfill the needs of
IT industry.
• PEO2:Design innovative and interdisciplinary systems through latest digital technologies.
• PEO3:Inculcate professional – social ethics, team work and leadership for serving the
society.
• PEO4:Inculcate lifelong learning in the field of computing for successful career in
organizations and R&D sectors.
Topic CO
Introduction to Operating System CO1
Types of operating System CO1
Interrupt Handling CO1
Operating System Structure CO1
Operating System Services CO1
Topic Objective
Students will be able to
Introduction of Operating System Understand the basics of Operating System,its features
characteristics and functions
2. Booting
Booting is basically the process of starting the computer. When the CPU is first switched ON it has nothing inside the
memory. So, to start the computer, we load the operating system into the main memory. Therefore, loading the OS to the
main memory to start the computer is booting. Hence, the OS helps to start the computer when the power is switched ON.
4. Multitasking
The OS helps to run more than one application at a time on the computer. It plays an important role while multitasking.
Since it manages memory and other devices during multitasking. Therefore, it provides smooth multitasking on the system.
• Memory Management — It keeps tracks of primary memory i.e what part of it are in use by whom,
what part are not in use etc. Allocates the memory when the process or program request it.
• Processor Management — Allocate the processor(CPU) to a process. De allocate processor when
processor is no longer required.
• Device Management — Keep tracks of all devices. This is also called I/O controller. Decides which
process gets the device when and for how much time.
• File Management — Allocates the resources. De-allocates the resource. Decides who gets the
resources.
• Security — By means of passwords & similar other techniques, preventing unauthorized access to
programs & data.
• Error-detecting aids — Production of dumps, traces, error messages and other debugging and error-
detecting methods.
• Storage Management
Memory Management:
• It is the management of the main or primary memory. Whatever program is executed, it has to be
present in the main memory. Main memory is a quick storage area that may be accessed directly by
the CPU. When the program execution is completed, the memory region is released and can be used
by other programs. Therefore, there can be more than one program present at a time. Hence, it is
required to manage the memory.
The operating system:
• Allocates and de allocates the memory.
• Keeps a record of which part of primary memory is used by whom and how much.
• Distributes the memory while multiprocessing.
• In multiprogramming, the operating system selects which processes acquire memory when and how
much memory they get.
Processor Management:
• Every software that runs on a computer, whether in the background or in the frontend, is a process. Processor
management is an execution unit in which a program operates. The operating system determines the status of the
processor and processes, selects a job and its processor, allocates the processor to the process, and de-allocates
the processor after the process is completed.
• When more than one process runs on the system, the OS decides how and when a process will use the CPU.
Hence, the name is also CPU Scheduling.
The OS:
• Allocates and de allocates processor to the processes.
• Keeps record of CPU status.
Certain algorithms used for CPU scheduling are as follows:
• First Come First Serve (FCFS)
• Shortest Job First (SJF)
• Round-Robin Scheduling
• Priority-based scheduling etc.
• Computer-System Operation
• I/O Structure
• Storage Structure
• Storage Hierarchy
• Hardware Protection
• General System Architecture
• A modern computer system consists of a CPU, memory, system bus and a number
of device controllers.
• I/O devices and the CPU can execute concurrently.
• Each device controller is in charge of a particular device type.
• A device controller for each device contains local buffer storage and special
purpose registers.
• A bootstrap program is required to initialize the computer system.
• CPU moves data from /to main memory and 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.
• The Computer System has a number of device controllers connected through a common bus.
• A device controller contains local buffer storage and a set of special purpose registers.
• The device driver is responsible for moving the data between the peripheral devices and it controls its
local buffer storage.
• I/O interrupts are used by the device controllers for transfer of data.
• I/O methods
a) Synchronous
b) Asynchronous
• In synchronous method , after I/O starts, control returns to user program only upon I/O completion.
• In asynchronous method, after I/O starts, control returns to user program without waiting for I/O
completion. It requires system call which is a request to the operating system to allow user to wait for
I/O completion.
• Registers
• Cache Memory
• Main Memory
• Electronic Disk
• Magnetic Disk
• Optical Disk
• Hard Disk
• Magnetic Tape
• I/O Protection
• Memory Protection
• CPU Protection
I/O Protection :
a) All I/O instructions are defined as privileged instructions so users cannot issue I/O
instructions from user mode.
b) To do I/O , a user program executes a system call to request that the OS perform
I/O on its behalf and returns the control to the users after completion of I/O
operation.
Memory Protection:
Two registers are used to determine the range of legal addresses a program may access:
1. Base register: holds the smallest legal physical memory address.
2. Limit register: contains the size of the range
• CPU Protection :
A user program may:
a) be stuck in an infinite loop
b) fail to call system services
c) fail to return control to the OS.
Timer: Interrupts computer after specified period to ensure operating system maintains control.
Timer is also commonly used to implement time sharing mechanism.
Timer can be used to compute the current time.
Multitasking
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.
Multitasking
•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.
Time-Sharing Systems
• 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 is 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” not from a card reader, but rather
from the user’s keyboard.
• On-line system must be available for users to access data and code.
The response time of the OS needs to be short, since the user submits and
waits for the result.
Multithreaded System
• A thread is a flow of execution through the process code, with its own
program counter that keeps track of which instruction to execute next,
system registers which hold its current working variables, and a stack
which contains the execution history.
• A thread shares with its peer threads few information like code segment,
data segment and open files. When one thread alters a code segment,
memory item, all other threads see that.
• A thread is also called a lightweight process. Threads provide a way to
improve application performance through parallelism. Threads represent
a software approach to improving performance of operating system by
reducing the overhead, thread is equivalent to a classical process.
Multithreaded System
2 Process switching needs interaction with Thread switching does not need to interact
operating system. with operating system.
3 In multiple processing environments, each All threads can share same set of open files,
process executes the same code but has child processes.
its own memory and file resources.
4 Multiple processes without using threads Multiple threaded processes use fewer
use more resources. resources.
5 In multiple processes each process One thread can read, write or change
operates independently of the others. another thread's data.
Multithreaded System
• Most modern applications are multithreaded.
• Threads run within application.
• Multiple tasks within the application can be implemented by separate
threads
• Update display.
• Fetch data.
• Spell checking.
• Answer a network request.
• Process creation is heavy-weight while thread creation is light-weight.
• Can simplify code, increase efficiency.
• Kernels are generally multithreaded.
• System calls provide the interface between a running program and the operating system.
• Any single CPU computer can execute only one instruction at a time. If process is running a
user program in user mode and needs a system service, such as reading a data from a file , it
has to execute a trap instruction to transfer control to the operating system.
Operating system provides services and system call provides interface to these services.
System call is written in language C and C++ as routines. System calls are performed in a
series of steps.
System call is a technique by which a program executing in user mode can request the kernel’s
service.
Ex: Writing a simple program to read data from one file and copy them to another file.
Types of System calls
Here are the five types of system calls used in OS:
• Process Control
• File Management
• Device Management
• Information Maintenance
• Communications
05/29/2024 Dr. Sandhya Umrao OS Unit Number:1 68
Process control (CO1)
End , abort
● Load, Execute
● Create process, terminate process
● Wait for time
● Allocate and free memory
● Wait event, signal event
● Get process attributes, set PA
• Interrupts are generally called signals which are generated by the software or
hardware when a particular event or process requires immediate attention. So,
the signal informs the processor about a high priority and urgent information
demand causing an interruption in the current working process.
• Whenever an interruption occurs the processor finishes the current instruction
execution and starts the execution of the interrupt known as interrupt handling.
Moreover, for every interrupt handling to occur there is an Interrupt service
routine (ISR) or interrupt handler.
• 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
05/29/2024
type of interrupt. Dr. Sandhya Umrao OS Unit Number:1 74
Interrupt Handling(CO1)
Polling: In polling, the first device encountered with the IRQ bit set is the
device that is to be serviced first. Appropriate ISR is called to service the same.
It is easy to implement but a lot of time is wasted by interrogating the IRQ bit of
all devices.
Interrupt Timeline
• The operating system is divided into a number of layers (levels), each built on
top of lower layers. The bottom layer (layer 0), is the hardware; the highest
(layer N) is the user interface.
• With modularity, layers are selected such that each uses functions
(operations) and services of only lower-level layers.
Applications
Monolithic Kernel
Hardware
Applications Server
Microkernel
Hardware
Reentrant functions only modify local variables but do not alter global
data structures. To provide reentrant kernel, the kernel is implemented as a
collection of reentrant functions.
•Process Management
•Main Memory Management
•Secondary-Storage Management
•I/O System Management
•File Management
•Protection System
•Networking
•Command-Interpreter System
• 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 deallocate memory space as needed.
Additional functions exist not for helping the user, but rather for ensuring
efficient system operations.
• Resource allocation – allocating resources to multiple users or
multiple jobs running at the same time.
• Accounting – keep track of and record which users use how much
and what kinds of computer resources for account billing or for
accumulating usage statistics.
• Protection – ensuring that all access to system resources is
controlled.
•An I/O subsystem comprises of I/O devices and their corresponding driver
software. Drivers hide the peculiarities of specific hardware devices from
the users.
•An Operating System manages the communication between user and
device drivers.
•I/O operation means read or write operation with any file or any specific
I/O device.
•Operating system provides the access to the required I/O device when
required.
Communication
•In case of distributed systems which are a collection of processors that do not share
memory, peripheral devices, or a clock, the operating system manages communications
between all the processes. Multiple processes communicate with one another through
communication lines in the network.
•The OS handles routing and connection strategies, and the problems of contention and
security. Following are the major activities of an operating system with respect to
communication −
•Two processes often require data to be transferred between them
•Both the processes can be on one computer or on different computers, but are connected
through a computer network.
•Communication may be implemented by two methods, either by Shared Memory or by
Message Passing.
Error Handling
•Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in
the memory hardware. Following are the major activities of an operating system with
respect to error handling −
•The OS constantly checks for possible errors.
•The OS takes an appropriate action to ensure correct and consistent computing.
Resource Management
•In case of multi-user or multi-tasking environment, resources such as main memory, CPU
cycles and files storage are to be allocated to each user or job. Following are the major
activities of an operating system with respect to resource management −
•The OS manages all kinds of resources using schedulers.
•CPU scheduling algorithms are used for better utilization of CPU.
User
Interface
UNIX Kernel
• https://www.youtube.com/playlist?list=PLBlnK6fEyqRiVhbXDGLXDk_OQAeuVcp2O
• https://nptel.ac.in/courses/106108101
• https://www.youtube.com/playlist?list=PLBlnK6fEyqRiVhbXDGLXDk_OQAeuVcp2O
• https://nptel.ac.in/courses/106108101
• https://www.youtube.com/playlist?list=PLBlnK6fEyqRiVhbXDGLXDk_OQAeuVcp2O
• https://nptel.ac.in/courses/106108101
In this module,
we have studied the following: