Unit 2
Unit 2
Operating system is a software that acts as an intermediary between the user and computer
hardware. It is a program with the help of which we are able to run various applications. It is
the one program that is running all the time. Every computer must have an operating system to
smoothly execute other programs. The OS coordinates the use of the hardware and application
programs for various users. It provides a platform for other application programs to work. The
operating system is a set of special programs that run on a computer system that allows it to
work properly. It controls input-output devices, execution of programs, managing files, etc.
1.Program Execution
It is the Operating System that manages how a program is going to be executed. It loads the
program into the memory after which it is executed. The order in which they are executed
depends on the CPU Scheduling Algorithms. A few are FCFS, SJF, etc. When the program is
in execution, the Operating System also handles deadlock i.e. no two processes come for
execution at the same time. The Operating System is responsible for the smooth execution of
both user and system programs. The Operating System utilizes various resources available for
the efficient running of all types of functionalities.
3.File Management
The operating system helps in managing files also. If a program needs access to a file, it is the
operating system that grants access. These permissions include read-only, read-write, etc. It
also provides a platform for the user to create, and delete files. The Operating System is
responsible for making decisions regarding the storage of all types of data or files, i.e, floppy
disk/hard disk/pen drive, etc. The Operating System decides how the data should be
manipulated and stored.
4.Error Handling
The Operating System also handles the error occurring in the CPU, in Input-Output devices,
etc. It also ensures that an error does not occur frequently and fixes the errors. It also prevents
the process from coming to a deadlock. It also looks for any type of error or bugs that can
occur while any task. The well-secured OS sometimes also acts as a countermeasure for
preventing any sort of breach of the Computer System from any external source and probably
handling them.
5.Resource Management
System resources are shared between various processes. It is the Operating system that
manages resource sharing. It also manages the CPU time among processes using CPU
Scheduling Algorithms. It also helps in the memory management of the system. It also controls
input-output devices. The OS also ensures the proper use of all the resources available by
deciding which resource to be used by whom.
7.Security
In an operating system, protection is a mechanism that controls the access of the process,
programs, or users over any resources of the computer system. The operating system ensures
that all access to system resources must be monitored and controlled. It also ensures that the
external resources or peripherals must be protected from invalid access. It provides
authentication by using usernames and passwords.
8.Networking
This service enables communication between devices on a network, such as connecting to the
internet, sending and receiving data packets, and managing network connections.
9.System Utilities
These are a set of tools and applications that provide additional functionality to the OS, such
as backup and recovery, system optimization, and diagnostic tools.
10.User Interface
User interface is essential and all operating systems provide it. Users either interface with the
operating system through the command-line interface or graphical user interface or GUI. The
command interpreter executes the next user-specified command.
A GUI offers the user a mouse-based window and menu system as an interface.
11.Error Management
Errors can happen anywhere at any time. A problem could be with the CPU, the I/O, or the
memory hardware. The main activities of an operating system with regard to error handling are
as follows:
1. The OS continuously scans for potential errors.
2. The OS takes the proper action to guarantee accurate and reliable computing.
12.Resource Administration
When working in a multi-user or multi-tasking environment, each user or task should be given
its own share of resources like main memory, CPU time, and file storage. The main resource
management activities of an operating system are as follows:
1. Schedulers are used by the OS to manage various types of resources.
2. Algorithms for CPU scheduling are employed for increased CPU efficiency.
13.Protection
Multiple processes must be shielded from one another’s actions in a computer system with
multiple users and concurrent process execution.Protection describes a method or a way to
manage how users, processes, or programs can access the resources designated by a computer
system. The main protection-related activities of an operating system are as follows:
1. The OS makes sure that all system resources have controlled access.
2. The OS makes sure external I/O devices are secured against unauthorized access attempts.
3. The operating system offers password-based authentication features for each user.
The graphical user interface is a type of GUI that enables the users to interact with the operating
system by means of point-and-click operations. GUI contains several icons representing pictorial
representation of the variables such as a file, directory, and device. The graphical icon provided
in the UI can be manipulated by the users using a suitable pointing device such as a mouse,
trackball, touch screen and light pen. The other input devices like keyboard can also be used to
manipulate these graphical icons. GUIs are considered to be very user- friendly interface because
each object is represented with a corresponding icon.
Elements of GUI
The following services are provided by Process Control System calls that are used to control a
process.
The following services are provided by system call for file management:
The following services are offered by a system call that controls I/O devices:
Devices might be needed while a process is running. such as access to the file system, I/O
devices, main memory, etc.
As a result, it can ask for a device and then release it once the task is complete.
when a requested device is granted access by the process. It is capable of reading,
writing, and repositioning operations.
In order to obtain or modify a specific device's attribute.
To detach a device from the processor that is currently executing a command, the call can
be made.
4. Information Maintenance
The system calls for information maintenance call moves data from the user programme to the
operating system. Considering this, the services offered by this type of system call are:
Obtain the system's time or date. Set the system's time or date.
Obtain system-related information. Configure the system data.
Obtain the characteristics of a specific operating system process. Alternatively, of a
specific file on the system or on any attached devices.
Set the characteristics of a specific operating system process. Alternatively, of a specific
file on the system or on any attached devices.
5. Communication
Such a system call facilitates the system's network connection. The services that these system
calls offer are:
Open a fresh connection to send the data. After the transmission is finished, disconnect
from the connection.
On a particular connection, send a message. Obtain communication from a specific
connection.
Identify and connect a specific remote device to the network. Remove a specific remote
computer or device from the network.
CreateProcess() Fork()
Process Control ExitProcess() Exit()
WaitForSingleObject() Wait()
Open()
CreateFile()
Read()
File manipulation ReadFile()
Write()
WriteFile()
Close()
SetConsoleMode() Ioctl()
Device Management ReadConsole() Read()
WriteConsole() Write()
GetCurrentProcessID() Getpid()
Information Maintenance SetTimer() Alarm()
Sleep() Sleep()
CreatePipe() Pipe()
Communication CreateFileMapping() Shmget()
MapViewOfFile() Mmap()
SetFileSecurity() Chmod()
Protection InitializeSecurityDescriptor() Umask()
SetSecurityDescriptorgroup() Chown()
open()
The open() system call allows you to access a file on a file system. It allocates resources to the
file and provides a handle that the process may refer to. Many processes can open a file at once
or by a single process only. It's all based on the file system and structure.
read()
It is used to obtain data from a file on the file system. It accepts three arguments in general:
o A file descriptor.
o A buffer to store read data.
o The number of bytes to read from the file.
The file descriptor of the file to be read could be used to identify it and open it
using open() before reading.
wait()
In some systems, a process may have to wait for another process to complete its execution before
proceeding. When a parent process makes a child process, the parent process execution is
suspended until the child process is finished. The wait() system call is used to suspend the parent
process. Once the child process has completed its execution, control is returned to the parent
process.
write()
It is used to write data from a user buffer to a device like a file. This system call is one way for a
program to generate data. It takes three arguments in general:
o A file descriptor.
o A pointer to the buffer in which data is saved.
o The number of bytes to be written from the buffer.
fork()
Processes generate clones of themselves using the fork() system call. It is one of the most
common ways to create processes in operating systems. When a parent process spawns a child
process, execution of the parent process is interrupted until the child process completes. Once the
child process has completed its execution, control is returned to the parent process.
close()
It is used to end file system access. When this system call is invoked, it signifies that the program
no longer requires the file, and the buffers are flushed, the file information is altered, and the file
resources are de-allocated as a result.
exec()
When an executable file replaces an earlier executable file in an already executing process, this
system function is invoked. As a new process is not built, the old process identification stays, but
the new process replaces data, stack, data, head, etc.
exit()
The exit() is a system call that is used to end program execution. This call indicates that the
thread execution is complete, which is especially useful in multi-threaded environments. The
operating system reclaims resources spent by the process following the use of the exit() system
function.
Structure Types:
What is Operating System (OS) Structure?
The operating system (OS) structure consists of a kernel at its core, which manages hardware
resources and provides services to other system components. The OS also includes system
libraries, which are collections of prewritten code used by applications. The user interface,
including the shell and graphical user interface (GUI), allows users to interact with the OS and
its applications. Device drivers provide an interface between hardware devic es and the OS.
System services handle tasks such as printing and file sharing. The file system manages storage
and organizes data on disks. Finally, the network stack manages network connections and data
transmission.
1.SIMPLE STRUCTURE
Such operating systems do not have well-defined structures and are small, simple, and limited.
The interfaces and levels of functionality are not well separated. Example MS-DOS
These types of operating systems cause the entire system to crash if one of the user programs
fails.
Advantages of Simple structure
It delivers better application performance because of the few interfaces between the
application program and the hardware.
It is easy for kernel developers to develop such an operating system.
Disadvantages of Simple structure
The structure is very complicated, as no clear boundaries exist between modules.
It does not enforce data hiding in the operating system.
2.LAYERED STRUCTURE
An OS can be broken into pieces and retain much more control over the system.
In this structure, the OS is broken into a number of layers (levels).
The bottom layer (layer 0) is the hardware, and the topmost layer (layer N) is the user
interface.
These layers are so designed that each layer uses the functions of the lower-level layers.
This simplifies the debugging process, if lower-level layers are debugged and an error
occurs during debugging, then the error must be on that layer only, as the lower-level
layers have already been debugged.
The main disadvantage of this structure is that at each layer, the data needs to be
modified and passed on which adds overhead to the system.
Moreover, careful planning of the layers is necessary, as a layer can use only lower level
layers. UNIX is an example of this structure.
Advantages of Layered structure
Layering makes it easier to enhance the operating system, as the implementation of a
layer can be changed easily without affecting the other layers.
It is very easy to perform debugging and system verification.
Disadvantages of Layered structure
In this structure, the application’s performance is degraded as compared to simple
structure.
It requires careful planning for designing the layers, as the higher layers use the
functionalities of only the lower layers
3.MICRO-KERNEL
This structure designs the operating system by removing all non-essential components
from the kernel and implementing them as system and user programs.
Advantages of this structure are that all new services need to be added to user space and
does not require the kernel to be modified.
Thus it is more secure and reliable as if a service fails, then rest of the operating system
remains untouched.
It provides only essential services, such as process scheduling and inter-process
communication, while moving most non-essential services, like device drivers, into user
space.
Mac OS is an example of this type of OS.
Advantages of Micro-kernel structure
It makes the operating system portable to various platforms.
As microkernel’s are small so these can be tested effectively.
Disadvantages of Micro-kernel structure
Increased level of inter module communication degrades system performance.
Advantages:
There are no protection problems because each virtual machine is completely isolated
from all other virtual machines.
Virtual machine can provide an instruction set architecture that differs from real
computers.
Easy maintenance, availability and convenient recovery.
Disadvantages:
When multiple virtual machines are simultaneously running on a host computer, one
virtual machine can be affected by other running virtual machines, depending on the
workload.
Virtual machines are not as efficient as a real one when accessing the hardware.
5.MONOLITHIC KERNEL
The monolithic operating system controls all aspects of the operating system's operation,
including file management, memory management, device management, and operational
operations.
The core of an operating system for computers is called the kernel (OS). All other System
components are provided with fundamental services by the kernel. The operating system and the
hardware use it as their main interface. When an operating system is built into a single piece of
hardware, such as a keyboard or mouse, the kernel can directly access all of its resources.
The monolithic operating system is often referred to as the monolithic kernel. Multiple
programming techniques such as batch processing and time-sharing increase a processor's
usability. Working on top of the operating system and under complete command of all hardware,
the monolithic kernel performs the role of a virtual computer. This is an old operating system
that was used in banks to carry out simple tasks like batch processing and time-sharing, which
allows numerous users at different terminals to access the Operating System.
Advantages of Monolithic Structure:
Because layering is unnecessary and the kernel alone is responsible for managing all
operations, it is easy to design and execute.
Due to the fact that functions like memory management, file management, process
scheduling, etc., are implemented in the same address area, the monolithic kernel runs
rather quickly when compared to other systems. Utilizing the same address speeds up and
reduces the time required for address allocation for new processes.
Disadvantages
The monolithic kernel's services are interconnected in address space and have an impact
on one another, so if any of them malfunctions, the entire system does as well.
It is not adaptable. Therefore, launching a new service is difficult.
A client program runs only when it requests for a service from the server while the server
program runs all time as it does not know when its service is required.
A server provides a service for many clients not just for a single client. Therefore, we can say
that client-server follows the many-to-one relationship. Many clients can use the service of
one server.
Client
A client is a program that runs on the local machine requesting service from the server. A
client program is a finite program means that the service started by the user and
terminates when the service is completed.
Server
A server is a program that runs on the remote machine providing services to the clients.
When the client requests for a service, then the server opens the door for the incoming
requests, but it never initiates the service.
A server program is an infinite program means that when it starts, it runs infinitely unless
the problem arises. The server waits for the incoming requests from the clients. When the
request arrives at the server, then it responds to the request.
Advantages of Client-server networks:
Centralized: Centralized back-up is possible in client-server networks, i.e., all the data is
stored in a server.
Security: These networks are more secure as all the shared resources are centrally
administered.
Performance: The use of the dedicated server increases the speed of sharing resources.
This increases the performance of the overall system.
Scalability: We can increase the number of clients and servers separately, i.e., the new
element can be added, or we can add a new node in a network at any time.
Disadvantages of Client-Server network:
Traffic Congestion is a big problem in Client/Server networks. When a large number of
clients send requests to the same server may cause the problem of Traffic congestion.
It does not have a robustness of a network, i.e., when the server is down, then the client
requests cannot be met.
A client/server network is very decisive. Sometimes, regular computer hardware does not
serve a certain number of clients. In such situations, specific hardware is required at the
server side to complete the work.
Sometimes the resources exist in the server but may not exist in the client. For example,
If the application is web, then we cannot take the print out directly on printers without
taking out the print view window on the web.