os
os
UNIT-1
UNIT - I (JNTUH-R22 SYLLABUS)
Operating System - Introduction, Structures - Simple Batch, Multiprogrammed, Time-
shared, Personal Computer, Parallel, Distributed Systems, Real-Time Systems, System
components, Operating System services, System Calls
Process - Process concepts and scheduling, Operations on processes, Cooperating
Processes, Threads
UNIT-1,CHAPTER-1
OPERATING SYSTEM - INTRODUCTION
Operating System
.
Functions of the Operating System
Resource Management: The operating system manages and allocates
memory, CPU time, and other hardware resources among the various
programs and processes running on the computer.
Process Management: The operating system is responsible for
starting, stopping, and managing processes and programs. It also
controls the scheduling of processes and allocates resources to them.
Memory Management: The operating system manages the computer’s
primary memory and provides mechanisms for optimizing memory
usage.
Security: The operating system provides a secure environment for the
user, applications, and data by implementing security policies and
mechanisms such as access controls and encryption.
Job Accounting: It keeps track of time and resources used by various
jobs or users.
File Management: The operating system is responsible for organizing
and managing the file system, including the creation, deletion, and
manipulation of files and directories.
Device Management: The operating system manages input/output
devices such as printers, keyboards, mice, and displays. It provides the
necessary drivers and interfaces to enable communication between the
devices and the computer.
Networking: The operating system provides networking capabilities
such as establishing and managing network connections, handling
network protocols, and sharing resources such as printers and files
over a network.
User Interface: The operating system provides a user interface that
enables users to interact with the computer system. This can be
a Graphical User Interface (GUI), a Command-Line Interface (CLI), or a
combination of both.
Backup and Recovery: The operating system provides mechanisms
for backing up data and recovering it in case of system failures, errors,
or disasters.
Virtualization: The operating system provides virtualization
capabilities that allow multiple operating systems or applications to
run on a single physical machine. This can enable efficient use of
resources and flexibility in managing workloads.
Performance Monitoring: The operating system provides tools for
monitoring and optimizing system performance, including identifying
bottlenecks, optimizing resource usage, and analyzing system logs and
metrics.
Time-Sharing: The operating system enables multiple users to share a
computer system and its resources simultaneously by providing time-
sharing mechanisms that allocate resources fairly and efficiently.
System Calls: The operating system provides a set of system calls that
enable applications to interact with the operating system and access its
resources. System calls provide a standardized interface between
applications and the operating system, enabling portability and
compatibility across different hardware and software platforms.
Error-detecting Aids: These contain methods that include the
production of dumps, traces, error messages, and other debugging and
error-detecting methods.
Multiprogramming
Multitasking
Time-Sharing OS
Advantages of Time-Sharing OS
Each task gets an equal opportunity.
Fewer chances of duplication of software.
CPU idle time can be reduced.
Resource Sharing: Time-sharing systems allow multiple users to share
hardware resources such as the CPU, memory, and peripherals,
reducing the cost of hardware and increasing efficiency.
Improved Productivity: Time-sharing allows users to work
concurrently, thereby reducing the waiting time for their turn to use
the computer. This increased productivity translates to more work
getting done in less time.
Improved User Experience: Time-sharing provides an interactive
environment that allows users to communicate with the computer in
real time, providing a better user experience than batch processing.
Disadvantages of Time-Sharing OS
Reliability problem.
One must have to take care of the security and integrity of user
programs and data.
Data communication problem.
High Overhead: Time-sharing systems have a higher overhead than
other operating systems due to the need for scheduling, context
switching, and other overheads that come with supporting multiple
users.
Complexity: Time-sharing systems are complex and require advanced
software to manage multiple users simultaneously. This complexity
increases the chance of bugs and errors.
Security Risks: With multiple users sharing resources, the risk of
security breaches increases. Time-sharing systems require careful
management of user access, authentication, and authorization to
ensure the security of data and software.
Examples of Time-Sharing OS with explanation
IBM VM/CMS: IBM VM/CMS is a time-sharing operating system that
was first introduced in 1972. It is still in use today, providing a virtual
machine environment that allows multiple users to run their own
instances of operating systems and applications.
TSO (Time Sharing Option): TSO is a time-sharing operating system
that was first introduced in the 1960s by IBM for the IBM System/360
mainframe computer. It allowed multiple users to access the same
computer simultaneously, running their own applications.
Windows Terminal Services: Windows Terminal Services is a time-
sharing operating system that allows multiple users to access a
Windows server remotely. Users can run their own applications and
access shared resources, such as printers and network storage, in real-
time.
Distributed OS
Advantages of Distributed Operating System
Failure of one will not affect the other network communication, as all
systems are independent of each other.
Electronic mail increases the data exchange speed.
Since resources are being shared, computation is highly fast and
durable.
Load on host computer reduces.
These systems are easily scalable as many systems can be easily added
to the network.
Delay in data processing reduces.
Disadvantages of Distributed Operating System
Failure of the main network will stop the entire communication.
To establish distributed systems the language is used not well-defined
yet.
These types of systems are not readily available as they are very
expensive. Not only that the underlying software is highly complex and
not understood well yet.
Examples of Distributed Operating Systems are LOCUS, etc.
The distributed os must tackle the following issues:
Networking causes delays in the transfer of data between nodes of a
distributed system. Such delays may lead to an inconsistent view of
data located in different nodes, and make it difficult to know the
chronological order in which events occurred in the system.
Control functions like scheduling, resource allocation, and deadlock
detection have to be performed in several nodes to achieve
computation speedup and provide reliable operation when computers
or networking components fail.
Messages exchanged by processes present in different nodes may
travel over public networks and pass through computer systems that
are not controlled by the distributed operating system. An intruder
may exploit this feature to tamper with messages, or create fake
messages to fool the authentication procedure and masquerade as a
user of the system.
Advantages of RTOS
Maximum Consumption: Maximum utilization of devices and systems,
thus more output from all the resources.
Task Shifting: The time assigned for shifting tasks in these systems is
very less. For example, in older systems, it takes about 10
microseconds in shifting from one task to another, and in the latest
systems, it takes 3 microseconds.
Focus on Application: Focus on running applications and less
importance on applications that are in the queue.
Real-time operating system in the embedded system: Since the size
of programs is small, RTOS can also be used in embedded systems like
in transport and others.
Error Free: These types of systems are error-free.
Memory Allocation: Memory allocation is best managed in these types
of systems.
Disadvantages of RTOS
Limited Tasks: Very few tasks run at the same time and their
concentration is very less on a few applications to avoid errors.
Use heavy system resources: Sometimes the system resources are not
so good and they are expensive as well.
Complex Algorithms: The algorithms are very complex and difficult
for the designer to write on.
Device driver and interrupt signals: It needs specific device drivers
and interrupts signal to respond earliest to interrupts.
Thread Priority: It is not good to set thread priority as these systems
are very less prone to switching tasks.
Examples of Real-Time Operating Systems are Scientific experiments, medical
imaging systems, industrial control systems, weapon systems, robots, air traffic
control systems, etc.
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
2. Input Output Operations
3. Communication between Process
4. File Management
5. Memory Management
6. Process Management
7. Security and Privacy
8. Resource Management
9. User Interface
10. Networking
11. Error handling
12. Time Management
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.
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.
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.
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.
Memory Management
Let’s understand memory management by OS in simple way. Imagine a cricket
team with limited number of player . The team manager (OS) decide whether the
upcoming player will be in playing 11 ,playing 15 or will not be included in team ,
based on his performance . In the same way, OS first check whether the upcoming
program fulfil all requirement to get memory space or not ,if all things good, it
checks how much memory space will be sufficient for program and then load the
program into memory at certain location. And thus , it prevents program from
using unnecessary memory.
Process Management
Let’s understand the process management in unique way. Imagine, our kitchen
stove as the (CPU) where all cooking(execution) is really happen and chef as the
(OS) who uses kitchen-stove(CPU) to cook different dishes(program). The
chef(OS) has to cook different dishes(programs) so he ensure that any particular
dish(program) does not take long time(unnecessary time) and all
dishes(programs) gets a chance to cooked(execution) .The chef(OS) basically
scheduled time for all dishes(programs) to run kitchen(all the system) smoothly
and thus cooked(execute) all the different dishes(programs) efficiently.
Security and Privacy
Security : OS keep our computer safe from an unauthorized user by
adding security layer to it. Basically, Security is nothing but just a layer
of protection which protect computer from bad guys like viruses and
hackers. OS provide us defences like firewalls and anti-virus software
and ensure good safety of computer and personal information.
Privacy : OS give us facility to keep our essential information hidden
like having a lock on our door, where only you can enter and other are
not allowed . Basically , it respect our secrets and provide us facility to
keep it safe.
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.
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.
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.
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.
Time Management
Imagine traffic light as (OS), which indicates all the cars(programs) whether it
should be stop(red)=>(simple queue) , start(yellow)=>(ready
queue),move(green)=>(under execution) and this light (control) changes after a
certain interval of time at each side of the road(computer system) so that the
cars(program) from all side of road move smoothly without traffic.
Unlock the Power of Placement Preparation!
There are mainly five types of system calls. These are explained in detail 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.
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.