Unit-I OS Notes (Updated)
Unit-I OS Notes (Updated)
Unit-I OS Notes (Updated)
Memory Management
Processor Management
Device Management
File Management
Security
Control over system performance
Job accounting
Error detecting aids
Coordination between other software and users
Memory Management
Main memory provides a fast storage that can be accessed directly by the CPU. For a
program to be executed, it must in the main memory. An Operating System does the
following activities for memory management −
Keeps tracks of primary memory, i.e., what part of it are in use by whom, what part
are not in use. In multiprogramming, the OS decides which process will get memory
when and how much.
Allocates the memory when a process requests it to do so.
De-allocates the memory when a process no longer needs it or has been terminated.
1
Processor Management
In multiprogramming environment, the OS decides which process gets the processor when
and for how much time. This function is called process scheduling. An Operating System
does the following activities for processor management −
Keeps tracks of processor and status of process. The program responsible for this task
is known as traffic controller.
Allocates the processor (CPU) to a process.
De-allocates processor when a process is no longer required.
Device Management
An Operating System manages device communication via their respective drivers. It does the
following activities for device management −
Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
Decides which process gets the device when and for how much time.
Allocates the device in the efficient way.
De-allocates devices.
File Management
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions.
Keeps track of information, location, uses, status etc. The collective facilities are often
known as file system.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.
Following are some of the important activities that an Operating System performs −
o Client-server Systems.
o Peer-to-Peer system.
Network Operating System
Real-time Operating System
The batch operating system does not have a direct link with the computer. A different system
divides and allocates similar tasks into batches for easy processing and faster response. The
batch operating system is appropriate for lengthy and time-consuming tasks. To avoid
slowing down a device, each user prepares their tasks offline and submits them to an
operator. Advantages of using a batch operating system include:
The time-sharing operating system, also known as a multitasking OS, works by allocating
time to a particular task and switching between tasks frequently. Unlike the batch system, the
time-sharing system allows users to complete their work in the system simultaneously. It
allows many users to be distributed across various terminals to minimize response time.
3
Potential advantages of time-sharing operating systems include:
This system is based on autonomous but interconnected computers communicating with each
other via communication lines or a shared network. Each autonomous system has its own
processor that may differ in size and function. A distributed operating system serves multiple
applications and multiple users in real-time. The data processing function is then distributed
across the processors.
Disadvantages:
Network operating systems are installed on a server providing users with the capability to
manage data, user groups and applications. This operating system enables users to access and
4
share files and devices such as printers, security software and other applications, mostly in a
local area network.
Real-time operating systems provide support to real-time systems that require observance of
strict time requirements. The response time between input, processing and response is tiny,
which is beneficial for processes that are highly sensitive and need high precision. These
processes include operating missile systems, medical systems or air traffic control systems,
where delays may lead to loss of life and property.
Real-time operating systems may either be hard real-time systems or soft real-time systems.
Hard real-time systems are installed in applications with strict time constraints. The system
guarantees the completion of sensitive tasks on time. Hard real-time does not have virtual
memory. Soft real-time systems do not have equally rigid time requirements. A critical task
gets priority over other tasks.
5
Real-time operating systems are used for tasks such as scientific experiments, medical
imaging, robotics and air traffic control operations.
Mobile operating systems run exclusively on small devices such as smartphones, tablets and
wearables. The system combines the features of a personal computer with additional features
useful for a handheld device. Mobile operating systems start when a device is powered on to
provide access to installed applications. Mobile operating systems also manage wireless
network connectivity.
Examples of mobile operating systems include Android OS, Apple and Windows mobile OS.
Microsoft Windows
Created by Microsoft, Microsoft Windows is one of the most popular proprietary operating
systems for computers in the world. Most personal computers come preloaded with a version
of Microsoft Windows. One downside of Windows is that compatibility with mobile phones
has been problematic.
Apple iOS
Apple iOS from Apple is used on smartphones and tablets manufactured by the same
company. Users of this system have access to hundreds of applications. The operating system
offers strong encryption capabilities to control unauthorized access to users' private data.
Google Android
Android from Google is the most popular operating system in the world. It's mainly used on
tablets and smartphones. It also runs on devices made by other manufacturers. Users have
access to numerous mobile applications available on the Google Play Store.
Apple macOS
Developed by Apple, this proprietary operating system runs on the manufacturer's personal
computers and desktops. All Apple and Macintosh computers come equipped with the latest
6
version of macOS, previously known as OS X systems. The ability to prevent bugs and fend
off hackers make Apple operating systems popular with their users.
Linux
A computer system uses many devices, arranged in different ways to solve many problems.
This constitutes a computing environment where many computers are used to process and
exchange information to handle multiple issues.
Computing Environment
In the personal computing environment, there is a single computer system. All the system
processes are available on the computer and executed there. The different devices that
constitute a personal computing environment are laptops, mobiles, printers, computer
systems, scanners etc.
7
Time Sharing Computing Environment
The time sharing computing environment allows multiple users to share the system
simultaneously. Each user is provided a time slice and the processor switches rapidly among
the users according to it. Because of this, each user believes that they are the only ones using
the system.
A distributed computing environment contains multiple nodes that are physically separate but
linked together using the network. All the nodes in this system communicate with each other
and handle processes in tandem. Each of these nodes contains a small part of the distributed
operating system software.
In client server computing, the client requests a resource and the server provides that
resource. A server may serve multiple clients at the same time while a client is in
contact with only one server. Both the client and server usually communicate via a
computer network but sometimes they may reside in the same system.
The peer to peer computing architecture contains nodes that are equal participants in
data sharing. All the tasks are equally divided between all the nodes. The nodes
interact with each other as required as share resources.
The computing is moved away from individual computer systems to a cloud of computers in
cloud computing environment. The cloud users only see the service being provided and not
the internal details of how the service is provided. This is done by pooling all the computer
resources and then managing them using a software.
Mobile Computing
Mobile Computing is a technology that allows transmission of data, voice and video via a
computer or any other wireless enabled device without having to be connected to a fixed
physical link.
Real-Time Computing:
In Hard RTOS, all critical tasks must be completed within the specified time duration, i.e.,
within the given deadline. Not meeting the deadline would result in critical failures such as
damage to equipment or even loss of human life. Ex.: Break, Air back, Aircraft, Autopilot
Plane, Medical critical care system
Soft RTOS accepts a few delays via the means of the Operating system. In this kind of
RTOS, there may be a closing date assigned for a particular job, but a delay for a small
amount of time is acceptable. So, cut off dates are treated softly via means of this kind of
RTOS. Ex. Stack Market price, Online transactions
In Firm RTOS additionally want to observe the deadlines. However, lacking a closing date
might not have a massive effect, however may want to purposely undesired effects, like a
massive discount within the fine of a product. Ex. Multimedia Applications,
In Firm RTOS additionally want to observe the deadlines. However, lacking a closing date
might not have a massive effect, however may want to purposely undesired effects, like a
massive discount within the fine of a product.
MTS
Lynx
QNX
Vx Works etc.
RTOS is used in real-time applications that must work within specific deadlines. Following
are the common areas of applications of Real-time operating systems are given below.
Operating system can be implemented with the help of various structures. The structure of the
OS depends mainly on how the various common components of the operating system are
interconnected and melded into the kernel. Depending on this we have following structures of
the operating system:
Simple structure:
Such operating systems do not have well defined structure and are small, simple and limited
systems. The interfaces and levels of functionality are not well separated. MS-DOS is an
example of such operating system. In MS-DOS application programs are able to access the
basic I/O routines. These types of operating system cause the entire system to crash if one of
the user programs fails.
It delivers better application performance because of the few interfaces between the
application program and the hardware.
Easy for kernel developers to develop such an operating system.
10
Disadvantages of Simple structure:
Layered structure:
An OS can be broken into pieces and retain much more control on system. In this structure
the OS is broken into number of layers (levels). The bottom layer (layer 0) is the hardware
and the topmost layer (layer N) is the user interface. These layers are so designed that each
layer uses the functions of the lower level layers only. This simplifies the debugging process
as if lower level layers are debugged and an error occurs during debugging then the error
must be on that layer only as the lower level layers have already been debugged.
The main disadvantage of this structure is that at each layer, the data needs to be modified
and passed on which adds overhead to the system. Moreover careful planning of the layers is
necessary as a layer can use only lower level layers. UNIX is an example of this structure.
Layering makes it easier to enhance the operating system as implementation of a layer can be
changed easily without affecting the other layers.
It requires careful planning for designing the layers as higher layers use the functionalities of
only the lower layers.
11
Micro-kernel:
This structure designs the operating system by removing all non-essential components from
the kernel and implementing them as system and user programs. This result in a smaller
kernel called the micro-kernel.
Advantages of this structure are that all new services need to be added to user space and does
not require the kernel to be modified. Thus it is more secure and reliable as if a service fails
then rest of the operating system remains untouched. Mac OS is an example of this type of
OS.
It is considered as the best approach for an OS. It involves designing of a modular kernel.
The kernel has only set of core components and other services are added as dynamically
loadable modules to the kernel either during run time or boot time. It resembles layered
structure due to the fact that each kernel has defined and protected interfaces but it is more
flexible than the layered structure as a module can call any other module.
12
For example Solaris OS is organized as shown in the figure.
13
Virtual machine software of 2022
Systems Calls:
The interface between a process and an operating system is provided by system calls. In
general, system calls are available as assembly language instructions. They are also
included in the manuals used by the assembly level programmers. System calls are
usually made when a process in user mode requires access to a resource. Then it requests
the kernel to provide the resource via a system call.
System Calls
As can be seen from this diagram, the processes execute normally in the user mode until a
system call interrupts this. Then the system call is executed on a priority basis in the kernel
mode. After the execution of the system call, the control returns to the user mode and
execution of user processes can be resumed.
o If a file system requires the creation or deletion of files. Reading and writing from
files also require a system call.
o Creation and management of new processes.
14
o Network connections also require system calls. This includes sending and receiving
packets.
o Access to a hardware devices such as a printer, scanner etc. requires a system call.
What is difference between system call and command?
The main difference between API and system call is that API is a set of protocols, routines,
functions that allow exchanging data among various applications and devices while a system
call is a method that allows a program to request services from the kernel.
System call provides the services of the operating system to the user programs via
Application Program Interface(API). It provides an interface between a process and operating
system to allow user-level processes to request services of the operating system. System calls
are the only entry points into the kernel system.
Some of the examples of all the above types of system calls in Windows and Unix are given
as follows −
Types of System Windows Linux
Calls
Process Control CreateProcess() fork()
ExitProcess() exit()
WaitForSingleObject() wait()
15
File Management CreateFile() open()
ReadFile() read()
WriteFile() write()
CloseHandle() close()
Device SetConsoleMode() ioctl()
Management ReadConsole() read()
WriteConsole() write()
Information GetCurrentProcessID() getpid()
Maintenance SetTimer() alarm()
Sleep() sleep()
Communication CreatePipe() pipe()
CreateFileMapping() shmget()
MapViewOfFile() mmap()
There are many different system calls as shown above. Details of some of those system calls
are as follows −
open()
The open() system call is used to provide access to a file in a file system. This system call
allocates resources to the file and provides a handle that the process uses to refer to the file. A
file can be opened by multiple processes at the same time or be restricted to one process. It all
depends on the file organisation and file system.
read()
The read() system call is used to access data from a file that is stored in the file system. The
file to read can be identified by its file descriptor and it should be opened using open() before
it can be read. In general, the read() system calls takes three arguments i.e. the file descriptor,
buffer which stores read data and number of bytes to be read from the file.
write()
The write() system calls writes the data from a user buffer into a device such as a file. This
system call is one of the ways to output data from a program. In general, the write system
calls takes three arguments i.e. file descriptor, pointer to the buffer where data is stored and
number of bytes to write from the buffer.
close()
The close() system call is used to terminate access to a file system. Using this system call
means that the file is no longer required by the program and so the buffers are flushed, the
file metadata is updated and the file resources are de-allocated.
The system program serves as a part of the operating system. It traditionally lies between the
user interface and the system calls. The user view of the system is actually defined by system
16
programs and not system calls because that is what they interact with and system programs
are closer to the user interface.
System programs can be divided into seven parts. These are given as follows:
Status Information
The status information system programs provide required data on the current or past status of
the system. This may include the system date, system time, available memory in system, disk
space, logged in users etc.
Communications
These system programs are needed for system communications such as web browsers. Web
browsers allow systems to communicate and access information from the network as
required.
File Manipulation
These system programs are used to manipulate system files. This can be done using various
commands like create, delete, copy, rename, print etc. These commands can create files,
delete files, copy the contents of one file into another, rename files, print them etc.
File Modification
17
System programs that are used for file modification basically change the data in the file or
modify it in some other way. Text editors are a big example of file modification system
programs.
Application Programs
Application programs can perform a wide range of services as per the needs of the users.
These include programs for database systems, word processors, plotting tools, spreadsheets,
games, scientific applications etc.
These system programs provide additional support features for different programming
languages. Some examples of these are compilers, debuggers etc. These compile a program
and make sure it is error free respectively.
The following diagram demonstrates the steps involved in a system boot process −
The CPU initializes itself after the power in the computer is first turned on. This is done
by triggering a series of clock ticks that are generated by the system clock.
After this, the CPU looks for the system’s ROM BIOS to obtain the first instruction in the
start-up program. This first instruction is stored in the ROM BIOS and it instructs the
system to run POST (Power On Self Test) in a memory address that is predetermined.
18
POST first checks the BIOS chip and then the CMOS RAM. If there is no battery failure
detected by POST, then it continues to initialize the CPU.
POST also checks the hardware devices, secondary storage devices such as hard drives,
ports etc. And other hardware devices such as the mouse and keyboard. This is done to
make sure they are working properly.
After POST makes sure that all the components are working properly, then the BIOS
finds an operating system to load.
In most computer system’s, the operating system loads from the C drive onto the hard
drive. The CMOS chip typically tells the BIOS where the operating system is found.
The order of the different drives that CMOS looks at while finding the operating system
is known as the boot sequence. This sequence can be changed by changing the CMOS
setup.
After finding the appropriate boot drive, the BIOS first finds the boot record which tells it
to find the beginning of the operating system.
After the initialization of the operating system, the BIOS copies the files into the memory.
Then the operating system controls the boot process.
In the end, the operating system does a final inventory of the system memory and loads
the device drivers needed to control the peripheral devices.
The users can access the system applications to perform various tasks.
19
BIOS:
The Basic Input Output System, or BIOS, is a very small piece of code contained on a chip
on your system board. When you start your computer, BIOS is the first software that runs. It
identifies your computer's hardware, configures it, tests it, and connects it to the operating
system for further instruction.
BIOS is the built-in core processor software responsible for booting up your system.
Typically embedded into your computer as a motherboard chip, the BIOS functions as a
catalyst for PC functionality action.
POST:
When power is turned on, POST (Power-On Self-Test) is the diagnostic testing sequence that
a computer's basic input/output system (or "starting program") runs to determine if the
computer keyboard, random access memory, disk drives, and other hardware are working
correctly.
The principal duties of the main BIOS during POST are as follows:
20
What happens if power on self test fails?
Bootstrap Loader:
Alternatively referred to as bootstrapping, bootloader, or boot program, a bootstrap loader is a
program that resides in the computer's EPROM, ROM, or another non-volatile memory. It is
automatically executed by the processor when turning on the computer.
The bootstrap loader is a programme that resides on the EPROM, ROM or other non-volatile
memory of the machine. It is executed by the processor automatically when the device is
turned on.
The difference between a bootloader and a bootstrap loader in this context is simple: The
bootloader controls the board upon power-up and does not rely on the Linux kernel in any
way. In contrast, the bootstrap loader's primary purpose in life is to act as the glue between a
board-level bootloader and the Linux kernel.
21