Os Unit-1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

OS UNIT-1

UNIT-1
OPERATING SYSTEMS

 OPERATING SYSTEM
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 like file management,
memory management, process management, handling input and output, and controlling
peripheral devices such as disk drives and printers.

An operating system is software that enables applications to interact with a computer's


hardware. The software that contains the core components of the operating system is called
the kernel.

The primary purposes of an Operating System are to enable applications (spftwares) to


interact with a computer's hardware and to manage a system's hardware and software
resources.

Some popular Operating Systems include Linux Operating System, Windows Operating
System, VMS, OS/400, AIX, z/OS, etc. Today, Operating systems is found almost in every
device like mobile phones, personal computers, mainframe computers, automobiles, TV,
Toys etc.

 Why are Operating Systems Used?


Between the user and the computer hardware, an operating system serves as a
communication bridge (interface). An operating system’s objective is to provide a platform
for a user to run programs in an efficient and convenient manner.

An OS is a piece of software that controls how computer hardware is allocated. Hardware


coordination must be appropriate to ensure the computer system’s proper operation and to
prevent user programs from interfering with the system’s proper operation.

Example: We request or convey our orders to the OS in the same way as a boss delivers
orders to his employees.

The primary purpose of the operating system is to make the computer environment more
user-friendly, with a secondary goal of maximising resource utilisation.

Page 1
OS UNIT-1

 FUNCTIONS OF OS

1. Security
To safeguard user data, the operating system employs password protection and other
related measures. It also protects programs and user data from illegal access.

2. Control over System Performance


The operating system monitors the overall health of the system in order to optimise
performance. To get a thorough picture of the system’s health, keep track of the time
between system responses and service requests. This can aid performance by providing
critical information for troubleshooting issues.

3. Job Accounting
The operating system maintains track of how much time and resources are consumed by
different tasks and users, and this data can be used to measure resource utilisation for a
specific user or group of users.

4. Error Detecting Aids


The OS constantly monitors the system in order to discover faults and prevent a computer
system from failing.

5. Coordination between Users and Other Software


Operating systems also organise and assign interpreters, compilers, assemblers, as well as
other software to computer users.

6. Memory Management
The operating system is in charge of managing the primary memory, often known as the
main memory. The main memory consists of a vast array of bytes or words, each of which is
allocated an address. Main memory is rapid storage that the CPU can access directly. A
program must first be loaded into the main memory before it can be executed. For memory
management, the OS performs the following tasks:
 The OS keeps track of primary memory – meaning, which user program can use which
bytes of memory, memory addresses that have already been assigned, as well as
memory addresses yet to be used.
 The OS determines the order in which processes would be permitted memory access
and for how long in multiprogramming.
 It allocates memory to the process when the process asks for it and deallocates memory
when the process exits or performs an I/O activity.

7. Process Management
The operating system determines which processes have access to the processor and how
much processing time every process has in a multiprogramming environment. Process
scheduling is the name for this feature of the operating system. For processor management,
the OS performs the following tasks:
 It keeps track of how processes are progressing.

Page 2
OS UNIT-1

 A traffic controller is a program that accomplishes this duty.


 Allocates a processor-based CPU to a process. When a process is no longer needed, the
processor is deallocated.

8. Device Management
A file system is divided into directories to make navigation and usage more efficient. Other
directories and files may be found in these directories. The file management tasks
performed by an operating system are: it keeps track of where data is kept, user access
settings, and the state of each file, among other things. The file system is the name given to
all of these features.

9. Services by OS
Furthermore, the operating system, in one form or another, provides certain services to the
computer system. The OS provides users with a number of services, which can be
summarised as follows:

1. Program Execution: The OS is in charge of running all types of programs, whether they
are user or system programs. The operating system makes use of a variety of resources to
ensure that all types of functions perform smoothly.

2. Handling Input/Output Operations: The operating system is in charge of handling


various types of inputs, such as those from the keyboard, mouse, and desktop. Regarding all
types of inputs and outputs, the operating system handles all interfaces in the most
appropriate manner.
3.
3. Manipulation of File System: The OS is in charge of deciding where data or files should
be stored, such as on a floppy disk, hard disk, or pen drive. The operating system
determines how data should be stored and handled.

4. Error Detection and Handling: The OS is in charge of detecting any errors or flaws that
may occur during any task. The well-secured OS can also operate as a countermeasure,
preventing and possibly handling any type of intrusion into the computer system from an
external source.

5. Resource Allocation: The operating system guarantees that all available resources are
properly utilised by determining which resource should be used by whom and for how long.
The operating system makes all of the choices.

6. Accounting: The operating system keeps track of all the functions that are active in the
computer system at any one time. The operating system keeps track of all the facts,
including the types of mistakes that happened.

7. Information and Resource Protection: The operating system is in charge of making the
most secure use of all the data and resources available on the machine. Any attempt by an
external resource to obstruct data or information must be foiled by the operating system.

Page 3
OS UNIT-1

 Approches or Structures of Operating System


An operating system has a complex structure, so we need a well-defined structure to assist
us in applying it to our unique requirements. Just as we break down a big problem into
smaller, easier-to-solve subproblems, designing an operating system in parts is a simpler
approach to do it. And each section is an Operating System component. The approach of
interconnecting and integrating multiple operating system components into the kernel can
be described as an operating system structure. As mentioned below, various sorts of
structures are used to implement operating systems.

1. Simple Structure
It is the simplest Operating System Structure and is not well defined; It can only be used for
small and limited systems. In this structure, the interfaces and levels of functionality are well
separated; hence programs can access I/O routines which can cause unauthorized access to
I/O routines.
 This structure is implemented in MS-DOS operating system:
 The MS-DOS operating System is made up of various layers, each with its own set of
functions.
 These layers are:
 Application Program
 System Program
 MS-DOS device drivers
 ROM BIOS device drivers
 Layering has an advantage in the MS-DOS operating system since all the levels can be
defined separately and can interact with each other when needed.
 It is easier to design, maintain, and update the system if it is made in layers. So that's
why limited systems with less complexity can be constructed easily using Simple
Structure.
 If one user program fails, the entire operating system gets crashed.
 The abstraction level in MS-DOS systems is low, so programs and I/O routines are
visible to the end-user, so the user can have unauthorized access.
Layering in simple structure is shown below:

Advantages of Simple Structure


 It is easy to develop because of the limited number of interfaces and layers.
 Offers good performance due to lesser layers between hardware and applications.

Disadvantages of Simple Structure


 If one user program fails, the entire operating system crashes.
 Abstraction or data hiding is not present as layers are connected and communicate with
each other.
 Layers can access the processes going in the Operating System, which can lead to data
modification and can cause Operating System to crash.

Page 4
OS UNIT-1

2. Layered Approach
In this type of structure, OS is divided into layers or levels. The hardware is on the bottom
layer (layer 0), while the user interface is on the top layer (layer N). These layers are
arranged in a hierarchical way in which the top-level layers use the functionalities of their
lower-level levels.

In this approach, functionalities of each layer are isolated, and abstraction is also available.
In layered structure, debugging is easier as it is a hierarchical model, so all lower-level
layered is debugged, and then the upper layer is checked. So all the lower layers are already
checked, and the current layer is to be checked only.

Below is the Image illustrating the Layered structure in OS:

Page 5
OS UNIT-1

Advantages of Layered Structure


 Each layer has its functionalities, so work tasks are isolated, and abstraction is present
up to some level.
 Debugging is easier as lower layers are debugged, and then upper layers are checked.

Disadvantages of Layered Structure


 In Layered Structure, layering causes degradation in performance.
 It takes careful planning to construct the layers since higher layers only utilize the
functions of lower layers.

3. Monolithic Structure
The Monolithic operating System in which the kernel acts as a manager by managing all
things like file management, memory management, device management, and operational
processes of the Operating System.

The kernel is the heart of a computer operating system (OS). Kernel delivers basic services
to all other elements of the System. It serves as the primary interface between the
Operating System and the hardware.

In monolithic systems, kernels can directly access all the resources of the operating System
like physical hardware, exp Keyboard, Mouse etc.

The monolithic kernel is another name for the monolithic operating system. Batch
processing and time-sharing maximize the usability of a processor by multiprogramming.
The monolithic kernel functions as a virtual machine by working on top of the Operating
System and controlling all hardware components. This is an outdated operating system that
was used in banks to accomplish minor activities such as batch processing and time-sharing,
which enables many people at various terminals to access the Operating System.

Advantages of Monolithic structure:


 It is simple to design and implement because all operations are managed by kernel only,
and layering is not needed.
 As services such as memory management, file management, process scheduling, etc.,
are implemented in the same address space, the execution of the monolithic kernel is
relatively fast as compared to normal systems. Using the same address saves time for
address allocation for new processes and makes it faster.

Disadvantages of Monolithic structure:


 If any service in the monolithic kernel fails, the entire System fails because, in address
space, the services are connected to each other and affect each other.
 It is not flexible, and to introduce a new service

Page 6
OS UNIT-1

A Diagram of the Monolithic structure is shown below:

4. 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.
For example, Solaris OS is organized as shown in the figure.

Page 7
OS UNIT-1

5. Micro-kernel
Micro-Kernel structure designs the Operating System by removing all non-essential
components of the kernel. These non-essential components of kernels are implemented as
systems and user programs. Hence these implemented systems are called as Micro-Kernels.

Each Micro-Kernel is made independently and is isolated from other Micro-Kernels. So this
makes the system more secure and reliable. If any Micro-Kernel fails, then the remaining
operating System remains untouched and works fine.

Advantages of Micro-kernel structure:


 It allows the operating system to be portable between platforms.
 As each Micro-Kernel is isolated, it is safe and trustworthy.
 Because Micro-Kernels are smaller, they can be successfully tested.
 If any component or Micro-Kernel fails, the remaining operating System is unaffected
and continues to function normally.

Disadvantages of Micro-kernel structure:


 Increased inter-module communication reduces system performance.
 System is complex to be constructed.

Page 8
OS UNIT-1

 OPERATING SYSTEM OPERATIONS


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.
The major operations of the operating system are process management, memory
management, device management and file management. These are given in detail as
follows:
Definition
An operating system is a program that acts as an interface between the user and the
computer hardware and controls the execution of all kinds of programs.

Page 9
OS UNIT-1

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

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

Page 10
OS UNIT-1

 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.
 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 ENVIRONMENTS
Computing Environments : When a problem is solved by the computer, during that
computer uses many devices, arranged in different ways and which work together to solve
problems. This constitutes a computing environment where various number of computer
devices arranged in different ways to solve different types of problems in different ways. In
different computing environments computer devices are arranged in different ways and
they exchange information in between them to process and solve problem. One computing
environment consists of many computers other computational devices, software and
networks that to support processing and sharing information and solving task. Based on the
organization of different computer devices and communication processes there exists
multiple types of computing environments.

Types of Computing Environments : There are the various types of computing


environments. They are :
1. Personal Computing Environment : In personal computing environment there is a
stand-alone machine. Complete program resides on computer and executed there. Different
stand-alone machines that constitute a personal computing environment are laptops,
mobiles, printers, computer systems, scanners etc. That we use at our homes and offices.

2. Time-Sharing Computing Environment : In Time Sharing Computing Environment


multiple users share system simultaneously. Different users (different processes) are allotted
different time slice and processor switches rapidly among users according to it. For example,
student listening to music while coding something in an IDE. Windows 95 and later versions,

Page 11
OS UNIT-1

Unix, IOS, Linux operating systems are the examples of this time sharing computing
environment.

3. Client Server Computing Environment : In client server computing environment


two machines are involved i.e., client machine and server machine, sometime same machine
also serve as client and server. In this computing environment client requests
resource/service and server provides that respective resource/service. A server can provide
service to multiple clients at a time and here mainly communication happens through
computer network.

4. Distributed Computing Environment : In a distributed computing environment


multiple nodes are connected together using network but physically they are separated. A
single task is performed by different functional units of different nodes of distributed unit.
Here different programs of an application run simultaneously on different nodes, and
communication happens in between different nodes of this system over network to solve
task.

5. Grid Computing Environment : In grid computing environment, multiple computers


from different locations works on single problem. In this system set of computer nodes
running in cluster jointly perform a given task by applying resources of multiple
computers/nodes. It is network of computing environment where several scattered
resources provide running environment for single task.

Page 12
OS UNIT-1

6. Cloud Computing Environment : In cloud computing environment on demand


availability of computer system resources like processing and storage are availed. Here
computing is not done in individual technology or computer rather it is computed in cloud
of computers where all required resources are provided by cloud vendor. This environment
primarily comprised of three services i.e software-as-a-service (SaaS), infrastructure-as-a-
service (IaaS), and platform-as-a-service (PaaS).

7. Cluster Computing Environment : In cluster computing environment cluster


performs task where cluster is a set of loosely or tightly connected computers that work
together. It is viewed as single system and performs task parallelly that’s why also it is
similar to parallel computing environment. Cluster aware applications are especially used in
cluster computing environment.

Advantages of different computing environments:


 Mainframe: High reliability, security, and scalability, making it suitable for mission-
critical applications.
 Client-Server: Easy to deploy, manage and maintain, and provides a centralized point
of control.
 Cloud Computing: Cost-effective and scalable, with easy access to a wide range of
resources and services.
 Mobile Computing: Allows users to access information and applications from
anywhere, at any time.
 Grid Computing: Provides a way to harness the power of multiple computers for large-
scale computations.
 Embedded Systems: Enable the integration of software into devices and products,
making them smarter and more functional.

Disadvantages of different computing environments:


 Mainframe: High cost and complexity, with a significant learning curve for developers.
 Client-Server: Dependence on network connectivity, and potential security risks from
centralized data storage.
 Cloud Computing: Dependence on network connectivity, and potential security and
privacy concerns.
 Mobile Computing: Limited processing power and memory compared to other
computing environments, and potential security risks.
 Grid Computing: Complexity in setting up and managing the grid infrastructure.
 Embedded Systems: Limited processing power and memory, and the need for
specialized skills for software development.

Page 13
OS UNIT-1

 OPEN-SOURCE OPERATING SYSTEM


The term "open source" refers to computer software or applications where the owners or
copyright holders enable the users or third parties to use, see, and edit the product's source
code. The source code of an open-source OS is publicly visible and editable. The usually
operating systems such as Apple's iOS, Microsoft's Windows, and Apple's Mac OS are
closed operating systems. Open-Source Software is licensed in such a way that it is
permissible to produce as many copies as you want and to use them wherever you like. It
generally uses fewer resources than its commercial counterpart because it lacks any code
for licensing, promoting other products, authentication, attaching advertisements, etc.

The open-source operating system allows the use of code that is freely distributed and
available to anyone and for commercial purposes. Being an open-source application or
program, the program source code of an open-source OS is available. The user may modify
or change those codes and develop new applications according to the user requirement.
Some basic examples of the open-source operating systems are Linux, Open Solaris, Free
RTOS, Open BDS, Free BSD, Minix, etc.

In 1997, the first Open-Source software was released. Despite the industry, there are now
Open-Source alternatives for every Software program. Thanks to technological
developments and innovations, many Open-Source Operating Systems have been
developed since the dawn of the 21st century.

 How does Open-Source Operating System work?


It works similarly to a closed operating system, except that the user may modify the source
code of the program or application. There may be a difference in function even if there is no
difference in performance.

For instance, the information is packed and stored in a proprietary (closed) operating
system. In open-source, the same thing happens. However, because the source code is
visible to you, you may better understand the process and change how data is processed.

While the former operating system is secure and hassle-free, and the latter requires some
technical knowledge, you may customize these and increase performance. There is no
specific way or framework for working on the open-source OS, but it may be customized on
the user requirements.

 Best Open-Source Operating System


Most of the open-source operating systems are Linux based. Some of the best open-source
operating systems are as follows:

Page 14
OS UNIT-1

1. Linux Kernel
Linux kernel was developed by Linus Torvalds. It offers the essential functions required for
an operating system, such as data cancellation, memory processing, and interactions with
computer hardware. It is open-source software, and many developers researched the source
code and produced a plethora of helpful plug-ins and operating systems to meet their
requirements.

2. Linux Lite
Linux Lite is another free and open-source operating system that can run on lower-end
hardware. It is a lightweight operating system designed to help users who are unfamiliar
with Linux-based operating systems. The operating system includes all of the required
programs, capabilities, tools, and desktops. It has a minimal interface and is entirely based
on the Ubuntu system. In the last five years, the operating system has been stable and has
received regular updates. It is efficiently functional soon after installation. After installation,
users are not required to install any further drivers. If you want a lightweight open-source
operating system on your PC, go with Linux Lite.

3.Linux mint
Linux Mint is a powerful Linux-based operating system that exudes modernity and power. It
is simple to use and includes complete multimedia capabilities, making it a user-friendly
open-source operating system. It is an Ubuntu-based distribution that is popular among
both beginners and experts. It is built on the Debian platform and includes one of the most
powerful software managers. It is more stable and has better visual aesthetics than Ubuntu.

4. FEDORA
Fedora is another popular Linux-based operating system, and it is widely considered the
best open-source operating system after Ubuntu. It is an RPM-based general-purpose
operating system that is supported by Red Hat and built by the Fedora Project community.
Its purpose is to develop and share cutting-edge open-source technology for free. As a
result, Fedora developers prefer to make upstream improvements rather than create fixes
specifically for Fedora. Fedora developers' updates are available to all Linux distributions.

It has a GNOME-based desktop that may be customized. Fedora comes with a customizable
GNOME-based desktop. Its Fedora Spins feature allows you to customize and run several
user interfaces and desktop environments.

5. REACT OS
ReactOS is another free and open-source operating system that has nearly 1 million
downloads in over 100 countries. This community-based OS may run Windows apps,
making it an excellent alternative to the Windows operating system. Although ReactOS is
still growing, users, who love highly customizable operating systems, can select ReactOS.
However, the operating system is developer-focused.

Page 15
OS UNIT-1

6. SOLUS
Solus is a free and open-source operating system for your desktop computer. It's a new
operating system from the Linux family, released in 2012. More than 6000 registered users
are currently using the software. VLC, XChat, Transmission, Thunderbird, OpenShot Video
Editor, Firefox, Budgie desktop environment, and LibreOffice Suite are all included with
Solus. The most recent version of Solus, Solus 3, was released in August 2017.

7. CHROME OS
Chrome OS is a partly open-source operating system with various attractive features. It's a
part of the Chromium and Linux families, with features including better security,
compatibility for supported Android and Chrome apps, Aura windows manager, Google
cloud print, integrated media player, virtual desktop access, and cloud-based management.
The only issue with the operating system is that it only supports Nexus devices or its
hardware. As a result, if you're a Google fan, you'll love Chrome OS on a Chromebook.

 Advantages
1. Reliable and efficient
The open-source operating systems are most reliable and efficient. Thousands of eyes
monitor these because the source code is public. As a result, if there are any bugs or errors,
they are fixed by the best developers worldwide.

2. Cost-efficient
Most of the open-source operating systems are free. And some of them are far less
expensive than commercially closed products.

3. Flexibility
The great advantage is you may customize it as per your requirement. And there is creative
freedom.

 Disadvantages
1. Complicated
It is not as user-friendly as the ones that are closed. To use this software, you must have a
basic understanding of technology.

2, Security risk
Despite the defects having been detected, there is a risk of assaults because the attackers
have access to the source code.

3. No support
If you run across an issue, there is no customer support available to assist you.

Page 16
OS UNIT-1

SYSTEM STRUCTURES
 OPERATING SYSTEM 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 −

1. Program execution
2. I/O operations
3. File System manipulation
4. Communication
5. Error Detection
6. Resource Allocation
7. Protection

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

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

Page 17
OS UNIT-1

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

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.

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

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

6.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 −

Page 18
OS UNIT-1

 The OS manages all kinds of resources using schedulers.


 CPU scheduling algorithms are used for better utilization of CPU.

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

 OPERATING SYSTEM AND USER-INTERFACE


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.

THE ROLE OF OPERATING SYSTEM IN THE COMPUTER


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,

 the identification and activation of devices connected to the computer,


 the installation and use of programs, and
 the handling of files.

 DIFFERENT OPERATING SYSTEMS


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.

Page 19
OS UNIT-1

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

2. LINUX AND UNIX


Linux is an open-source OS, which means that its program code is freely available to
software developers. This is why thousands of programmers around the world have
developed Linux, and it is considered the most tested OS in the world. Linux has been very
much influenced by the commercial Unix OS.

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.

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

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

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

Page 20
OS UNIT-1

The images contain the same information: a directory listing of a computer. You can often
carry out the same tasks regardless of which kind of UI you are using.

6. TEXT USER INTERFACE (TUI)


Modern graphical user interfaces have evolved from text-based UIs. Some operating
systems, such as Linux, can still be used with a text-based user interface. In this case, the
commands are entered as text (e.g., “cat story.txt”).

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

Most GUIs have the following basic components:


 a start menu with program groups
 a taskbar showing running programs
 a desktop
 various icons and shortcuts.

Page 21
OS UNIT-1

 SYSTEM CALLS IN OS
System call is the special function that is used by the process to request action from the
operating system which cannot be carried out by normal function. System calls provide the
interface between the process and the operating system.

 What are System Calls in OS?


When the process is being run, if the process requires certain actions which need to be
carried out by Operating System, the process has to go call the function which can interact
with the kernel to complete the actions. This special type of function call is known as System
Calls in OS. System calls provide the interface so that the process can communicate with the
Operating System.

 How Does the System Call Work?


Professor: Before an understanding of the working of system calls in OS let us understand
the important concept of modes of operation.
In our computer system, we have two modes available.
1. User Mode: In this mode, execution is done on behalf of the user.
2. Monitor/Kernel-Mode: In this mode, execution is done on behalf of OS.

Page 22
OS UNIT-1

 So when the process is under execution process executes under user mode, but when
the process requires some os resources to complete the task, the process makes a
system call.
 System calls in OS are executed in kernel mode on a priority basis.
 On completion of the system call, the control is passed to process in user mode.
 The process continues the execution in user mode.

 Types of System Calls in OS


There are mainly 5 types of system calls available:
a) Process Control
b) File Management
c) Device Management
d) Information Maintenance
e) Communication

a) Process Control: It handles the system calls for process creation, deletion, etc. Examples
for process control system calls are: Load, Execute, Abort, Wait Signal events for process.

b) File Management: File manipulation events like Creating, Deleting, Reading Writing etc
are being classified under file management system calls.

c) Device Management: Device Management system calls are being used to request the
device, release the device, logically attach and detach the device.

Page 23
OS UNIT-1

d) Information Maintenance: This type of system call is used to maintain the information
about the system like time and date.

e) Communications: In order to have interprocess communications like send or receive the


message, create or delete the communication connections,to transfer status information etc
communication system calls are used.

 Example of System Calls in Windows and Unix

Types of System Calls Windows Linux


CreateProcess() fork()
Process Control ExitProcess() exit()
WaitForSingleObject() wait()

CreateFile() open()
ReadFile() read()
File Management WriteFile() write()
CloseHandle() close()

SetConsoleMode() ioctl()
Device Management ReadConsole() read()
WriteConsole() write()

GetCurrentProcessID() getpid()

Page 24
OS UNIT-1

Information Maintenance SetTimer() alarm()


Sleep() sleep()

CreatePipe() pipe()
Communication CreateFileMapping() shmget()
MapViewOfFile() mmap()

 As we can see in the diagram, initially, the process pushes the parameter onto the stack.
 After that, the read routine from the library is called, which puts the system call code
(unique code for each system call is assigned) into the register.
 Trap instruction is used which causes the transfer of control from user mode to kernel
mode.
 Kernel reads the system call code present in the register and finds out that the system
call is read, so the system call handler executes the read system call.
 After the execution of the read system call, the transfer is given back to the user mode.
 The library routine (Library routine is nothing but the line of codes that forms the library
and the functions in that can be called by the process so that we don't need to write the
function every time. Eg. max function) in user mode returns the output to the process
which called it.

Page 25
OS UNIT-1

 On receiving the output, the process continues to execute the next instruction.
Note: Trap is the kind of interrupt that is synchronous to the process for executing the
functionality.

 Rules for Passing Parameters in System Call


 The floating-point parameters can’t be passed as a parameter in the system call.
 Only a limited number of arguments can be passed in the system call.
 If there are more arguments, then they should be stored in the block of memory and
the address of that memory block is stored in the register.
 Parameters can be pushed and popped from the stack only by the operating system.

 Important System Calls Used in OS


1. wait(): There are scenarios where the current process needs to wait for another process
to complete the task. So to wait in this scenario, wait() system call is used.
2. fork(): This system call creates the copy of the process which has called it. The one
which has called fork is called the parent process and the newly created copy is called
the child process.
3. exec(): This system call is called when the running process wants to execute another
executable file. The process id remains the same while the other resources used by the
process are replaced by the newly created process.
4. kill(): Sometimes while working, we require to terminate a certain process. So kill
system call is called which sends the termination signal to the process.
5. exit(): When we are actually required to terminate the program, an exit system call is
used. The resources which are occupied by the process are released after invoking the
exit system call.

 Conclusion
 System call is the interface through which the process communicates with the system
call.
 Computer system operates in two modes: User Mode and Kernel Mode
 Process executes in user mode, and when a system call is made, the mode is switched to
kernel mode. Once the system call execution is completed, the control is passed back to
the process in user mode.
 System calls in OS are made by sending a trap signal to the kernel, which reads the
system call code from the register and executes the system call.
 Major type of sytem calls are Process Control, File Management, Device Management,
Information maintenance and Communicaiton.
 Rules for parameter passing while making a system call is it should not be a floating
number, a limited number of arguments should be passed and if arguments are more,
they should be stored in memory block and address of that memory block should be
passed, and the push, pop operations from the stack will be made only by the operating
system.
 wait(), fork(), exec(), kill() and exit() are few important system calls of our computer
system.

Page 26
OS UNIT-1

 SYSTEM PROGRAM
System Programming can be defined as the act of building Systems Software using System
Programming Languages. According to Computer Hierarchy, one which comes at last is
Hardware. Then it is Operating System, System Programs, and finally Application Programs.
Program Development and Execution can be done conveniently in System Programs. Some
of the System Programs are simply user interfaces, others are complex. It traditionally lies
between the user interface and system calls.

So here, the user can only view up-to-the System Programs he can’t see System Calls.
System Programs can be divided into these categories :

1.File Management –
A file is a collection of specific information stored in the memory of a computer system. File
management is defined as the process of manipulating files in the computer system, its
management includes the process of creating, modifying and deleting files.
 It helps to create new files in the computer system and placing them at specific
locations.
 It helps in easily and quickly locating these files in the computer system.
 It makes the process of sharing files among different users very easy and user-friendly.
 It helps to store files in separate folders known as directories.
 These directories help users to search files quickly or to manage files according to their
types of uses.
 It helps users to modify the data of files or to modify the name of files in directories.

Page 27
OS UNIT-1

2.Status Information –
Information like date, time amount of available memory, or disk space is asked by some
users. Others providing detailed performance, logging, and debugging information which is
more complex. All this information is formatted and displayed on output devices or printed.
Terminal or other output devices or files or a window of GUI is used for showing the output
of programs.

3.File Modification –
For modifying the contents of files we use this. For Files stored on disks or other storage
devices, we used different types of editors. For searching contents of files or perform
transformations of files we use special commands.

4.Programming-Language support –
For common programming languages, we use Compilers, Assemblers, Debuggers, and
interpreters which are already provided to users. It provides all support to users. We can run
any programming language. All languages of importance are already provided.

5.Program Loading and Execution –


When the program is ready after Assembling and compilation, it must be loaded into
memory for execution. A loader is part of an operating system that is responsible for
loading programs and libraries. It is one of the essential stages for starting a program.
Loaders, relocatable loaders, linkage editors, and Overlay loaders are provided by the
system.

6.Communications –
Virtual connections among processes, users, and computer systems are provided by
programs. Users can send messages to another user on their screen, User can send e-mail,
browsing on web pages, remote login, the transformation of files from one user to another.

Some examples of system program in O.S. are –

 Windows 10
 Mac OS X
 Ubuntu
 Linux
 Unix
 Android
 Anti-virus
 Disk formatting
 Computer language translators

Page 28
OS UNIT-1

 DEBUGGING
Operating system debugging is the process of identifying and resolving issues, errors, and
bugs within an operating system (OS). An operating system is a complex software layer that
manages hardware resources and provides various services to applications. Debugging an
OS involves finding and fixing problems that can cause crashes, glitches, performance
degradation, and other undesirable behaviors.

 Why do we need Debugging?


Debugging gets started when we start writing the code for the software program. It
progressively starts continuing in the consecutive stages to deliver a software product
because the code gets merged with several other programming units to form a software
product.

 Following are the benefits of Debugging:

 Debugging can immediately report an error condition whenever it occurs. It prevents


hampering the result by detecting the bugs in the earlier stage, making software
development stress-free and smooth.
 It offers relevant information related to the data structures that further helps in easier
interpretation.
 Debugging assist the developer in reducing impractical and disrupting information.
 With debugging, the developer can easily avoid complex one-use testing code to save
time and energy in software development.

 Steps involved in Debugging


Following are the different steps that are involved in debugging:

Page 29
OS UNIT-1

1. Identify the Error: Identifying an error in a wrong may result in the wastage of time. It
is very obvious that the production errors reported by users are hard to interpret, and
sometimes the information we receive is misleading. Thus, it is mandatory to identify
the actual error.
2. Find the Error Location: Once the error is correctly discovered, you will be required to
thoroughly review the code repeatedly to locate the position of the error. In general,
this step focuses on finding the error rather than perceiving it.
3. Analyze the Error: The third step comprises error analysis, a bottom-up approach that
starts from the location of the error followed by analyzing the code. This step makes it
easier to comprehend the errors. Mainly error analysis has two significant goals, i.e.,
evaluation of errors all over again to find existing bugs and postulating the uncertainty
of incoming collateral damage in a fix.
4. Prove the Analysis: After analyzing the primary bugs, it is necessary to look for some
extra errors that may show up on the application. By incorporating the test framework,
the fourth step is used to write automated tests for such areas.
5. Cover Lateral Damage: The fifth phase is about accumulating all of the unit tests for
the code that requires modification. As when you run these unit tests, they must pass.
6. Fix & Validate: The last stage is the fix and validation that emphasizes fixing the bugs
followed by running all the test scripts to check whether they pass.

 Debugging Strategies
 For a better understanding of a system, it is necessary to study the system in depth. It
makes it easier for the debugger to fabricate distinct illustrations of such systems that
are needed to be debugged.
 The backward analysis analyzes the program from the backward location where the
failure message has occurred to determine the defect region. It is necessary to learn the
area of defects to understand the reason for defects.
 In the forward analysis, the program tracks the problem in the forward direction by
utilizing the breakpoints or print statements incurred at different points in the program.
It emphasizes those regions where the wrong outputs are obtained.
 To check and fix similar kinds of problems, it is recommended to utilize past experiences.
The success rate of this approach is directly proportional to the proficiency of the
debugger.

 SYSTEMBOOT

The operating system is loaded via a bootstrapping procedure, often known as booting. An
operating system or other larger program, such as a boot loader, is loaded by this
application. The process of booting involves turning on a computer. The memory of the
CPU is empty when it is first turned on. After loading the operating system into the main
memory and turning on the computer, it is prepared to accept user commands. A
computer's operating system is launched during the booting process when it is turned on.
The initial collection of tasks the computer carries out when turned on is known as the boot
sequence.

Page 30
OS UNIT-1

Every computer has a boot process. The kernel is located, loaded into the main memory,
and executed by the bootstrap loader. In some systems, the kernel is loaded after a
straightforward bootstrap loader retrieves a more intricate boot program from the disk.
Restarting a computer is sometimes referred to as rebooting. Depending on whether the
power is interrupted throughout the process, rebooting can be "soft" or "hard." On some
PCs, a soft boot may optionally clear RAM to zero.

Hardware, such as pressing a button or software commands, can start hard and soft booting.
When the functioning runtime system, typically the operating system and a few applications,
is reached, booting in OS is complete.

 What is Booting in Operating System?


Our computer's devices receive power and are initialized when we push the power button.
Because RAM is a volatile memory, our primary memory, intended to store the instructions,
will initially be empty. So, the ROM, read-only, or non-volatile memory, will contain a small
set of instructions.

These instructions will be sent to the CPU, where they will be executed and used to inspect
every piece of system hardware. We will be alerted by beep sounds or even on-screen
notifications if there are any hardware issues. The hardware is tested, and then the booting
process of the operating system continues to load the operating system.

 Types of Booting
There are 2 types of Booting in computers there are: cold and warm booting.

1. Cold Booting
It is referred to as "cold booting" when a computer starts up for the first time or when it is
shut down, and the power button is pressed to restart the system. The operating system is
automatically loaded into the system during cold booting in the computer when the
machine reads all of the BIOS (ROM) instructions. Compared to hot or warm booting, this
booting takes longer.

2. Warm Booting
Computer systems can restart while powered on during hot booting or warm booting in
computers when they hang or reach a state of no response. An alternative term for it is
rebooting. The only remedy for this ailment, which has several reasons, is to restart the
computer.

We might need to reboot after installing new software or hardware. The system must be
restarted to apply software or hardware configuration changes; otherwise, it may perform
incorrectly or respond incorrectly. In this case, the system must be made to restart. Press the
keys Ctrl+Alt+Del to restart the computer. Otherwise, some systems might feature a reset
button on the outside that can be pressed to restart the device.

Let's understand the booting process of a computer step by step.

Page 31
OS UNIT-1

 Steps of Booting Process in Operating System


Here are the 6 steps in the booting process that take place during the booting process in
OS.

Step 1: BIOS is loaded


The first step involves turning on the power. It powers the essential parts, including the
processor and BIOS, with electricity.

Step 2: BIOS: Power on Self-Test


It is the first test run by the BIOS. Additionally, this test runs a preliminary examination of
the computer's main memory, disk drives, input/output devices, etc. Moreover, the system
emits a beep sound in case of any errors.

Step 3: Loading of OS
The bootable sequence stored in the CMOS (Common Metal Oxide Semiconductor) is read
by BIOS following the successful completion of POST. Based on the bootable sequence, it
will look for the Master Boot Record (MBR) on bootable devices such as floppy disks, CD-
ROMs, and hard disks.

A message saying "No Boot Device Found" will be displayed, and the system will crash if
MBR is not found in any of them. If MBR is discovered, the BIOS will launch a unique
application software called the Boot Loader, which will ultimately launch the operating
system.

Step 4: System Configuration


Device drivers are put into the memory after the OS is loaded to ensure the proper
operation of our gadgets.

Step 5: Loading System Utilities


In this step, system utilities like antivirus and volume control are loaded into the memory.

Step 6: User Authentication


The system will prompt the user to input their credentials if any user authentication is
configured. Once the system has received valid credentials, it will typically launch the GUI
shell or the CLI shell.

 Dual Booting of Operating System


Dual booting of operating system is installation of two operating systems on a single
computer, known as dual-booting. Numerous operating systems can be installed on such a
machine. To choose which operating system to boot, a boot loader familiar with various file
systems and operating systems can occupy the boot space.

Once it has been loaded, one of the operating systems on the disc can be booted. On the
disc, there may be several partitions, each of which houses a different operating system;

Page 32
OS UNIT-1

when a computer system boots in the operating system, a boot manager program displays
a menu so the user can choose the operating system to use.

 How Does a System Boot?


All system parts receive power and are initialized when the power button is pressed. The
CPU needs to execute instructions after being initialized. The BIOS, a brief collection of
instructions, is being loaded from ROM. After the Power-On Self-Test (POST) has been
completed, the BIOS locates the bootable sequence from the CMOS.

 It locates the first bootable device based on the bootable sequence.


 It loads instructions from the Master Boot Record, which is contained in logical Sector 0,
from the first bootable device.
 The information regarding the Boot Loader, which can load the Operating System, is
contained in this collection of instructions.
 This boot loader information relates to particular operating systems; for instance, GRUB
is the boot loader for Linux ( GRand Unified Bootloader).
 The operating system is subsequently loaded into memory by the boot loader.
 Finally, all critical system files and drivers are put into memory, and the operating
system is given control.

 Why Do We Need Booting?


Here are some reasons why the booting process is necessary.

 The booting prevents leaks of memory in the system


 It checks for updates and installs them
 RAM is flushed during the process
 Make small corrections to errors in the program

Page 33

You might also like