You are on page 1of 21

Operating System -Unit-I

An Operating System (OS) is an interface between a computer user and computer


hardware. An operating system is a software which performs all the basic tasks ...

Following are some of important functions of an operating System.

 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

Memory management refers to management of Primary Memory or Main Memory. Main


memory is a large array of words or bytes where each word or byte has its own address.

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.

An Operating System does the following activities for file management −

 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.

Other Important Activities

Following are some of the important activities that an Operating System performs −

 Security − By means of password and similar other techniques, it prevents


unauthorized access to programs and data.
 Control over system performance − Recording delays between request for a service
and response from the system.
 Job accounting − Keeping track of time and resources used by various jobs and users.
 Error detecting aids − Production of dumps, traces, error messages, and other
debugging and error detecting aids.
 Coordination between other softwares and users − Coordination and assignment of
compilers, interpreters, assemblers and other software to the various users of the
computer systems.
2
Types of operating system:

 Batch Operating System


 Multiprogramming Operating System
 Time-sharing Operating System
 Multiprocessor Operating System
 Distributed Operating System

o Client-server Systems.
o Peer-to-Peer system.
 Network Operating System
 Real-time Operating System

o Hard Real-time-Aircraft systems, Medical critical care System,


etc.
o Soft Real-time -Live stock price and Online Transaction System.
o Firm Real-time-Multimedia Applications.
 Mobile Operating System -Android, IOS, BlackBerry, WatchOS

Batch operating systems

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:

 Many users can share batch systems.


 There is little idle time for batch operating systems.
 It becomes possible to manage large workloads.
 It's easy to estimate how long a task will take to be completed.

Some notable disadvantages are:

 Batch operating systems are challenging to debug.


 Any failure of the system creates a backlog.
 It may be costly to install and maintain good batch operating systems.
 Batch operating systems are used for tasks such as managing payroll systems, data
entry and bank statements.

Time-sharing or multitasking operating systems

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:

 There's a quick response during task performance.


 It minimizes the idle time of the processor.
 All tasks get an equal chance of being accomplished.
 It reduces the chance of software duplication.

Some potential disadvantages of this system are:

 The user's data security might be a problem.


 System failure can lead to widespread failures.
 Problems in data communication may arise.
 The integrity of user programs is not assured.

Examples of time-sharing operating systems include Multics and Unix.

Distributed operating systems

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.

Potential advantages of distributed operating systems are:

 They allow remote working.


 They allow a faster exchange of data among users.
 Failure in one site may not cause much disruption to the system.
 They reduce delays in data processing.
 They minimize the load on the host computer.
 They enhance scalability since more systems can be added to the network.
 Potential disadvantages of distributed operating systems include:

Disadvantages:

 If the primary network fails, the entire system shuts down.


 They're expensive to install.
 They require a high level of expertise to maintain.
 Distributed operating systems are used for tasks such as telecommunication networks,
airline reservation controls and peer-to-peer networks.

Network operating systems

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.

Potential advantages of network operating systems are:

 Centralized servers provide high stability.


 Security issues are easier to handle through the servers.
 It's easy to upgrade and integrate new technologies.
 Remote access to the servers is possible.

Potential disadvantages of network operating systems are:

 They require regular updates and maintenance.


 Servers are expensive to buy and maintain.
 Users' reliance on a central server might be detrimental to workflows.
 Examples of network operating systems include Microsoft Windows, Linux and Mac
OS X.

Real-time operating systems

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.

Potential advantages of real-time operating systems include:

 They use device and systems maximally, hence more output.


 They allow fast shifting from one task to another.
 The focus is on current tasks, and less focus is put on the queue.
 They can be used in embedded systems.
 Real-time systems are meticulously programmed, hence free of errors.
 They allow easy allocation of memory.

Potential disadvantages of real-time operating systems are:

 They have a low capacity to run tasks simultaneously.


 They use heavy system resources.
 They run on complex algorithms that are not easy to understand.
 They're unsuitable for thread priority because of the system's inability to switch 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

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.

Potential advantages of mobile operating systems are:

 Most systems are easy for users to learn and operate.

Potential disadvantages of real-time operating systems are:

 Some mobile OS put a heavy drain on a device’s battery, requiring frequent


recharging.
 Some systems are not user-friendly.

Examples of mobile operating systems include Android OS, Apple and Windows mobile OS.

Here are the most common operating systems in use:

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

Created by the Finnish programmer Linus Torvalds, Linux is today developed by


programmer collaborators across the world who submit tweaks to the central kernel software.
Linux is popular with programmers and corporate servers. It is available for free online.

Types of Computing Environments

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.

The different types of Computing Environments are −

Computing Environment

Personal 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.

Distributed Computing Environment

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.

Client Server Computing Environment

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.

Peer to peer computing

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.

Cluster Computing Environment

The clustered computing environment is similar to parallel computing environment as


they both have multiple CPUs. However a major difference is that clustered systems
are created by two or more individual computer systems merged together which then
work parallel to each other

Cloud Computing Environment

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:

A real-time operating system (RTOS) is a special-purpose operating system used in


computers that has strict time constraints for any job to be performed. It is employed mostly
8
in those systems in which the results of the computations are used to influence a process
while it is executing. Whenever an event external to the computer occurs, it is communicated
to the computer with the help of some sensor used to monitor the event. The sensor produces
the signal that is interpreted by the operating system as an interrupt. On receiving an
interrupt, the operating system invokes a specific process or a set of processes to serve the
interrupt.

Types of Real-Time Operating System:

Hard Real-Time operating system:

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 Real-Time operating 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

Firm Real-Time operating system:

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,

Firm Real-Time operating system:

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.

The various examples of Real-time operating systems are:

 MTS
 Lynx
 QNX
 Vx Works etc.

Applications of Real-time operating system (RTOS):

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.

 Real-time running structures are used inside the Radar gadget.


 Real-time running structures are utilized in Missile guidance.
 Real-time running structures are utilized in on line inventory trading.
9
 Real-time running structures are used inside the cell phone switching gadget.
 Real-time running structures are utilized by Air site visitors to manipulate structures.
 Real-time running structures are used in Medical Imaging Systems.
 Real-time running structures are used inside the Fuel injection gadget.
 Real-time running structures are used inside the Traffic manipulate gadget.
 Real-time running structures are utilized in Autopilot travel simulators.

Different approaches or Structures of Operating Systems

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.

Diagram of the structure of MS-DOS is shown below.

Advantages of Simple structure:

 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:

 The structure is very complicated as no clear boundaries exists between modules.


 It does not enforce data hiding in the operating system.

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.

Advantages of Layered 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 is very easy to perform debugging and system verification.

Disadvantages of Layered structure:

In this structure the application performance is degraded as compared to simple structure.

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.

Advantages of Micro-kernel structure:

 It makes the operating system portable to various platforms.


 As microkernels are small so these can be tested effectively.

Disadvantages of Micro-kernel structure:

 Increased level of inter module communication degrades system performance.

Modular structure or approach:

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.

Virtualization computing environment

 Allows operating systems to run applications within other OSes


 Vast and growing industry
 Virtualization – OS natively compiled for CPU, running guest OSes also natively
compiled
 Consider VMware running WinXP guests, each running applications, all on native
WinXP host OS
 VMM (virtual machine Manager) provides virtualization services

13
Virtual machine software of 2022

 VMware Workstation Player.


 VirtualBox. Not all good things cost money. ...
 Parallels Desktop. The best Apple Mac virtuality. ...
 QEMU. A virtual hardware emulator. ...
 Citrix Hypervisor. A highly scalable solution from Citrix. ...
 Xen Project. ...
 Microsoft Hyper-V.

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.

A figure representing the execution of the system call is given as follows −

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.

In general, system calls are required in the following situations −

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?

A command can be a program, which in turn is comprised of functions, which


themselves can execute system calls. For example, the 'cp' command in Unix-like systems
copies files. Its implementation includes functions which perform the copying. Those
functions themselves execute system-calls like open() and read().

What is the difference between system call and API?

Image result for user command vs system call : pdf

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.

What is purpose of system call?

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.

Types of System Calls


There are mainly five types of system calls. These are explained in detail as follows −
Process Control: These system calls deal with processes such as process creation, process
termination etc.
File Management: These system calls are responsible for file manipulation such as creating
a file, reading a file, writing into a file etc.
Device Management: These system calls are responsible for device manipulation such as
reading from device buffers, writing into device buffers etc.
Information Maintenance: These system calls handle information and its transfer between
the operating system and the user program.
Communication: These system calls are useful for interprocess communication. They also
deal with creating and deleting a communication connection.

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.

What is the system program in OS?

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.

Types of System Programs

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.

Program Loading and Execution


The system programs that deal with program loading and execution make sure that programs
can be loaded into memory and executed correctly. Loaders and Linkers are a prime example
of this type of system programs.

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.

Programming Language Support

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.

System Boot Process:


The BIOS, operating system and hardware components of a computer system should all be
working correctly for it to boot. If any of these elements fail, it leads to a failed boot
sequence.

The following diagram demonstrates the steps involved in a system boot process −

Here are the steps −

 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.

Master Boot Record

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:

 verify CPU registers.


 verify the integrity of the BIOS code itself.
 verify some basic components like DMA, timer, interrupt controller.
 initialize, size, and verify system main memory.
 initialize BIOS
 What is Power On Self Test beep codes?
 POST Codes

20
What happens if power on self test fails?

Error Code Error Message Response

0047 Unknown BIOS error. Error code = 0047 Halt

0048 Password Check Failed Halt

0049 Unknown BIOS error. Error code = 0049 Halt

004A Unknown BIOS error. Error code = 004A Pause

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.

Where is bootstrap loader located?

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.

What is the difference between bootloader and bootstrap loader?

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

You might also like