1 Unit Notes - 21CSC202J Operating System
1 Unit Notes - 21CSC202J Operating System
UNIT-1
An Operating System acts as a communication bridge (interface) between the user and computer
hardware. The purpose of an operating system is to provide a platform on which a user can execute
programs conveniently and efficiently.
An operating system is a piece of software that manages the allocation of Computer Hardware. The
coordination of the hardware must be appropriate to ensure the correct working of the computer system
and to prevent user programs from interfering with the proper working of the system.
The main goal of the Operating System is to make the computer environment more convenient to use and
the Secondary goal is to use the resources most efficiently.
What is an Operating System?
An operating system is a program on which application programs are executed and acts as a
communication bridge (interface) between the user and the computer hardware. The main task an
operating system carries out is the allocation of resources and services, such as the allocation of memory,
devices, processors, and information. The operating system also includes programs to manage these
resources, such as a traffic controller, a scheduler, a memory management module, I/O programs, and a
file system.
Why are Operating Systems Used?
Operating System is used as a communication channel between the Computer hardware and the user. It
works as an intermediate between System Hardware and End-User. Operating System handles the
following responsibilities:
● It controls all the computer resources.
● It provides valuable services to user programs.
● It coordinates the execution of user programs.
● It provides resources for user programs.
● It provides an interface (virtual machine) to the user.
● It hides the complexity of software.
● It supports multiple execution modes.
● It monitors the execution of user programs to prevent errors.
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 the 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 processors work by allocating carious 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
SRM Institute of Science and Technology, Ramapuram
controller. Allocates the CPU that is a processor to a process. De-allocates processor when a process is no
more required.
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. Decides 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.
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. Following security measures are used to protect
user data:
● Protection against unauthorized access through login.
● Protection against intrusion by keeping firefall active.
● Protecting the system memory against malicious access.
● Displaying messages related to system vulnerabilities.
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/
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.
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
The OS provides network connectivity and manages communication between computers on a network. It
also manages network security by providing firewalls and other security measures.
Services Provided by an Operating System
The Operating System provides certain services to the users which can be listed in the following manner:
● 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.
● Error Detection and Handling: The Operating System is responsible for the detection of any type
of error or bugs that can occur while any task. The well-secured OS sometimes also acts as a
countermeasure for preventing any sort of breach of the Computer System from any external source
and probably handling them.
● 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.
● System Services: The operating system provides various system services, such as printing, time and
date management, and event logging.
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.
An Operating System provides services to both the users and to the programs.
● It provides programs an environment to execute.
● It provides users the services to execute the programs in a convenient manner.
Following are a few common services provided by an operating system −
● Program execution
● I/O operations
● File System manipulation
● Communication
● Error Detection
● Resource Allocation
● Protection
Program execution
Operating systems handle many kinds of activities from user programs to system programs like printer
spooler, name servers, file server, etc. Each of these activities is encapsulated as a process.
A process includes the complete execution context (code to execute, data to
manipulate, registers, OS resources in use). Following are the major
activities of an operating system with respect to program management −
● Loads a program into memory.
● Executes the program.
● Handles program's execution.
● Provides a mechanism for process synchronization.
● Provides a mechanism for process communication.
● Provides a mechanism for deadlock handling.
I/O Operation
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.
File system manipulation
A file represents a collection of related information. Computers can store files on the disk (secondary
storage), for long-term storage purpose. Examples of storage media include magnetic tape, magnetic disk
and optical disk drives like CD, DVD. Each of these media has its own properties like speed, capacity,
data transfer rate and data access methods.
SRM Institute of Science and Technology, Ramapuram
A file system is normally organized into directories for easy navigation and
usage. These directories may contain files and other directions. Following
are the major activities of an operating system with respect to file
management −
● Program needs to read a file or write a file.
● The operating system gives the permission to the program for operation on file.
● Permission varies from read-only, read-write, denied and so on.
● Operating System provides an interface to the user to create/delete files.
● Operating System provides an interface to the user to create/delete directories.
● Operating System provides an interface to create the backup of file system.
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.
Protection
Considering a computer system having multiple users and concurrent execution of multiple processes, the
various processes must be protected from each other's activities.
Protection refers to a mechanism or a way to control the access of programs,
processes, or users to the resources defined by a computer system.
Following are the major activities of an operating system with respect to
protection −
● The OS ensures that all access to system resources is controlled.
● The OS ensures that external I/O devices are protected from invalid access attempts.
● The OS provides authentication features for each user by means of passwords.
SRM Institute of Science and Technology, Ramapuram
As already mentioned, in addition to the hardware, a computer also needs a set of programs—an operating
system—to control the devices. This page will discuss the following:
▪ There are different kinds of operating systems: such as Windows, Linux and Mac OS
▪ There are also different versions of these operating systems, e.g. Windows 10 and 11
▪ Operating systems can be used with different user interfaces (UI): text user interfaces (TUI)
and graphical user interfaces (GUI) as examples
▪ Graphical user interfaces have many similarities in different operating systems: such as the
start menu, desktop etc.
When you can recognize the typical parts of each operating system’s user interface, you will mostly be
able to use both Windows and Linux as well as e.g. Mac OS.
An operating system (OS) is a set of programs which ensures the interoperability of the hardware and
software in your computer. The operating system enables, among other things,
Over the years, several different operating systems have been developed for different purposes. The most
typical operating systems in ordinary computers are Windows, Linux and Mac OS.
WINDOWS
The name of the Windows OS comes from the fact that programs are run in “windows”: each program has
its own window, and you can have several programs open at the same time. Windows is the most popular
OS for home computers, and there are several versions of it. The newest version is Windows 11.
In addition to servers, Linux is widely used in home computers, since there are a great number of free
programs for it (for text and image processing, spreadsheets, publishing, etc.). Over the years, many
different versions of Linux have become available for distribution, most of which are free for the user
(such as Ubuntu, Fedora and Mint, to name a few).
Linux can be installed on a PC as the only operating system or alongside Windows, so that each time the
machine is started, the user selects either one. Linux may also be used on a virtual computer from the
Windows environment, or vice versa, Windows from Linux.
MAC OS X
Apple’s Mac computers have their own operating system, OS X. Most of the programs that are available
for PCs are also available for Macs running under OS X, but these two types of computers cannot use the
exact same programs: for example, you cannot install the Mac version of the Microsoft Office suite on a
Windows computer. You can install other operating systems on Mac computers, but the OS X is only
available for computers made by Apple. Apple’s lighter portable devices (iPads, iPhones) use a light
version of the same operating system, called iOS.
Mac computers are popular because OS X is considered fast, easy to learn and very stable and Apple’s
devices are considered well-designed—though rather expensive.
ANDROID
Android is an operating system designed for phones and other mobile devices. Android is not available
for desktop computers, but in mobile devices it is extremely popular: more than a half of all mobile devices
in the world run on Android.
USER INTERFACES
A user interface (UI) refers to the part of an operating system, program, or device that allows a user to
enter and receive information. A text-based user interface (see the image to the left) displays text, and
its commands are usually typed on a command line using a keyboard. With a graphical user
interface (see the right-hand image), the functions are carried out by clicking or moving buttons, icons
and menus by means of a pointing device.
To display the text-based Command Prompt in Windows, open the Start menu and type cmd. Press Enter on
the keyboard to launch the command prompt in a separate window. With the command prompt, you can type
your commands from the keyboard instead of using the mouse.
GRAPHICAL USER INTERFACE
In most operating systems, the primary user interface is graphical, i.e. instead of typing the commands
you manipulate various graphical objects (such as icons) with a pointing device. The underlying principle
of different graphical user interfaces (GUIs) is largely the same, so by knowing how to use a Windows
UI, you will most likely know how to use Linux or some other GUI.
1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication
Now, you will learn about all the different types of system calls one-by-one.
Process Control
Process control is the system call that is used to direct the processes. Some process control examples
include creating, load, abort, end, execute, process, terminate the process, etc.
File Management
File management is a system call that is used to handle the files. Some file management examples include
creating files, delete files, open, close, read, write, etc.
SRM Institute of Science and Technology, Ramapuram
Device Management
Device management is a system call that is used to deal with devices. Some examples of device
management include read, device, write, get device attributes, release device, etc.
Information Maintenance
Information maintenance is a system call that is used to maintain information. There are some examples
of information maintenance, including getting system data, set time or date, get time or date, set system
data, etc.
Communication
Communication is a system call that is used for communication. There are some examples of
communication, including create, delete communication connections, send, receive messages, etc.
open()
The open() system call allows you to access a file on a file system. It allocates resources to the file and
provides a handle that the process may refer to. Many processes can open a file at once or by a single
process only. It's all based on the file system and structure.
read()
It is used to obtain data from a file on the file system. It accepts three arguments in general:
SRM Institute of Science and Technology, Ramapuram
o A file descriptor.
o A buffer to store read data.
o The number of bytes to read from the file.
The file descriptor of the file to be read could be used to identify it and open it using open() before reading.
wait()
In some systems, a process may have to wait for another process to complete its execution before
proceeding. When a parent process makes a child process, the parent process execution is suspended until
the child process is finished. The wait() system call is used to suspend the parent process. Once the child
process has completed its execution, control is returned to the parent process.
write()
It is used to write data from a user buffer to a device like a file. This system call is one way for a program
to generate data. It takes three arguments in general:
o A file descriptor.
o A pointer to the buffer in which data is saved.
o The number of bytes to be written from the buffer.
fork()
Processes generate clones of themselves using the fork() system call. It is one of the most common ways
to create processes in operating systems. When a parent process spawns a child process, execution of the
parent process is interrupted until the child process completes. Once the child process has completed its
execution, control is returned to the parent process.
close()
It is used to end file system access. When this system call is invoked, it signifies that the program no
longer requires the file, and the buffers are flushed, the file information is altered, and the file resources
are de-allocated as a result.
exec()
When an executable file replaces an earlier executable file in an already executing process, this system
function is invoked. As a new process is not built, the old process identification stays, but the new process
replaces data, stack, data, head, etc.
exit()
The exit() is a system call that is used to end program execution. This call indicates that the thread
execution is complete, which is especially useful in multi-threaded environments. The operating system
reclaims resources spent by the process following the use of the exit() system function.
Operating System Design and Implementation
Computer ScienceMCAOperating System
An operating system is a construct that allows the user application programs to interact with the system
hardware. Operating system by itself does not provide any function but it provides an atmosphere in
which different applications and programs can do useful work.
There are many problems that can occur while designing and implementing an operating system. These
are covered in operating system design and implementation.
SRM Institute of Science and Technology, Ramapuram
An operating system is a construct that allows the user application programs to interact with the system
hardware. Since the operating system is such a complex structure, it should be created with utmost care
so it can be used and modified easily. An easy way to do this is to create the operating system in parts.
Each of these parts should be well defined with clear inputs, outputs and functions.
Simple Structure
There are many operating systems that have a rather simple structure. These started as small systems and
rapidly expanded much further than their scope. A common example of this is MS-DOS. It was designed
simply for a niche amount for people. There was no indication that it would become so popular.
An image to illustrate the structure of MS-DOS is as follows −
It is better that operating systems have a modular structure, unlike MS-DOS. That would lead to greater
control over the computer system and its various applications. The modular structure would also allow
the programmers to hide information as required and implement internal routines as they see fit without
changing the outer specifications.
Layered Structure
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 −
SRM Institute of Science and Technology, Ramapuram
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 structure 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.
Operating System Debugging
The automatic creation of the core dump files can be disabled by the users. This may be done to improve
performance, clear disk space or increase security.
Crash Dump Files
In the event of a total system failure, the information about the state of
the operating system is captured in crash dump files. There are three types
of dump that can be captured when a system crashes. These are −
Complete Memory Dump
The whole contents of the physical memory at the time of the system crash are captured in the complete
memory dump. This is the default setting on the Windows Server System.
Kernel Memory Dump
Only the kernel mode read and write pages that are present in the main memory at the time of the system
crash are stored in the kernel memory dump.
Small Memory Dump
This memory dump contains the list of device drivers, stop code, process and thread information, kernel
stack etc.
Trace Listings
The trace listing record information about a program execution using logging. This information is used
by programmers for debugging. System administrators and technical personnel can use the trace listings
to find the common problems with software using software monitoring tools.
Profiling
This is a type of program analysis that measures various parameters in a program such as space and time
complexity, frequency and duration of function calls, usage of specific instructions etc. Profiling is done
by monitoring the source code of the required system program using a code profiler.
Operating Systems have evolved over the years. So, their evolution through
the years can be mapped using generations of operating systems. There are
four generations of operating systems. These can be described as follows −
SRM Institute of Science and Technology, Ramapuram
The process of returning a computer from a state of sleep does not involve booting; however, restoring it
from a state of hibernation does. Minimally, some embedded systems do not require a noticeable boot
sequence to begin functioning and, when turned on, may run operational programs that are stored in ROM.
All computer systems are state machines and a reboot may be the only method to return to a designated
zero-state from an unintended, locked state.
In addition to loading an operating system or stand-alone utility, the boot process can also load a storage
dump program for diagnosing problems in an operating system.
Advertisement
Sequencing of Booting
Booting is a start-up sequence that starts the operating system of a computer when it is turned on. A boot
sequence is the initial set of operations that the computer performs when it is switched on. Every computer
has a boot sequence.
1. Boot Loader: Computers powered by the central processing unit can only execute code found in the
system's memory. Modern operating systems and application program code and data are stored on
nonvolatile memories. When a computer is first powered on, it must initially rely only on the code and
data stored in nonvolatile portions of the system's memory. The operating system is not really loaded at
boot time, and the computer's hardware cannot perform many complex systems actions.
SRM Institute of Science and Technology, Ramapuram
The program that starts the chain reaction that ends with the entire operating system being loaded is the
boot loader or bootstrap loader. The boot loader's only job is to load other software for the operating
system to start.
2. Boot Devices: The boot device is the device from which the operating system is loaded. A modern PC
BIOS (Basic Input/Output System) supports booting from various devices. These include the local hard
disk drive, optical drive, floppy drive, a network interface card, and a USB device. The BIOS will allow
the user to configure a boot order. If the boot order is set to:
o CD Drive
o Hard Disk Drive
o Network
The BIOS will try to boot from the CD drive first, and if that fails, then it will try to boot from the hard
disk drive, and if that fails, then it will try to boot from the network, and if that fails, then it won't boot at
all.
3. Boot Sequence: There is a standard boot sequence that all personal computers use. First, the CPU runs
an instruction in memory for the BIOS. That instruction contains a jump instruction that transfers to the
BIOS start-up program. This program runs a power-on self-test (POST) to check that devices the computer
will rely on are functioning properly. Then, the BIOS goes through the configured boot sequence until it
finds a bootable device. Once BIOS has found a bootable device, BIOS loads the bootsector and transfers
execution to the boot sector. If the boot device is a hard drive, it will be a master boot record (MBR).
The MBR code checks the partition table for an active partition. If one is found, the MBR code loads that
partition's boot sector and executes it. The boot sector is often operating system specific, and however, in
most operating systems, its main function is to load and execute the operating system kernel, which
continues start-up. Suppose there is no active partition, or the active partition's boot sector is invalid. In
that case, the MBR may load a secondary boot loader which will select a partition and load its boot sector,
which usually loads the corresponding operating system kernel.
Types of Booting
There are two types of booting in an operating system.
1. Cold Booting: When the computer starts for the first time or is in a shut-down state and switch
on the power button to start the system, this type of process to start the computer is called cold
booting. During cold booting, the system will read all the instructions from the ROM (BIOS) and
the Operating System will be automatically get loaded into the system. This booting takes more
time than Hot or Warm Booting.
2. Warm Booting: Warm or Hot Booting process is when computer systems come to no response
or hang state, and then the system is allowed to restart during on condition. It is also referred to
as rebooting. There are many reasons for this state, and the only solution is to reboot the computer.
Rebooting may be required when we install new software or hardware. The system requires a
reboot to set software or hardware configuration changes, or sometimes systems may behave
abnormally or may not respond properly. In such a case, the system has to be a force restart. Most
commonly Ctrl+Alt+Del button is used to reboot the system. Else, in some systems, the external
reset button may be available to reboot the system.
SRM Institute of Science and Technology, Ramapuram
Step 1: Once the computer system is turned on, BIOS (Basic Input /Output System) performs a series of
activities or functionality tests on programs stored in ROM, called on POST (Power-on Self Test) that
checks to see whether peripherals in the system are in perfect order or not.
Step 2: After the BIOS is done with pre-boot activities or functionality test, it read bootable sequence
from CMOS (Common Metal Oxide Semiconductor) and looks for master boot record in the first physical
sector of the bootable disk as per boot device sequence specified in CMOS. For example, if the boot device
sequence is:
o Floppy Disk
o Hard Disk
o CDROM
Step 3: After this, the master boot record will search first in a floppy disk drive. If not found, then the
hard disk drive will search for the master boot record. But if the master boot record is not even present on
the hard disk, then the CDROM drive will search. If the system cannot read the master boot record from
any of these sources, ROM displays "No Boot device found" and halted the system. On finding the master
boot record from a particular bootable disk drive, the operating system loader, also called Bootstrap loader,
is loaded from the boot sector of that bootable drive· into memory. A bootstrap loader is a special program
that is present in the boot sector of a bootable drive.
Step 4: The bootstrap loader first loads the IO.SYS file. After this, MSDOS.SYS file is loaded, which is
the core file of the DOS operating system.
Step 5: After this, MSDOS.SYS file searches to find Command Interpreter in CONFIG.SYS file, and
when it finds, it loads into memory. If no Command Interpreter is specified in the CONFIG.SYS file,
the COMMAND.COM file is loaded as the default Command Interpreter of the DOS operating system.
Step 6: The last file is to be loaded and executed is the AUTOEXEC.BAT file that contains a sequence of
DOS commands. After this, the prompt is displayed. We can see the drive letter of bootable drive displayed
on the computer system, which indicates that the operating system has been successfully on the system
from that drive.
Once loaded, it can boot one of the operating systems available on the disk. The disk can have multiple
partitions, each containing a different type of operating system. When a computer system turns on, a boot
manager program displays a menu, allowing the user to choose the operating system to use.
—-------------------------------------------------------------------------------------------------------------