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

Operating System

Unit – 1 :-Basics

1. Evaluation, Definition,
2. Operating System Functionalities
3. Types of OS
4. Computer Architecture Support to OS: Kernel & User mode
5. Introduction to System Calls.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 1


Srikakulam,RGUKT-AP
About an Operating System:
An operating system acts as an intermediary between the user of a computer
and the computer hardware. The purpose of an operating system is to provide an environment in
which a user can excute programs in a convenient and efficient manner.
(or)
An operating system is a program that controls the execution of application program and acts as an
interface between application and the computer hardware.
In OS the main objectives are

Convenience , Efficiency.

1. Convenience : An operating system makes a computer more convenient to use.


2. Efficiency : An operating system allows the computer system resources to be used in an efficient manner.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 2


Srikakulam,RGUKT-AP
Operating System Overview as a User / Computer Interface:
A computer system can be divided roughly into four components: the
hardware, the operating system, the application programs, and the users . The hardware the central
processing unit (CPU), the memory, and the input/output (I/O) devices provides the basic
computing resources for the system. The application programs such as word processors,
spreadsheets, compilers, and Web browsers define the ways in which these resources are used to
solve users’ computing problems. The operating system controls the hardware and coordinates its
use among the various application programs for the various users.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 3


Srikakulam,RGUKT-AP
OPERATING SYSTEM STRUCTURE

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 4


Srikakulam,RGUKT-AP
Evolution of Operating Systems
1. Early Systems (1950)
2. Simple Batch Systems (1960)
3. Multiprogrammed Batch Systems (1970)
4. Time-Sharing and Real-Time Systems (1970)
5. Personal/Desktop Computers (1980)
6. Multiprocessor Systems (1980)
7. Networked/Distributed Systems (1980)
8. Web-based Systems (1990)

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 5


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 6
Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 7
Srikakulam,RGUKT-AP
Early Systems
Structure:
1. Single user system.
2. Programmer/User as operator (Open Shop).
3. Large machines run from console.
4. Paper Tape or Punched cards.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 8


Srikakulam,RGUKT-AP
Example of an early computer
system

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 9


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 10
Srikakulam,RGUKT-AP
Simple Batch Systems
1. Use of high-level languages, magnetic tapes.
2. Jobs are batched together by type of languages.
3. An operator was hired to perform the repetitive tasks of loading jobs, starting the
computer, and collecting the output (Operator-driven Shop).
4. It was not feasible for users to inspect memory or patch programs directly.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 11


Srikakulam,RGUKT-AP
Operator-driven Shop

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 12


Srikakulam,RGUKT-AP
Operation of Simple Batch Systems

1. The user submits a job (written on cards or


tape) to a computer operator.
2. The computer operator place a batch of several
jobs on an input device.
3. A special program, the monitor, manages the
execution of each program in the batch.
4. Monitor utilities are loaded when needed.
5. “Resident monitor” is always in main memory
and available for execution.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 13
Srikakulam,RGUKT-AP
Idea of Simple Batch Systems
1. Reduce setup time by batching similar jobs.
2. Alternate execution between user program and
the monitor program.
3. Rely on available hardware to effectively alternate
execution from various parts of memory.
4. Use Automatic Job Sequencing – automatically
transfer control from one job when it finishes to
another one.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 14
Srikakulam,RGUKT-AP
Control Cards (1)
• Problems:
– 1. How does the monitor know about the nature of the job (e.g.,
Fortran versus Assembly) or which program to execute?
– 2. How does the monitor distinguish:
(a) job from job?
(b) data from program?
• Solution: Introduce Job Control Language (JCL) and
control cards.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 15


Srikakulam,RGUKT-AP
Control Cards (2)
• Special cards that tell the monitor which programs to run:
$JOB
$FTN
$RUN
$DATA
$END

• Special characters distinguish control cards from data or program cards:


$ in column 1
// in column 1 and 2
709 in column1

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 16


Srikakulam,RGUKT-AP
Job Control Language (JCL)

▪ JCL is the language that provides instructions to the monitor:


▪ what compiler to use $JOB
$FTN
▪ what data to use ...
▪ Example of job format: ------->> FORTRAN
program
▪ $FTN loads the compiler and transfers control to it. ...
▪ $LOAD loads the object code (in place of compiler).
$LOAD
$RUN
▪ $RUN transfers control to user program. ...
Data
...
$END

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 13 17


Srikakulam,RGUKT-AP
Example card deck of a Job

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 18


Srikakulam,RGUKT-AP
Effects of Job Control Language (JCL)
1. Each read instruction (in user program) causes one
line of input to be read.
2. Causes (OS) input routine to be invoked:
▪ checks for not reading a JCL line.
▪ skip to the next JCL line at completion of user program.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 19


Srikakulam,RGUKT-AP
Resident Monitor
1. Resident Monitor is first rudimentary OS.
2. Resident Monitor (Job Sequencer):
▪ initial control is in monitor.
▪ loads next program and transfers control to it.
▪ when job completes, the control transfers back to monitor.
▪ Automatically transfers control from one job to another, no idle time
between programs.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 20


Srikakulam,RGUKT-AP
Resident Monitor Parts
• Parts of resident monitor:
– Control Language Interpreter – responsible for reading and carrying out
instructions on the cards.
– Loader – loads systems programs and applications programs into memory.
– Device drivers – know special characteristics and properties for each of the
system’s I/O devices.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 21


Srikakulam,RGUKT-AP
Offline Operation
▪ Problem:

▪ Card Reader slow, Printer slow (compared to Tape).


▪ I/O and CPU could not overlap.
▪ Solution: Offline Operation (Satellite Computers) –
▪ Speed up computation by loading jobs into memory from tapes while card reading and line
printing is
done off-line using smaller machines.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 20 22


Srikakulam,RGUKT-AP
Main/Offline Computers

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 23


Srikakulam,RGUKT-AP
Resident Monitor Layout

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 24


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 25
Srikakulam,RGUKT-AP
We assumed Uniprogramming until now
▪ I/O operations are exceedingly slow (compared to
instruction execution).
▪ A program containing even a very small number
of I/O operations, will spend most of its time
waiting for them.
▪ Hence: poor CPU usage when only one program
is present in memory.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 26


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 27
Srikakulam,RGUKT-AP
Multiprogramming (1)

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 28


Srikakulam,RGUKT-AP
Multiprogramming (2)

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 29


Srikakulam,RGUKT-AP
Why Multiprogramming?
▪ Multiprogramming (also known as Multitasking)
needed for efficiency:
▪ Single user cannot keep CPU and I/O devices busy at all
times.
▪ Multiprogramming organizes jobs (code and data) so CPU
always has one to execute.
▪ A subset of total jobs in system is kept in memory.
▪ One job selected and run via job scheduling.
▪ When it has to wait (for I/O for example), OS switches to
another job.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 30
Srikakulam,RGUKT-AP
Components of Multiprogramming

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 31


Srikakulam,RGUKT-AP
Requirements for Multiprogramming
1. Hardware support:
1. I/O interrupts and DMA controllers
In order to execute instructions while I/O device is
busy.
2. Timer interrupts for CPU to gain control.
3. Memory management
several ready-to-run jobs must be kept in memory.
4. Memory protection (data and programs).
2. Software support from the OS:
1. For scheduling (which program is to be run
next).
2. To manage resource contention.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 32
Srikakulam,RGUKT-AP
FUNCTIONS OF OPERATING SYSTEM

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 33


Srikakulam,RGUKT-AP
Types of operating system
• Batch Operating System
• Multi-Programming System
• Multi-Processing System
• Multi-Tasking Operating System
• Time-Sharing Operating System
• Distributed Operating System
• Network Operating System
• Real-Time Operating System
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 34
Srikakulam,RGUKT-AP
Batch Operating System
This type of operating system does not interact with the
computer directly. There is an operator which takes similar
jobs having the same requirement and groups them into
batches. It is the responsibility of the operator to sort jobs
with similar needs.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 35


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 36
Srikakulam,RGUKT-AP
Advantages of Batch Operating System
• It is very difficult to guess or know the time required for
any job to complete. Processors of the batch systems
know how long the job would be when it is in the queue.
• Multiple users can share the batch systems.
• The idle time for the batch system is very less.
• It is easy to manage large work repeatedly in batch
systems.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 37
Srikakulam,RGUKT-AP
Disadvantages of Batch Operating System

• The computer operators should be well known with batch


systems.
• Batch systems are hard to debug.
• It is sometimes costly.
• The other jobs will have to wait for an unknown time if any
job fails.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 38
Srikakulam,RGUKT-AP
Starvation
• Batch processing suffers
from starvation.

There are five jobs J1, J2, J3, J4, and J5, present in the batch. If the execution time of J1 is very
high, then the other four jobs will never be executed, or they will have to wait for a very long time.
Hence the other processes get starved.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 39


Srikakulam,RGUKT-AP
Multiprogramming Operating System
• Multiprogramming is an extension to batch processing
where the CPU is always kept busy. Each process needs
two types of system time: CPU time and IO time.
• in a multiprogramming environment, when a process does
its I/O, The CPU can start the execution of other
processes. Therefore, multiprogramming improves the
efficiency of the system.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 40


Srikakulam,RGUKT-AP
Advantages of Multiprogramming OS:

• Throughout the system, it increased as the


CPU always had one program to execute.
• Response time can also be reduced.

Disadvantages of Multiprogramming OS
• Multiprogramming systems provide an
environment in which various systems
resources are used efficiently, but they do
not provide any user interaction with the
computer system.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 41


Srikakulam,RGUKT-AP
Throughput − Throughput is the amount of work completed
in a unit of time. In other words throughput is the processes
executed to number of jobs completed in a unit of time

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 42


Srikakulam,RGUKT-AP
Multiprocessing operating system
• In Multiprocessing, Parallel computing is achieved. There
are more than one processors present in the system
which can execute more than one process at the same
time. This will increase the throughput of the system

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 43


Srikakulam,RGUKT-AP
• In Multiprocessing, Parallel
computing is achieved. More
than one processor present
in the system can execute
more than one process
simultaneously, which will
increase the throughput of
the system.I

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 44


Srikakulam,RGUKT-AP
Advantages of Multiprocessing operating
system:

• Increased reliability: Due to the multiprocessing system,


processing tasks can be distributed among several
processors. This increases reliability as if one processor
fails, the task can be given to another processor for
completion.
• Increased throughout: As several processors increase,
more work can be done in less.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 45


Srikakulam,RGUKT-AP
Disadvantages of Multi-Processing
Operating System

• Due to the multiple CPU, it can be more complex and


somehow difficult to understand.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 46


Srikakulam,RGUKT-AP
multitasking operating system
• The multitasking operating system is a logical extension
of a multiprogramming system that enables multiple
programs simultaneously. It allows a user to perform more
than one computer task at the same time.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 47


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 48
Srikakulam,RGUKT-AP
Advantages of Multitasking • Disadvantages of
operating system Multi-Tasking Operating
• This operating system is System
more suited to supporting SS
multiple users • The system gets heated in
simultaneously. case of heavy programs
• The multitasking operating multiple times.
systems have well-defined
memory management.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 49
Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 50
Srikakulam,RGUKT-AP
Time-Sharing Operating Systems
• Each task is given some time to execute so that all the
tasks work smoothly. Each user gets the time of the CPU
as they use a single system. These systems are also
known as Multitasking Systems. The task can be from a
single user or different users also. The time that each task
gets to execute is called quantum. After this time interval
is over OS switches over to the next task.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 51


Srikakulam,RGUKT-AP
Advantages of Time-Sharing OS

• Each task gets an equal opportunity.


• Fewer chances of duplication of software.
• CPU idle time can be reduced.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 52


Srikakulam,RGUKT-AP
• 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. 53
• 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.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 54


Srikakulam,RGUKT-AP
• 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.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT


Srikakulam,RGUKT-AP
Distributed Operating System
• he Distributed Operating system is not installed on a
single machine, it is divided into parts, and these parts are
loaded on different machines. A part of the distributed
Operating system is installed on each machine to make
their communication possible. Distributed Operating
systems are much more complex, large, and
sophisticated than Network operating systems because
they also have to take care of varying networking
protocols.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 56
Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 57
Srikakulam,RGUKT-AP
• Advantages of Distributed Operating System
• The distributed operating system provides sharing of
resources.
• This type of system is fault-tolerant.
• Disadvantages of Distributed Operating System
• Protocol overhead can dominate computation cost.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 58


Srikakulam,RGUKT-AP
Network Operating System
These systems run on a server and provide the capability to
manage data, users, groups, security, applications, and other
networking functions. These types of operating systems
allow shared access to files, printers, security, applications,
and other networking functions over a small private network.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 59


Srikakulam,RGUKT-AP
• One more important aspect of Network Operating
Systems is that all the users are well aware of the
underlying configuration, of all other users within the
network, their individual connections, etc. and that’s why
these computers are popularly known as tightly coupled
systems.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 60


Srikakulam,RGUKT-AP
Advantages of Network
Operating System
Disadvantages of Network
• Highly stable centralized
Operating System
servers.
• Security concerns are handled • Servers are costly.
through servers. • User has to depend on a
• New technologies and central location for most
hardware up-gradation are
operations.
easily integrated into the
system. • Maintenance and updates
• Server access is possible are required regularly.
remotely from different
locations and types of
systems. By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 61
Srikakulam,RGUKT-AP
Examples of Network Operating Systems
are
Microsoft Windows Server 2003, Microsoft Windows
Server 2008, UNIX, Linux, Mac OS X, Novell
NetWare, BSD, etc.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 62


Srikakulam,RGUKT-AP
Real-Time Operating System
• These types of OSs serve real-time systems. The
time interval required to process and respond to
inputs is very small. This time interval is called
response time.
• Real-time systems are used when there are time
requirements that are very strict like missile systems,
air traffic control systems, robots, etc.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 63


Srikakulam,RGUKT-AP
Types of Real-Time Operating Systems
• Hard Real-Time Systems:
• Hard Real-Time OSs are meant for applications where time
constraints are very strict and even the shortest possible
delay is not acceptable. These systems are built for saving
life like automatic parachutes or airbags which are required
to be readily available in case of an accident. Virtual
memory is rarely found in these systems.
• Soft Real-Time Systems:
• These OSs are for applications where time-constraint is
less strict. By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 64
Srikakulam,RGUKT-AP
• Examples of Real-Time Operating Systems are
Scientific experiments, medical imaging systems,
industrial control systems, weapon systems,
robots, air traffic control systems, etc

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 65


Srikakulam,RGUKT-AP
system calls in Operating System
• A system call is a mechanism 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.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 66


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 67
Srikakulam,RGUKT-AP
Functions of an Operating System
• Memory Management
• The operating system manages the Primary Memory or
Main Memory. Main memory is made up of a large array
of bytes or words where each byte or word is assigned a
certain address. Main memory is fast storage and it can
be accessed directly by the CPU.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 68


Srikakulam,RGUKT-AP
• For a program to be executed, it should be first loaded in
the main memory. An operating system manages the
allocation and deallocation of the memory to various
processes and ensures that the other process does not
consume the memory allocated to one process.An
Operating System performs the following activities for
Memory Management:

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 69


Srikakulam,RGUKT-AP
• It keeps track of primary memory, i.e., which bytes of
memory are used by which user program. The memory
addresses that have already been allocated and the
memory addresses of the memory that has not yet been
used.
• In multiprogramming, the OS decides the order in which
processes are granted memory access, and for how long.
• It Allocates the memory to a process when the process
requests it and deallocates the memory when the process
has terminated or ByisM performing an I/O
Roopa ,Assistant Prof(C), CSE Dept,IIIT
Srikakulam,RGUKT-AP operation. 70
• Device Management

• The operating system manages the communication


between the computer system and the peripheral devices
connected to the I/O port of the system. Peripheral
devices use their respective drivers to communicate with
the system. The operating system determines which
program or process is accessed by which connection and
device. It also makes sure when a program is executed or
terminated, it will stop the communication
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT
Srikakulam,RGUKT-AP between the 71
• process Management

• The process is a program under the execution. The


operating system manages all the processes so that each
process gets the CPU for a specific time to execute itself,
and there will be less waiting time for each process. This
management is also called process scheduling

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 72


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 73
Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 74
Srikakulam,RGUKT-AP
system calls in Operating System
• A system call is a mechanism 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.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 75


Srikakulam,RGUKT-AP
• System call offers the services of the operating system to
the user programs via API (Application Programming
Interface). System calls are the only entry points for the
kernel system.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 76


Srikakulam,RGUKT-AP
• System calls are usually made when a process in user
mode requires access to a resource. Then it requests the
kernel to provide the resource via a system call.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 77


Srikakulam,RGUKT-AP
A figure representing the execution of the system call is given as follows −

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 78


Srikakulam,RGUKT-AP
• the processes execute normally in the user mode until a
system call interrupts this. Then the system call is
executed on a priority basis in the kernel mode. After the
execution of the system call, the control returns to the
user mode and execution of user processes can be
resumed.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 79


Srikakulam,RGUKT-AP
• n general, system calls are required in the following
situations −

• If a file system requires the creation or deletion of files.


Reading and writing from files also require a system call.
• Creation and management of new processes.
• Network connections also require system calls. This
includes sending and receiving packets.
• Access to a hardware devices such as a printer, scanner
etc. requires a system call.
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 80
Srikakulam,RGUKT-AP
Types of System Calls
• Here are the five types of System Calls in OS:

• Process Control
• File Management
• Device Management
• Information Maintenance
• Communications

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 81


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 82
Srikakulam,RGUKT-AP
1. Process Control
This system calls perform the task of process creation,
process termination, etc.
Functions:
• End and Abort
• Load and Execute
• Create Process and Terminate Process
• Wait and Signal Event
• Allocate and free memory

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 83


Srikakulam,RGUKT-AP
2.File Management
• File management system calls handle file manipulation
jobs like creating a file, reading, and writing, etc.
Functions:
• Create a file
• Delete file
• Open and close file
• Read, write, and reposition
• Get and set file attributes

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 84


Srikakulam,RGUKT-AP
• Device Management
• Device management does the job of device manipulation
like reading from device buffers, writing into device
buffers, etc.

• Functions:

• Request and release device


• Logically attach/ detach devices
• Get and Set device attributes
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 85
Srikakulam,RGUKT-AP
• Information Maintenance
• It handles information and its transfer between the OS
and the user program.

• Functions:

• Get or set time and date


• Get process and device attributes
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 86
Srikakulam,RGUKT-AP
• Communication
• These types of system calls are specially used for
interprocess communications.

• Functions:

• Create, delete communications connections


• Send, receive message
• Help OS to transfer status information
• Attach or detach remote devices
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 87
Srikakulam,RGUKT-AP
important System Calls Used in OS
wait()
• In some systems, a process needs to wait for another
process to complete its execution. This type of situation
occurs when a parent process creates a child process,
and the execution of the parent process remains
suspended until its child process executes.
• The suspension of the parent process automatically
occurs with a wait() system call. When the child process
ends execution, the control moves back to the parent
process. By M Roopa ,Assistant Prof(C), CSE Dept,IIIT
Srikakulam,RGUKT-AP
88
• fork()
• Processes use this system call to create processes that
are a copy of themselves. With the help of this system
Call parent process creates a child process, and the
execution of the parent process will be suspended till the
child process executes.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 89


Srikakulam,RGUKT-AP
• exec()
• This system call runs when an executable file in the
context of an already running process that replaces the
older executable file. However, the original process
identifier remains as a new process is not built, but stack,
data, head, data, etc. are replaced by the new process.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 90


Srikakulam,RGUKT-AP
• kill()
• The kill() system call is used by OS to send a termination
signal to a process that urges the process to exit.
However, a kill system call does not necessarily mean
killing the process and can have various meanings.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 91


Srikakulam,RGUKT-AP
exit()
The exit() system call is used to terminate program
execution. Specially in the multi-threaded environment, this
call defines that the thread execution is complete. The OS
reclaims resources that were used by the process after the
use of exit() system call.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 92


Srikakulam,RGUKT-AP
open()
The open() system call is used to provide access to a file in
a file system. This system call allocates resources to the file
and provides a handle that the process uses to refer to the
file. A file can be opened by multiple processes at the same
time or be restricted to one process. It all depends on the
file organisation and file system.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 93


Srikakulam,RGUKT-AP
read()
• The read() system call is used to access data from a file
that is stored in the file system. The file to read can be
identified by its file descriptor and it should be opened
using open() before it can be read. In general, the read()
system calls takes three arguments i.e. the file descriptor,
buffer which stores read data and number of bytes to be
read from the file.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 94


Srikakulam,RGUKT-AP
write()
• The write() system calls writes the data from a user buffer
into a device such as a file. This system call is one of the
ways to output data from a program. In general, the write
system calls takes three arguments i.e. file descriptor,
pointer to the buffer where data is stored and number of
bytes to write from the buffer.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 95


Srikakulam,RGUKT-AP
• close()
• The close() system call is used to terminate access to a
file system. Using this system call means that the file is no
longer required by the program and so the buffers are
flushed, the file metadata is updated and the file
resources are de-allocated.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 96


Srikakulam,RGUKT-AP
close()
The close() system call is used to terminate access to a file
system. Using this system call means that the file is no
longer required by the program and so the buffers are
flushed, the file metadata is updated and the file resources
are de-allocated.

By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 97


Srikakulam,RGUKT-AP
By M Roopa ,Assistant Prof(C), CSE Dept,IIIT 98
Srikakulam,RGUKT-AP

You might also like