Lecture Incourse OS by Rabbi Sir
Lecture Incourse OS by Rabbi Sir
Introduction
An Operating System (OS) is a software that manages and handles hardware and software resources
of a computing device.
• Responsible for managing and controlling all the activities and sharing of computer
resources among different running applications.
• A low-level Software that includes all the basic functions like processor management,
memory management, file management, etc.
• It mainly acts a government for your system that has different departments to manage
different resources.
• Examples are Linux, Unix, Windows 11, MS DOS, Android, macOS and iOS.
1
Rabbi Sir
Functions of an Operating System
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 manages the allocation and deallocation
of memory to various processes and ensures that the other process does not consume the memory
allocated to one process. 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 memory
access, 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.
Processor Management
In a multi-programming 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.
An operating system manages the processor’s work by allocating various jobs to it and ensuring
that each process receives enough time from the processor to function properly.
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 longer required.
2
Rabbi Sir
Device Management
An OS manages device communication via its 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.
• Decide which process gets access to a certain device and for how long.
• Allocates devices effectively and efficiently. Deallocates devices when they are no
longer required.
• There are various input and output devices. An OS controls the working of these input-
output devices.
• It receives the requests from these devices, performs a specific task, and communicates
back to the requesting process.
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, the status of every file, and more. These facilities are collectively known as the file
system. An OS keeps track of information regarding the creation, deletion, transfer, copy, and
storage of files in an organized way. It also maintains the integrity of the data stored in these files,
including the file directory structure, by protecting against unauthorized access
I/O Management
I/O management is the important function of operating system refers to how the OS
handles input and output operations between the computer and external devices, such as
keyboards, mice, printers, hard drives, and monitors.
User Interface or Command Interpreter
The user interacts with the computer system through the operating system. Hence OS acts as an
interface between the user and the computer hardware. This user interface is offered through a set
of commands or a graphical user interface (GUI). Through this interface, the user makes interacts
with the applications and the machine hardware.
3
Rabbi Sir
Booting the Computer
The process of starting or restarting the computer is known as booting. If the computer is switched
off completely and if turned on then it is called cold booting. Warm booting is a process of using
the operating system to restart the computer.
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. The operating system provides various
techniques which assure the integrity and confidentiality of user data. The following security
measures are used to protect user data:
• Protection against unauthorized access through login.
• Protection against intrusion by keeping the firewall active.
• Protecting the system memory against malicious access.
• Displaying messages related to system vulnerabilities.
Job Accounting
The 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. In a
multitasking OS where multiple programs run simultaneously, the OS determines which
applications should run in which order and how time should be allocated to each application.
Error-Detecting Aids
The operating system constantly monitors the system to detect errors and avoid malfunctioning
computer systems. From time to time, the operating system checks the system for any external
threat or malicious software activity. It also checks the hardware for any type of damage. This
process displays several alerts to the user so that the appropriate action can be taken against any
damage caused to the system.
4
Rabbi Sir
Performs Basic Computer Tasks
The management of various peripheral devices such as the mouse, keyboard, and printer is carried
out by the operating system. Today most operating systems are plug-and-play. These operating
systems automatically recognize and configure the devices with no user interference.
Network Management
• Network Communication: Think of them as traffic cops for your internet traffic.
Operating systems help computers talk to each other and the internet. They manage how
data is packaged and sent over the network, making sure it arrives safely and in the
right order.
• Settings and Monitoring: Think of them as the settings and security guard for your
internet connection. They also let you set up your network connections, like Wi-
Fi or Ethernet, and keep an eye on how your network is doing. They make sure your
computer is using the network efficiently and securely, like adjusting the speed of your
internet or protecting your computer from online threats.
5
Rabbi Sir
Services Provided by an Operating System
The Operating System provides certain services to the users which can be listed in the following
manner:
• User Interface: Almost all operating systems have a user interface (UI). This interface
can take several forms. One is a command-line interface(CLI), which uses text
commands and a method for entering them (say, a keyboard for typing in commands in
a specific format with specific options). Another is a batch interface, in which
commands and directives to control those commands are entered into files, and those
files are executed. Most commonly, a graphical user interface (GUI) is used. the
interface is a window system with a pointing device to direct I/O, choose from menus,
and make selections and a keyboard to enter text.
• Program Execution: The Operating System is responsible for the execution of all
types of programs whether it be user programs or system programs. The Operating
System utilizes various resources available for the efficient running of all types of
functionalities.
• Handling Input/Output Operations: The Operating System is responsible for
handling all sorts of inputs, i.e., from the keyboard, mouse, desktop, etc. The Operating
System does all interfacing most appropriately regarding all kinds of Inputs and
Outputs.
For example, there is a difference between all types of peripheral devices such as mice
or keyboards, the Operating System is responsible for handling data between them.
• Manipulation of File System: The Operating System is responsible for making
decisions regarding the storage of all types of data or files, i.e., floppy disk/hard
disk/pen drive, etc. The Operating System decides how the data should be manipulated
and stored.
• Resource Allocation: The Operating System ensures the proper use of all the resources
available by deciding which resource to be used by whom for how much time. All the
decisions are taken by the Operating System.
• Accounting: The Operating System tracks an account of all the functionalities taking
place in the computer system at a time. All the details such as the types of errors that
occurred are recorded by the Operating System.
• Information and Resource Protection: The Operating System is responsible for using
all the information and resources available on the machine in the most protected way.
The Operating System must foil an attempt from any external resource to hamper any
sort of data or information.
• Communication: The operating system implements communication between one
process to another process to exchange information. Such communication may occur
between processes that are executing on the same computer or between processes that
are executing on different computer systems tied together by a computer network.
• System Services: The operating system provides various system services, such as
printing, time and date management, and event logging.
• Error Detection: The operating system needs to be detecting and correcting errors
constantly. Errors may occur in the CPU and memory hardware ( for eg. a memory
error or a power failure), in I/O devices (such as a parity error on disk, a connection
failure on a network, or a lack of paper in the printer), and in the user program ( an
arithmetic overflow, an attempt to access an illegal memory location or a too-great use
of CPU time). For each type of error, the operating system should take the appropriate
action to ensure correct and consistent computing.
All these services are ensured by the Operating System for the convenience of the users to make the
programming task easier. All different kinds of Operating Systems more or less provide the same
services.
6
Rabbi Sir
Types of Operating System (OS)
Following are the popular types of OS (Operating System):
The user of a batch operating system never directly interacts with the computer. In this type of OS,
every user prepares his or her job on an offline device like a punch card and submit it to the computer
operator.
A real time operating system time interval to process and respond to inputs is very small. Examples:
Military Software Systems, Space Software Systems are the Real time OS example.
• Mobile OS
Mobile operating systems are those OS which is especially that are designed to power smartphones,
tablets, and wearables devices.
7
Rabbi Sir
What is Kernel in Operating System?
The kernel is the central component of a computer operating systems. The only job performed by the
kernel is to the manage the communication between the software and the hardware. A Kernel is at the
nucleus of a computer. It makes the communication between the hardware and software possible.
While the Kernel is the innermost part of an operating system, a shell is the outermost one.
Features of Kernel
• Low-level scheduling of processes
• Inter-process communication
• Process synchronization
• Context switching
Types of Kernel
There are many types of kernels that exists, but among them, the two most popular kernels are:
1. Monolithic
A monolithic kernel is a single code or block of the program. It provides all the required services
offered by the operating system. It is a simplistic design which creates a distinct communication layer
between the hardware and software.
2. Microkernels
Microkernel manages all system resources. In this type of kernel, services are implemented in
different address space. The user services are stored in user address space, and kernel services are
stored under kernel address space. So, it helps to reduce the size of both the kernel and operating
system.
8
Rabbi Sir
Difference between Firmware and Operating System
Below are the Key Differences between Firmware and Operating System:
Define Firmware: Firmware is one kind of Define Operating System: OS provides functionality
programming that is embedded on a chip in the over and above that which is provided by the
device which controls that specific device. firmware.
9
Rabbi Sir
A system call is a function provided by the operating
system that allows user-level applications to request
What is System Call in Operating System? services from the kernel.
A system call is a mechanism that provides the interface between a process and the operating system.
It is a programmatic method in which a computer program requests a service from the kernel of the
OS.
System call offers the services of the operating system to the user programs via API (Application
Programming Interface). System calls are the only entry points for the kernel system.
In an interactive system, this type of program execution requires some system calls by OS.
Step 1) The processes executed in the user mode till the time a system call interrupts it.
Step 2) After that, the system call is executed in the kernel-mode on a priority basis.
Step 3) Once system call execution is over, control returns to the user mode.,
10
Rabbi Sir
Why do you need System Calls in OS?
Following are situations which need system calls in OS:
• Process Control
• File Management
• Device Management
• Information Maintenance
• Communications
Process Control
This system calls perform the task of process creation, process termination, etc.
Functions:
File Management
File management system calls handle file manipulation jobs like creating a file, reading, and writing,
etc.
Functions:
• Create a file
• Delete file
• Open and close file
• Read, write, and reposition
• Get and set file attributes
11
Rabbi Sir
Device Management
Device management does the job of device manipulation like reading from device buffers, writing
into device buffers, etc.
Functions:
Information Maintenance
It handles information and its transfer between the OS and the user program.
Functions:
Communication
These types of system calls are specially used for interprocess communications.
Functions:
12
Rabbi Sir
Important System Calls Used in OS
wait()
In some systems, a process needs to wait for another process to complete its execution. This type of
situation occurs when a parent process creates a child process, and the execution of the parent process
remains suspended until its child process executes.
The suspension of the parent process automatically occurs with a wait() system call. When the child
process ends execution, the control moves back to the parent process.
fork()
Processes use this system call to create processes that are a copy of themselves. With the help of this
system Call parent process creates a child process, and the execution of the parent process will be
suspended till the child process executes.
exec()
This system call runs when an executable file in the context of an already running process that
replaces the older executable file. However, the original process identifier remains as a new process is
not built, but stack, data, head, data, etc. are replaced by the new process.
kill()
The kill() system call is used by OS to send a termination signal to a process that urges the process to
exit. However, a kill system call does not necessarily mean killing the process and can have various
meanings.
exit()
The exit() system call is used to terminate program execution. Specially in the multi-threaded
environment, this call defines that the thread execution is complete. The OS reclaims resources that
were used by the process after the use of exit() system call.
13
Rabbi Sir
Summary
CreateProcess() fork()
Process control ExitProcess() exit()
WaitForSingleObject() wait()
SetConsoleMode() loctl()
Device manipulation ReadConsole() read()
WriteConsole() write()
CreateFile() Open()
ReadFile() Read()
File manipulation
WriteFile() write()
CloseHandle() close!)
GetCurrentProcessID() getpid()
Information maintanence SetTimer() alarm()
Sleep() sleep()
CreatePipe() Pipe()
Communication CreateFileMapping() shm_open()
MapViewOfFile() mmap()
SetFileSecurity() Chmod()
Protection InitlializeSecurityDescriptor() Umask()
SetSecurityDescriptorGroup () Chown()
14
Rabbi Sir
What is Process Scheduling?
Process Scheduling is an OS task that schedules processes of different states like ready, waiting, and
running.
Process scheduling allows OS to allocate a time interval of CPU execution for each process. Another
important reason for using a process scheduling system is that it keeps the CPU busy all the time. This
allows you to get the minimum response time for programs
Long term scheduler is also known as a job scheduler. This scheduler regulates the program and
select process from the queue and loads them into memory for execution. It also regulates the degree
of multi-programing.
However, the main goal of this type of scheduler is to offer a balanced mix of jobs, like Processor, I/O
jobs., that allows managing multiprogramming.
A running process can become suspended if it makes an I/O request. A suspended processes can’t
make any progress towards completion. In order to remove the process from memory and make space
for other processes, the suspended process should be moved to secondary storage.
15
Rabbi Sir
Difference between Schedulers
Long-Term Vs. Short Term Vs. Medium-Term
Long term is also known as a Short term is also known as CPU Medium-term is also called
job scheduler scheduler swapping scheduler.
16
Rabbi Sir
Shortest Job First
SJF is a full form of (Shortest job first) is a scheduling algorithm in which the process with the
shortest execution time should be selected for execution next. This scheduling method can be
preemptive or non-preemptive. It significantly reduces the average waiting time for other processes
awaiting execution.
17
Rabbi Sir