0% found this document useful (0 votes)
13 views21 pages

Os Unit 1

Uploaded by

Mohammed Razi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views21 pages

Os Unit 1

Uploaded by

Mohammed Razi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Operating System(OS)

An operating system (OS) is the program that, after being initially loaded into the computer by a
boot program, manages all of the other application programs in a computer. The application
programs make use of the operating system by making requests for services through a defined
application program interface. In addition, users can interact directly with the operating system
through a user interface, such as a command-line interface (CLI) or a graphical UI (GUI).

Objectives of OS

The primary goals of an operating system are as follows:

 Convenience – An operating system improves the use of a machine. Operating systems


enable users to get started on the things they wish to complete quickly without having to
cope with the stress of first configuring the system.

 Efficiency – An operating system enables the efficient use of resources. This is due to
less time spent configuring the system.

 Ability to evolve – An operating system should be designed in such a way that it allows
for the effective development, testing, and introduction of new features without
interfering with service.

 Management of system resources – It guarantees that resources are shared fairly


among various processes and users.

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.
An operating system is a construct that allows the user application programs to interact
with the system hardware. Since the operating system is such a complex structure, it should be
created with utmost care so it can be used and modified easily. An easy way to do this is to
create the operating system in parts. Each of these parts should be well defined with clear
inputs, outputs and functions.

Operating System Structure

 This article also covers different types of structures implementing Operating Systems as
mentioned below.

o Simple Structure

o Monolithic Structure

o Layered Approach Structure

o Micro-kernel Structure

1. Simple Structure

There are many operating systems that have a rather simple structure. These started as
small systems and rapidly expanded much further than their scope. A common example of this
is MS-DOS. It was designed simply for a niche amount for people. There was no indication that
it would become so popular.

An image to illustrate the structure of MS-DOS is as follows −

It is better that operating systems have a modular structure, unlike MS-DOS. That would
lead to greater control over the computer system and its various applications. The modular
structure would also allow the programmers to hide information as required and implement
internal routines as they see fit without changing the outer specifications.

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.

2. Microkernel Structure

Kernel is the core part of an operating system that manages system resources. It also acts
as a bridge between the application and hardware of the computer. It is one of the first
programs loaded on start-up (after the Bootloader).

It provides a minimal amount of process and memory management services. The interaction
between the client application and services running in user address space is established via
message passing that helps to reduce the speed of microkernel execution. The OS is
unaffected because kernel and user services are isolated, so if any of the user services fails, the
kernel service is unaffected. It is extendable because new services are added to the user
address space, hence requiring no changes in kernel space. It's also lightweight, secure, and
reliable.

The kernel is responsible for performing the following tasks:

 Input-Output management

 Memory Management
 Process Management for application execution.

 Device Management

 System calls control

Advantages

1. Microkernels are secure since only those parts are added, which might disturb the
system's functionality.

2. Microkernels are modular, and the various modules may be swapped, reloaded, and
modified without affecting the kernel.

3. Microkernel architecture is compact and isolated, so it may perform better.

4. The system expansion is more accessible, so it may be introduced to the system


application without disrupting the kernel.

5. When compared to monolithic systems, microkernels have fewer system crashes.


Furthermore, due to the modular structure of microkernels, any crashes that do occur
are simply handled.

6. The microkernel interface helps in enforcing a more modular system structure.

7. Server failure is treated the same as any other user program failure.

8. It adds new features without recompiling.

Disadvantages

1. When the drivers are implemented as procedures, a context switch or a function call is
needed.

2. In a microkernel system, providing services are more costly than in a traditional


monolithic system.

3. The performance of a microkernel system might be indifferent and cause issues.

3. Monolithic kernel

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.

Monolithic System Architecture;

A monolithic design of the operating system architecture makes no special accommodation for
the special nature of the operating system. Although the design follows the separation of
concerns, no attempt is made to restrict the privileges granted to the individual parts of the
operating system. The entire operating system executes with maximum privileges. The
communication overhead inside the monolithic operating system is the same as that of any
other software, considered relatively low.

Advantages of Monolithic Kernel

Here are the following advantages of a monolithic kernel, such as:

o The execution of the monolithic kernel is quite fast as the services such as memory
management, file management, process scheduling, etc., are implemented under the
same address space.

o A process runs completely in single address space in the monolithic kernel.

o The monolithic kernel is a static single binary file.

Disadvantages of Monolithic Kernel

Here are some disadvantages of the monolithic kernel, such as:


o If any service fails in the monolithic kernel, it leads to the failure of the entire system.

o The entire operating system needs to be modified by the user to add any new service.

4. Modular structure

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.

Modular Kernel, as name suggests, is a type of kernel in which some parts of system
core will get allocated in independent files called modules. This can be added to system at run
time. It usually requires small amount of time of load modules. If one needs a new module, then
they won’t have to recompile.
For example Solaris OS is organized as shown in the figure.

Advantages −

 Efficient

 Easy to maintained

 Easy to debug and update

Disadvantages −

 It may lose stability


 Less security

5. Layered Structure

One way to achieve modularity in the operating system is the layered approach. In this, the
bottom layer is the hardware and the topmost layer is the user interface.

An image demonstrating the layered approach is as follows −

The operating system is split into various layers In the layered operating system and each of the
layers have different functionalities. This type of operating system was created as an
improvement over the early monolithic systems. Layering provides a distinct advantage in an
operating system. All the layers can be defined separately and interact with each other as
required. Also, it is easier to create, maintain and update the system if it is done in the form of
layers. Change in one layer specification does not affect the rest of the layers.

Each of the layers in the operating system can only interact with the layers that are above and
below it. The lowest layer handles the hardware and the uppermost layer deals with the user
applications.

Layers in Layered Operating System

There are six layers in the layered operating system. A diagram demonstrating these layers is
as follows:

Details about the six layers are:

1. Hardware

This layer interacts with the system hardware and coordinates with all the peripheral
devices used such as printer, mouse, keyboard, scanner etc. The hardware layer is the
lowest layer in the layered operating system architecture.

2. CPU Scheduling
This layer deals with scheduling the processes for the CPU. There are many
scheduling queues that are used to handle processes. When the processes enter the
system, they are put into the job queue. The processes that are ready to execute in the main
memory are kept in the ready queue.

3. Memory Management

Memory management deals with memory and the moving of processes from disk to
primary memory for execution and back again. This is handled by the third layer of the
operating system.

4. Process Management

This layer is responsible for managing the processes i.e assigning the processor to a
process at a time. This is known as process scheduling. The different algorithms used for
process scheduling are FCFS (first come first served), SJF (shortest job first), priority
scheduling, round-robin scheduling etc.

5. I/O Buffer

I/O devices are very important in the computer systems. They provide users with the
means of interacting with the system. This layer handles the buffers for the I/O devices and
makes sure that they work correctly.

6. User Programs

This is the highest layer in the layered operating system. This layer deals with the
many user programs and applications that run in an operating system such as word
processors, games, browsers etc.

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.

6. Hybrid Kernel

The kernel is the core part of the operating system as it manages the operations of the
computer as well as the hardware. The hybrid kernel attempts to combine the features and
aspects of the microkernel and the monolithic kernel. This means that the kernel structure
should be similar to a microkernel but the structure should be implemented like a monolithic
kernel.

A hybrid kernel is an operating system kernel architecture that attempts to combine aspects and
benefits of microkernel and monolithic kernel architectures used in computer operating systems.

It contains three layers:

1. Hardware abstraction layer: It is the lowermost layer that acts as an interface between
the kernel and hardware.

2. Microkernel layer: This layer is nothing but the microkernel only which comprises of the
three basic functionalities i.e., CPU scheduling, memory management, Inter-Process
Communication.

3. Application layer: This layer is in user area and acts as an interface between user
space and microkernel layer. It comprises of the remaining functionalities like file server,
error detection, I/O device management etc.

A figure that illustrates the structure of the Microsoft Windows NT kernel is as follows −

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

Advantages:

1. Easy to manage due to layered approach.

2. Number of layers is not very high.

3. Kernel is small and isolated.

4. Improved security and protection.

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:

Process Management

The operating system is responsible for managing the processes i.e assigning the processor to
a process at a time. This is known as process scheduling. The different algorithms used for
process scheduling are FCFS (first come first served), SJF (shortest job first), priority
scheduling, round robin scheduling etc.
There are many scheduling queues that are used to handle processes in process management.
When the processes enter the system, they are put into the job queue. The processes that are
ready to execute in the main memory are kept in the ready queue. The processes that are
waiting for the I/O device are kept in the device queue.

Memory Management

Memory management plays an important part in operating system. It deals with memory and the
moving of processes from disk to primary memory for execution and back again.

The activities performed by the operating system for memory management are −

 The operating system assigns memory to the processes as required. This can be done
using best fit, first fit and worst fit algorithms.

 All the memory is tracked by the operating system i.e. it nodes what memory parts are in
use by the processes and which are empty.

 The operating system deallocated memory from processes as required. This may
happen when a process has been terminated or if it no longer needs the memory.

Device Management

There are many I/O devices handled by the operating system such as mouse, keyboard, disk
drive etc. There are different device drivers that can be connected to the operating system to
handle a specific device. The device controller is an interface between the device and the
device driver. The user applications can access all the I/O devices using the device drivers,
which are device specific codes.

File Management

Files are used to provide a uniform view of data storage by the operating system. All the files
are mapped onto physical devices that are usually non volatile so data is safe in the case of
system failure.

The files can be accessed by the system in two ways i.e. sequential access and direct access −

 Sequential Access

The information in a file is processed in order using sequential access. The files records are
accessed on after another. Most of the file systems such as editors, compilers etc. use
sequential access.

 Direct Access

In direct access or relative access, the files can be accessed in random for read and write
operations. The direct access model is based on the disk model of a file, since it allows random
accesses.
Functions of the Operating System

Process Management
Every software that runs on a computer, whether in the background or in the frontend, is a
process. Processor management is an execution unit in which a program operates. The
operating system determines the status of the processor and processes, selects a job and its
processor, allocates the processor to the process, and de-allocates the processor after the
process is completed.
When more than one process runs on the system the OS decides how and when a process will
use the CPU. Hence, the name is also CPU Scheduling. The OS:

 Allocates and deallocates processor to the processes.


 Keeps record of CPU status.

Certain algorithms used for CPU scheduling are as follows:


 First Come First Serve (FCFS)
 Shortest Job First (SJF)
 Round-Robin Scheduling
 Priority-based scheduling etc.

Purpose of CPU scheduling


The purpose of CPU scheduling is as follows:
 Proper utilization of CPU. Since the proper utilization of the CPU is necessary.
Therefore, the OS makes sure that the CPU should be as busy as possible.
 Since every device should get a chance to use the processor. Hence, the OS makes
sure that the devices get fair processor time.
 Increasing the efficiency of the system.

Memory Management
It is the management of the main or primary memory. Whatever program is executed, it has to
be present in the main memory. Main memory is a quick storage area that may be accessed
directly by the CPU. When the program is completed, the memory region is released and can be
used by other programs. Therefore, there can be more than one program present at a time.
Hence, it is required to manage the memory.
The operating system:
 Allocates and deallocates the memory.
 Keeps a record of which part of primary memory is used by whom and how much.
 Distributes the memory while multiprocessing.
 In multiprogramming, the operating system selects which processes acquire memory
when and how much memory they get.

Storage Management
Storage management is a procedure that allows users to maximize the utilization of storage
devices while also protecting data integrity on whatever media on which it lives. Network
virtualization, replication, mirroring, security, compression, deduplication, traffic analysis,
process automation, storage provisioning, and memory management are some of the features
that may be included. The operating system is in charge of storing and accessing files. The
creation of files, the creation of directories, the reading and writing of data from files and
directories, as well as the copying of the contents of files and directories from one location to
another are all included in storage management.
The OS uses storage management for:

 Improving the performance of the data storage resources.

 It optimizes the use of various storage devices.

 Assists businesses in storing more data on existing hardware, speeding up the data
retrieval process, preventing data loss, meeting data retention regulations, and lowering
IT costs

Computer storage has components that store computer data. The different storage types in the
storage

Protection and Security


A threat is a program that is malicious in nature and leads to harmful effects for the system.
Some of the common threats that occur in a system are −

Virus
Viruses are generally small snippets of code embedded in a system. They are very dangerous
and can corrupt files, destroy data, crash systems etc. They can also spread further by
replicating themselves as required.

Trojan Horse
A trojan horse can secretly access the login details of a system. Then a malicious user can use
these to enter the system as a harmless being and wreak havoc.

Trap Door
A trap door is a security breach that may be present in a system without the knowledge of the
users. It can be exploited to harm the data or files in a system by malicious people.

Worm
A worm can destroy a system by using its resources to extreme levels. It can generate multiple
copies which claim all the resources and don't allow any other processes to access them. A
worm can shut down a whole network in this way.

Denial of Service
These type of attacks do not allow the legitimate users to access a system. It overwhelms the
system with requests so it is overwhelmed and cannot work properly for other user.
The different methods that may provide protect and security for different computer systems are

Authentication
This deals with identifying each user in the system and making sure they are who they claim to
be. The operating system makes sure that all the users are authenticated before they access
the system. The different ways to make sure that the users are authentic are:

 Username/ Password

Each user has a distinct username and password combination and they need to enter it
correctly before they can access the system.

 User Key/ User Card

The users need to punch a card into the card slot or use they individual key on a keypad to
access the system.

 User Attribute Identification

Different user attribute identifications that can be used are fingerprint, eye retina etc. These are
unique for each user and are compared with the existing samples in the database. The user can
only access the system if there is a match.

One Time Password

These passwords provide a lot of security for authentication purposes. A one time password can
be generated exclusively for a login every time a user wants to enter the system. It cannot be
used more than once. The various ways a one time password can be implemented are −

 Random Numbers

The system can ask for numbers that correspond to alphabets that are pre arranged. This
combination can be changed each time a login is required.

 Secret Key

A hardware device can create a secret key related to the user id for login. This key can change
each time.

Operating System Services

OSes provide environments in which programs run, and services for the users of the system,
including:

 User Interfaces - Means by which users can issue commands to the system.
Depending on the system these may be a command-line interface ( e.g. sh, csh, ksh,
tcsh, etc. ), a GUI interface ( e.g. Windows, X-Windows, KDE, Gnome, etc. ), or a batch
command systems. The latter are generally older systems using punch cards of job-
control language, JCL, but may still be used today for specialty systems designed for a
single purpose.
 Program Execution - The OS must be able to load a program into RAM, run the
program, and terminate the program, either normally or abnormally.

 I/O Operations - The OS is responsible for transferring data to and from I/O devices,
including keyboards, terminals, printers, and storage devices.

 File-System Manipulation - In addition to raw data storage, the OS is also responsible


for maintaining directory and subdirectory structures, mapping file names to specific
blocks of data storage, and providing tools for navigating and utilizing the file system.

 Communications - Inter-process communications, IPC, either between processes


running on the same processor, or between processes running on separate processors
or separate machines. May be implemented as either shared memory or message
passing, ( or some systems may offer both. )

 Error Detection - Both hardware and software errors must be detected and handled
appropriately, with a minimum of harmful repercussions. Some systems may include
complex error avoidance or recovery systems, including backups, RAID drives, and
other redundant systems. Debugging and diagnostic tools aid users and administrators
in tracing down the cause of problems.

Other systems aid in the efficient operation of the OS itself:

 Resource Allocation - E.g. CPU cycles, main memory, storage space, and peripheral
devices. Some resources are managed with generic systems and others with very
carefully designed and specially tuned systems, customized for a particular resource and
operating environment.

 Accounting - Keeping track of system activity and resource usage, either for billing
purposes or for statistical record keeping that can be used to optimize future
performance.

 Protection and Security - Preventing harm to the system and to resources, either
through wayward internal processes or malicious outsiders. Authentication, ownership,
and restricted access are obvious parts of this system. Highly secure systems may log
all process activity down to excruciating detail, and security regulation dictate the
storage of those records on permanent non-erasable medium for extended times in
secure ( off-site ) facilities.

User operating system interface

Command Interpreter

 Gets and processes the next user request, and launches the requested programs.
 In some systems the CI may be incorporated directly into the kernel.

 More commonly the CI is a separate program that launches once the user logs in or
otherwise accesses the system.
 UNIX, for example, provides the user with a choice of different shells, which may either
be configured to launch automatically at login, or which may be changed on the fly. (
Each of these shells uses a different configuration file of initial settings and commands
that are executed upon startup. )
 Different shells provide different functionality, in terms of certain commands that are
implemented directly by the shell without launching any external programs. Most provide
at least a rudimentary command interpretation structure for use in shell script
programming ( loops, decision constructs, variables, etc. )
 An interesting distinction is the processing of wild card file naming and I/O re-direction.
On UNIX systems those details are handled by the shell, and the program which is
launched sees only a list of filenames generated by the shell from the wild cards. On a
DOS system, the wild cards are passed along to the programs, which can interpret the
wild cards as the program sees fit.

Figure; The Bourne shell command interpreter in Solaris 10

Graphical User Interface, GUI

 Generally implemented as a desktop metaphor, with file folders, trash cans, and
resource icons.

 Icons represent some item on the system, and respond accordingly when the icon is
activated.
 First developed in the early 1970's at Xerox PARC research facility.
 In some systems the GUI is just a front end for activating a traditional command line
interpreter running in the background. In others the GUI is a true graphical shell in its
own right.

 Mac has traditionally provided ONLY the GUI interface. With the advent of OSX ( based
partially on UNIX ), a command line interface has also become available.
 Because mice and keyboards are impractical for small mobile devices, these normally
use a touch-screen interface today, that responds to various patterns of swipes or
"gestures". When these first came out they often had a physical keyboard and/or a
trackball of some kind built in, but today a virtual keyboard is more commonly
implemented on the touch screen.

Figure 2.3 - The iPad touchscreen

Choice of interface

 Most modern systems allow individual users to select their desired interface, and to
customize its operation, as well as the ability to switch between different interfaces as
needed. System administrators generally determine which interface a user starts with
when they first log in.

 GUI interfaces usually provide an option for a terminal emulator window for entering
command-line commands.
 Command-line commands can also be entered into shell scripts, which can then be run
like any other programs.
Figure - The Mac OS X GUI

System Calls
A system call is a method for a computer program to request a service from the kernel of
the operating system on which it is running. A system call is a method of interacting with the
operating system via programs. A system call is a request from computer software to an
operating system's kernel.
The Application Program Interface (API) connects the operating system's functions to user
programs. It acts as a link between the operating system and a process, allowing user-level
programs to request operating system services. The kernel system can only be accessed using
system calls. System calls are required for any programs that use resources.
How System Calls Work

The Applications run in an area of memory known as user space. A system call connects
to the operating system's kernel, which executes in kernel space. When an application creates a
system call, it must first obtain permission from the kernel. It achieves this using an interrupt
request, which pauses the current process and transfers control to the kernel.

If the request is permitted, the kernel performs the requested action, like creating or deleting a
file. As input, the application receives the kernel's output. The application resumes the
procedure after the input is received. When the operation is finished, the kernel returns the
results to the application and then moves data from kernel space to user space in memory.
A simple system call may take few nanoseconds to provide the result, like retrieving the system
date and time. A more complicated system call, such as connecting to a network device, may
take a few seconds. Most operating systems launch a distinct kernel thread for each system call
to avoid bottlenecks. Modern operating systems are multi-threaded, which means they can
handle various system calls at the same time.

Types of System Calls

There are commonly five types of system calls. These are as follows:
1. Process Control

2. File Management
3. Device Management

4. Information Maintenance

5. Communication

Process Control
Process control is the system call that is used to direct the processes. Some process control
examples include creating, load, abort, end, execute, process, terminate the process, etc.

File Management
File management is a system call that is used to handle the files. Some file management
examples include creating files, delete files, open, close, read, write, etc.

Device Management
Device management is a system call that is used to deal with devices. Some examples of
device management include read, device, write, get device attributes, release device, etc.

Information Maintenance
Information maintenance is a system call that is used to maintain information. There are some
examples of information maintenance, including getting system data, set time or date, get time
or date, set system data, etc.

Communication
Communication is a system call that is used for communication. There are some examples of
communication, including create, delete communication connections, send, receive messages,
etc.

Examples of Windows and Unix system calls

There are various examples of Windows and Unix system calls. These are as listed below in the
table:
Operating System Design and Implementation

Design Goals

 Requirements define properties which the finished system must have, and are a
necessary first step in designing any large complex system.

o User requirements are features that users care about and understand, and are
written in commonly understood vernacular. They generally do not include any
implementation details, and are written similar to the product description one
might find on a sales brochure or the outside of a shrink-wrapped box.

o System requirements are written for the developers, and include more details
about implementation specifics, performance requirements, compatibility
constraints, standards compliance, etc. These requirements serve as a "contract"
between the customer and the developers, ( and between developers and
subcontractors ), and can get quite detailed.
 Requirements for operating systems can vary greatly depending on the planned scope
and usage of the system. ( Single user / multi-user, specialized system / general
purpose, high/low security, performance needs, operating environment, etc. )

Mechanisms and Policies

 Policies determine what is to be done. Mechanisms determine how it is to be


implemented.

 If properly separated and implemented, policy changes can be easily adjusted without
re-writing the code, just by adjusting parameters or possibly loading new data /
configuration files. For example the relative priority of background versus foreground
tasks.

Implementation

 Traditionally OSes were written in assembly language. This provided direct control over
hardware-related issues, but inextricably tied a particular OS to a particular HW platform.

 Recent advances in compiler efficiencies mean that most modern OSes are written in C,
or more recently, C++. Critical sections of code are still written in assembly language, (
or written in C, compiled to assembly, and then fine-tuned and optimized by hand from
there. )

 Operating systems may be developed using emulators of the target hardware,


particularly if the real hardware is unavailable ( e.g. not built yet ), or not a suitable
platform for development, ( e.g. smart phones, game consoles, or other similar devices. )

You might also like