Unit1 OS
Unit1 OS
Operating System
BCSE0403A .1 3 3 2 2 1 2 - 2 3 2 2 3
BCSE0403A .2 3 3 3 2 2 3 2 2 3 - 1 3
BCSE0403A .3 3 3 2 2 2 2 2 2 2 3 1 3
BCSE0403A.4 3 2 2 3 1 2 2 - 2 - 2 3
BCSE0403A.5 3 1 2 2 2 2 - - 2 2 2 3
On successful completion of B. Tech. (CSE.) Program, the graduates will be able to:
BCSE0403A.1 2 1 2 2
BCSE0403A.2 2 2 1 2
BCSE0403A.3 2 3 3 2
BCSE0403A.4 2 2 1 2
BCSE0403A.5 2 2 2 2
PEO’S of the B. Tech. in Computer Science and Engineering are: The graduates will be able:
PEO 1: To have an excellent scientific and engineering breadth so as to comprehend, analyze, design and provide
sustainable solutions for real-life problems using state-of-the-art technologies.
PEO 2: To have a successful career in industries, to pursue higher studies or to support entrepreneurial endeavors
and to face global challenges.
PEO 3: To have an effective communication skill, professional attitude, ethical values and a desire to learn
specific knowledge in emerging trends, technologies for research, innovation and product development and
contribution to society.
PEO 4: To have life-long learning for up-skilling and re-skilling for successful professional career as engineer,
scientist, entrepreneur, and bureaucrat for betterment of the society.
Topic CO
Overview of Operating Systems CO1
Types of operating System CO1
Operating system architecture CO1
System call and kernel CO1
Introduction to Linux Operating System CO1
Basic Command Line Interface (CLI) CO1
Operations in Linux
Shell Scripting Basics CO1
Topic Objective
Students will be able to
Introduction of Operating System Understand the basics of Operating System, its features characteristics
and functions
1. Introduction
2. Functions of Operating System
3. Characteristics of Operating System
4. Operating system architecture
5. Types of Operating Systems
5.1 Simple Batch Systems
5.2 Multiprogramming Batched Systems
5.3 Multi-tasking Systems
5.4 Multi-Processor Systems
5.5 Real time Systems
6. System call and kernel.
7. Introduction to Linux Operating System
8. Basic Command Line Interface (CLI) Operations in Linux
9. Shell Scripting Basics: Variables, Control Structures, Functions.
• Convenience – An operating system improves the use of a machine. Operating systems enable users
to get started on the things they wish to complete quickly without having to cope with the stress of
first configuring the system.
• Efficiency – An operating system enables the efficient use of resources. This is due to less time spent
configuring the system.
• Ability to evolve – An operating system should be designed in such a way that it allows for the
effective development, testing, and introduction of new features without interfering with service.
• Throughput: An OS should be constructed so that it can give maximum throughput(Number of
tasks per unit time).
• Management of system resources – It guarantees that resources are shared fairly among various
processes and users.
• Security – For security, modern operating systems employ a firewall. A firewall is a type of security system that
monitors all computer activity and blocks it if it detects a threat.
• Job Accounting – As the operating system keeps track of all the functions of a computer system. Hence, it makes a
record of all the activities taking place on the system. It has an account of all the information about the memory,
resources, errors, etc. Therefore, this information can be used as and when required.
• Control over system performance – The operating system will collect consumption statistics for various resources
and monitor performance indicators such as reaction time, which is the time between requesting a service and
receiving a response from the system.
• Error detecting aids – While a computer system is running, a variety of errors might occur. Error detection
guarantees that data is delivered reliably across susceptible networks. The operating system continuously monitors
the system to locate or recognize problems and protects the system from them.
• Coordination between other software and users – The operating system (OS) allows hardware components to be
coordinated and directs and allocates assemblers, interpreters, compilers, and other software to different users of
the computer system.
• Booting process – The process of starting or restarting a computer is referred to as Booting. Cold booting occurs
when a computer is totally turned off and then turned back on. Warm booting occurs when the computer is restarted.
The operating system (OS) is in charge of booting the computer.
• 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.
Device Management:
• An operating system regulates device connection using drivers. The processes may require devices for their use.
This management is done by the OS.
The OS:
• Allocates and de allocates devices to different processes.
• Keeps records of the devices.
• Decides which process can use which device for how much time.
File Management:
• The operating system manages resource allocation and de-allocation. It specifies which process receives the file and
for how long. It also keeps track of information, location, uses, status, and so on. These groupings of resources are
referred to as file systems. The files on a system are stored in different directories.
The OS:
• Keeps records of the status and locations of files.
• Allocates and de allocates resources.
• Decides who gets the resources.
Storage Management:
• Storage management is a procedure that allows users to maximize the utilization of storage devices
while also protecting data integrity on whatever media on which it lives. Network virtualization,
replication, security, compression, de duplication, traffic analysis, process automation, storage
provisioning, and memory management are some of the features that may be included.
• The operating system is in charge of storing and accessing files. The creation of files, the creation of
directories, the reading and writing of data from files and directories, as well as the copying of the
contents of files and directories from one location to another are all included in storage management.
The OS uses storage management for:
• Improving the performance of the data storage resources.
• It optimizes the use of various storage devices.
• Assists businesses in storing more data on existing hardware, speeding up the data retrieval process,
preventing data loss, meeting data retention regulations, and lowering IT costs.
Popular Architectures
Following are various popular implementations of Operating System architectures.
• Simple Architecture
• Monolith Architecture
• Micro-Kernel Architecture
• Layered Architecture
• Modular Architecture
• Virtual Machine Architecture
In operating system Architecture, we've two major terms which defines the major components of the
operating systems.
• Kernal − Kernal is the central component of an operating system architecture in most of the implementation. A
kernal is responsible for all major operations and interaction with the hardware. A kernal manages memory,
processor, input/output devices and provides interface to application programs to interact with hardware
components.
• Shell − Shell is an interface of an operating system. It can be command line interface or a graphical user
interface. User interacts with an operating system using shell. Application programs can also use shell interface to
interact with underlying operating system.
• System Softwares − System softwares are the programs which interact with Kernal and provides interface for
security managment, memory management and other low level activities.
• Application Programs − Application softwares/Programs are the one using which a user interacts with the
operating system. For example a word processor to create a document and save it on the file system, a notepad to
create notes etc.
Advantages
Following are advantages of a simple operating system architecture.
Easy Development - In simple operation system, being very few interfaces, development is easy especially when
only limited functionalities are to be delivered.
Better Performance - Such a sytem, as have few layers and directly interects with hardware, can provide a better
performance as compared to other types of operating systems.
Disadvantages
Following are disadvantages of a simple operating system architecture.
Frequent System Failures - Being poorly designed, such a system is not robust. If one program fails, entires
operating system crashses. Thus system failures are quiet frequent in simple operating systems.
Poor Maintainability - As all layers of operating systems are tightly coupled, change in one layer can impact other
layers heavily and making code unmanageable over a period of time.
The kernel has access to the all the resources and it acts as an interface with application programs and the
underlying hardware. A monolithic kernel architecture promotes timesharing, multiprogramming model and was
used in old banking systems.
Advantages
Following are advantages of a monolith operating system architecture.
• Easy Development - As kernel is the only layer to develop with all major functionalities, it is easier to design and
develop.
• Performance - As Kernel is responsible for memory management, other operations and have direct access to the
hardware, it performs better.
Disadvantages
Following are disadvantages of a monolith operating system architecture.
• Crash Prone - As Kernel is responsible for all functions, if one function fails entire operating system fails.
• Difficult to enhance - It is very difficult to add a new service without impacting other services of a monolith
operating system.
Advantages
Following are advantages of a microkernel operating system architecture.
• Reliable and Stable - As multiple kernels are working simultaneously, chances of failure of operating
sytem is very less. If one functionlity is down, operating system can still provide other functionalities
using stable kernels.
• Maintainability - Being small sized kernels, code size is maintainable. One can enhance a microkernel
code base without impacting other microkernel code base.
Disadvantages
• Following are disadvantages of a microkernel operating system architecture.
• Complex to Design - Such a microkernel based architecture is difficult to design.
• Performance Degradation - Multi kernel, Multi-modular communication may hamper the
performance as compared to monolith architecture.
One way to achieve modularity in the operating system is the layered approach. In this, the bottom
layer is the hardware and the topmost layer is the user interface.
An image demonstrating the layered approach is as follows −
• As seen from the image, each upper layer is built on the bottom layer. All the layers hide some
structures, operations etc from their upper layers.
• One problem with the layered architecture is that each layer needs to be carefully defined. This is
necessary because the upper layers can only use the functionalities of the layers below them.
Advantages
• Following are advantages of a modular operating system architecture.
• High Customizable - Being modular, each module implmentation can be customized easily. A new
functionality can be added without impacting other modules as well.
• Verifiable - Being modular, each layer can be verified and debugged easily.
Disadvantages
• Following are disadvantages of a modular operating system architecture.
• Less Performant - A modular architecture operating system is less performant as compared to basic
structured operating system.
• Complex designing - Each module is to planned carefully as each module communicates with
kernal. A communication API is to be devised to facilitate the communication.
Advantages
• Following are advantages of a virtual machine based operating system architecture.
• High Customizable - Being virtual, functionality are easily accessible, can be customized on need basis.
• Secure - Being virtual, and no direct hardware access, such systems are highly secured.
Disadvantages
• Following are disadvantages of a virtual machine based operating system architecture.
• Less Performance - A virtual structured operating system is less performing as compared to modular structured operating
system.
• Complex designing - Each virtual component of the machine is to planned carefully as each component is to abstract
underlying hardware.
• 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.
• Registers
• Cache Memory
• Main Memory
• Electronic Disk
• Magnetic Disk
• Optical Disk
• Hard Disk
• Magnetic Tape
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 of 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 pool for later printing or processing.
Batch 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.
Advantages
•High and efficient CPU utilization.
•User feels that many programs are allotted to CPU almost simultaneously.
Disadvantages
•CPU scheduling is required.
•To accommodate many jobs in memory, memory management is required.
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.
Real-Time Systems
• Often used as a control device in a dedicated application such as controlling scientific
experiments, medical imaging systems, industrial control systems, and some display systems.
• Well-defined fixed-time constraints.
• Hard real-time system. - Hard real-time systems guarantee that critical tasks complete on
time. In hard real-time systems, secondary storage is limited or missing and the data is stored
in ROM. In these systems, virtual memory is almost never found.
• Soft real-time system - Soft real-time systems are less restrictive. A critical real-time task gets
priority over other tasks and retains the priority until it completes. Soft real-time systems have
limited utility than hard real-time systems. For example, multimedia, virtual reality, Advanced
Scientific Projects like undersea exploration and planetary rovers, etc.
Advantages
Failure of one processor does not affect the functioning of other processors.
It divides all the workload equally to the available processors.
Makes use of available resources efficiently.
Disadvantages
Symmetrical multiprocessing OS are more complex.
They are more costlier.
Synchronization between multiple processors is difficult.
• 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/17/2025 Ms. Rashmi Bhardwaj OS Unit Number:1 62
Types of Operating Systems(CO1)
Kernel (CO1)
What is Kernel:-
In computer science, Kernel is a computer program that is a core or heart of an operating
system. Before discussing kernel in detail, let's first understand its basic, i.e., Operating
system in a computer.
As discussed above, Kernel is the core part of an OS(Operating system); hence it has full
control over everything in the system. Each operation of hardware and software is managed
and administrated by the kernel.
It acts as a bridge between applications and data processing done at the hardware level. It is
the central component of an OS.
It is the part of the OS that always resides in computer memory and enables the
communication between software and hardware components.
It manages other tasks also such as memory management, task management, and disk
management.
A kernel is kept and usually loaded into separate memory space, known as protected
Kernel space. It is protected from being accessed by application programs or less important
parts of OS.
Other application programs such as browser, word processor, audio & video player use
separate memory space known as user-space.
Due to these two separate spaces, user data and kernel data don't interfere with each other
and do not cause any instability and slowness.
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.
Introduction to Linux
Linux is an open-source Unix-like operating system-based family on the Linux kernel, and the OS kernel was first
published on 17 September 1991 by Linus Torvalds. Typically, Linux is packaged as the Linux distribution, which
contains the supporting libraries and system software and kernel, several of which are offered by the GNU
Project.
Design of Linux OS
Various open-source developers admit that the Linux kernel was not developed but instead evolved from natural
selection. A Linux-based system is a compatible Unix-like OS, derived much of its common design from principles
made in Unix during the 1970s and 1980s.
4. Control Structures
Control structures allow the execution flow of the script to change based on conditions.
Conditional Statements:
If-Else:
if [ condition ]; then # commands elif [ condition ]; then # commands else # commands fi
Example:
#!/bin/bash if [ $1 -gt 10 ]; then echo "Greater than 10" else echo "10 or less" fi
Case Statement:
case $variable in pattern1) # commands ;; pattern2) # commands ;; *) # default commands ;; esac
Loops:
For Loop:
for var in list; do # commands done
While Loop:
while [ condition ]; do # commands done
Until Loop:
until [ condition ]; do # commands done
• https://www.youtube.com/playlist?list=PLBlnK6fEyqRiVhbXDGLXDk_OQAeuVcp2O
• https://nptel.ac.in/courses/106108101
Summary of UNIT 1
In this module,
we have studied the following: