0% found this document useful (0 votes)
3 views18 pages

Unit 2

The document outlines the essential services provided by an operating system, including program execution, input-output operations, file management, error handling, resource management, and security. It also discusses user interfaces such as command-line and graphical user interfaces, highlighting their advantages and disadvantages. Additionally, the document explains system calls, their types, and their significance in enabling communication between user programs and the operating system.

Uploaded by

deveshkale08
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)
3 views18 pages

Unit 2

The document outlines the essential services provided by an operating system, including program execution, input-output operations, file management, error handling, resource management, and security. It also discusses user interfaces such as command-line and graphical user interfaces, highlighting their advantages and disadvantages. Additionally, the document explains system calls, their types, and their significance in enabling communication between user programs and the operating system.

Uploaded by

deveshkale08
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/ 18

UNIT-2

Operating System Services

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.

Services of Operating System

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.

2.Input Output Operations

Operating System manages the input-output operations and establishes communication


between the user and device drivers. Device drivers are software that is associated with
hardware that is being managed by the OS so that the sync between the devices works
properly. It also provides access to input-output devices to a program when needed.

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.

6.Communication between Processes

The Operating system manages the communication between processes. Communication


between processes includes data transfer among them. If the processes are not on the same
computer but connected through a computer network, then also their communication is
managed by the Operating System itself.

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.

Operating System Interfaces


The user and operating system are connected with each other with the help of interface, so
interface is used to connect the user and OS.
In computers there are different types of interface that can be used for connection with
computers to users and their connection is responsible for data transfer.
1)Command Interpreter
Command line interface is a type of UI that enables the users to interact with the operating
system by issuing some specific commands. In order to perform a task in this interface, the user
needs to type a command at the command line. When the user enters the key, the command line
interpreter received a command. The software program that is responsible for receiving and
processing the commands issued by the user. After processing the command are called command
line interpreter, the command line interpreter displays the command prompt again along with the
output of the previous command issued by the user.

 Advantages of command line interface (CLI)


 Fast performance:
If you know how to use CLI and you are familiar with different commands then your
work will be completed fast as compared to using GUI. You can perform multiple
tasks by entering commands in the CLI.
 Less memory:
The command-line interface uses less memory as compare to GUI. GUI uses high
memory and it slows down the computer but CLI uses minimal memory and your
system will not slow down.
 Low-resolution monitor:
As CLI is a text-based interface so it can also run well on a low-resolution screen.
GUI on the other hand requires a high-resolution screen in most cases.
 The slow processor can work:
CLI can be run on any processor whether it is a slow processor or high processor. The
commands are executed fast and they also don’t need extra processing power.
 Don’t require windows:
You don’t need to install windows to run commands in CLI. All operating systems
support CLI. Mac has its own CLI, UNIX and Linux has also its own CLI.
 Autocomplete:
When you type commands in the CLI then most of the commands are auto-complete
by clicking on the TAB button on the keyboard.
 Remote work:
CLI also helps to have communication of devices. You can operate different
commands on remote computers also. You can connect different services to your PC
by using CLI.
 History of commands:
If you execute commands in CLI then commands are saved in the history. You can
use up/down arrows from the keyboard to reuse those commands again.

 Disadvantages of command line interface (CLI)


 Difficult to remember:
It is difficult to remember all the commands used in the CLI. UNIX has more than 100
commands for CLI. Some commands are used with other commands and remembering
the sequence of commands is also difficult.
 Error handling:
If you write wrong commands by any typo then it may delete any file or move the file
to the wrong location. If you accidentally delete any file then it creates a problem for
you and maybe that file contains important information.
 Confusing:
For new users, CLI is quite confusing. The new user cannot judge how the CLI can
work and what to type in the CLI.
 Redo commands:
Most of the commands in the command line interface are not reversed or undone. So
you have to be very careful to use commands. In most cases, the execution of the
command is not undone and its execution continues.
 Learning curve:
Learning commands is a lengthy process. If you do not use commands daily then you
will forget most of the commands. All the applications have different commands e.g.
GitHub has different commands to execute.

2)Graphical User Interface

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

 Button: A graphical representation of a button that acts as a program when pressed.


 Dialogue box: A type of window that displays additional information and asks a user for
input.
 Icon: Small graphical representation of a program, features, or file.
 Menu: List of commands or choices offered to the user through the menu bar.
 Ribbon: Replacement for the file menu and toolbar that groups programs activities
together.
 Tab: Clickable area at the top of a window that shows another page or area.
 Toolbar: Row of buttons, often near the top of an application window, that controls
software functions.
 Window: Rectangular section of the computer's display that shows the program currently
being used.
Advantages of Graphical User Interface
 The main advantage of GUI [Graphical User Interface] is that they are very simple to use
and handle, and hence replaced old-fashioned operating systems which used CUI.
 They are very attractive and visually impactful, making users more convenient for usage.
 They do not need prior computer skills or knowledge to perform computer operations.
 Playing with software and application is more easily compared to NON-GUI operating
systems.
 As modern operating systems are GUI-enabled, communication between users can be
established more easily.
 Files and folders can be managed easily.
 Learning computers and implementation is more fun as they can visually interact with the
users.
 Users can easily learn programming language with the help and assistance of GUI.
 Multitasking operations and tasks can be done easily using GUI technology.
 GUI is easy to use, handle and understand.
 They are easy to understand due to the interactive interface.
 They have a user-friendly environment.
 GUI-based operating systems are more attractive than NON-GUI operating systems.
 Searching is made easy in these operating systems as they are visually appealing, and no
need to memorize certain commands.
 GUI made files drag, drop, select, copying, and delete in just a single click.
 The results derived from GUI are instant.

Disadvantages of Graphical User Interface


 The operating systems are pre-programmed system software and cannot be updated or
changed.
 GUI consumes more resources like RAM and CPU.
 The booting process takes more time compared to the NON-GUI Operating system.
 This operating system gets corrupt more often.
 It takes more power for the system to function.
 The operation performed in GUI based operating system takes more time than NON-GUI
based OS.
 It requires more memory.
 The development of a GUI-based OS takes considerable time.
 The command-line interface is limited; therefore, o use commands, you require
administrative privileges.
 It requires more processing power to execute operations
System Calls
• A system call is a means that provides the interface between a process and the operating
system.
• It is a programmatic method in which a computer program requests a service from the
kernel of the OS.
• System call offers the services of the operating system to the user programs via API
(Application Programming Interface).
• A system call is initiated by the program executing a specific instruction, which triggers a
switch to kernel mode, allowing the program to request a service from the OS. The OS
then handles the request, performs the necessary operations, and returns the result back to
the program
• How do APIs work?
• API architecture is explained in terms of client and server. The application sending the
request is called the client, and the application sending the response is called the server.
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
The different types of system calls are
1. Process Control

The following services are provided by Process Control System calls that are used to control a
process.

 To forcefully abort the process, simply end it normally.


 Execute a process after loading it into the main memory.
 Terminate the current process before starting a new one.
 Wait for a process to complete running. Wait until a specific event happens, then
announce it once it has.
 Allocate memory to a process, then release the memory if the process is terminated.
2. File Management

The following services are provided by system call for file management:

 Making and erasing files


 Open the file, then close it.
 Write to a specific file, read from a specific file.
 To obtain a file's attribute and to change a file's attribute
3. Device 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.

System Calls Advantages


1. Access to hardware resources: System calls allow programs to access hardware resources
such as disk drives, printers, and network devices.
2. Memory management: System calls provide a way for programs to allocate and deallocate
memory, as well as access memory-mapped hardware devices.
3. Process management: System calls allow programs to create and terminate processes, as
well as manage inter-process communication.
4. Security: System calls provide a way for programs to access privileged resources, such as
the ability to modify system settings or perform operations that require administrative
permissions.
5. Standardization: System calls provide a standardized interface for programs to interact
with the operating system, ensuring consistency and compatibility across different
hardware platforms and operating system versions.
Examples of a System Call in Windows and Unix
Process Windows Quiz

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.

4.VMs (virtual machines)


 Based on our needs, a virtual machine abstracts the hardware of our personal computer,
including the CPU, disc drives, RAM, Network Interface Card, into a variety of different
execution contexts, giving us the impression that each execution environment is a
different computer.
 An operating system enables us to run multiple processes concurrently while making it
appear as though each one is using a different processor and virtual memory by
using CPU scheduling and virtual memory techniques.

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

6. CLIENT AND SERVER MODEL


An application program is known as a client program, running on the local machine that
requests for a service from an application program known as a server program, running on
the remote machine.

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.

You might also like