Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Osy Chapter-2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Operating system 22516

Unit -II
Services and components of operating system: (Marks 10)
2.1 Different services of Operating System.
2.2 System Calls-Concept,types of system calls
2.3 OS components:- Process Management,Main Memory Management,File
Management,I/O syste, Management, Secondary Storage Management.
2.4 Use of operating system tools:- user management,security policy,device
management,performance monitor,task schedular

Operating System services:


An operating system provides services to programs and to the users of those
programs. It provides environment for the execution of programs. The services
provided by one operating system are different than other operating system.
Operating system makes the programming task easier.
The common service provided by the operating system is listed below.
1. User Interface
2. Program execution
3. I/O operation
4. File system manipulation
5. Communications
6. Error detection
7. Resource management
8. Protection and security
9. Accounting

OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 1


User Interface
• Almost all operating systems have a user interface (UI).
• The interface can take several forms. One is a DTrace command-line interface
(CLI), which uses text commands and a method for entering them (say, a
program to allow entering and editing of commands).
• Another is a batch interface ,in which commands and directives to control those
commands are entered into files, and those files are executed . Most commonly,
a graphical user interface (GUI) is used.

1. Program execution

The main function of OS is to provide an efficient and convenient environment for


the execution of programs. The Operating system must be able to load the program
into memory and execute it. The program must be able to terminate its execution,
either normally or abnormally.
● Loads a program into memory.
● Executes the program.
● Terminates the execution either normally or abnormally

2. I/O Operation
● The executing program may require some input and produces some output.
● The input may be either from a file on the disk or from some other input device.
● The output may be written to some file on disk or sent to some output device.
● The operating system makes these files and I/O device available to the user.

3. File system manipulation


● The operating system makes a file available to the program for reading or writing
or for both either sequentially or randomly.
● It first takes a security checks. After satisfying all the checks it allows the user to
read the file and to make changes in the file.
● Operating System provides an interface to the user to create/delete files.
● Operating System provides an interface to the user to create/delete directories.
● Operating System provides an interface to create the backup of file system.

4. Communication

Following are the major activities of an operating system with respect to


communication.
● Two processes often require data to be transferred between them.

OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 2


● The both communicating processes can be on the same computer or on different
computer connected through computer network.
● Operating system provides facilities for communication between the two
processes.

5. Error Detection

The malfunctioning of the system may be due to the errors occured in CPU, I/O
devices or in the memory hardware. Following are the major activities of an
operating system with respect to error handling -
● OS constantly remains aware of possible errors.
● OS takes the appropriate action to ensure correct and consistent computing.

6. Resource Management

In case of multi-user or multi-tasking environment, resources needed to be shared


among multiple users and jobs. Following are the major activities of an operating
system with respect to resource management -
● CPU scheduling algorithms are used for better utilization of CPU.
● There will be routines for allocation and deallocation of resources like memory,
I/O devices and files.

7. Protection and security

Protection refers to mechanism or a way to control the access of programs,


processes, or users to the resources defined by computer systems. Following are the
major activities of an operating system with respect to protection.
● OS ensures that all access to system resources is controlled.
● OS ensures that external I/O devices are protected from invalid access attempts.
● OS provides authentication feature for each user by means of a password.

8. Accounting:

It is necessary to keep log of resources used by each user in multiuser environment.


It is useful for increasing system’s efficiency.
SYSTEM CALLS
● User cannot execute privileged instructions.
● System calls provide an interface between the process & the OS.
● The calls are generally available as assembly language instruction & certain
system allow system calls to be written in a high level language program.
● Several languages as C or C++ have been defined to replace assembly language
program.
OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 3
● A system call instruction generates an interrupt and allows OS to gain control of
the processor.

How System Calls Work


● The hardware provides a mechanism that a running program can use to cause a
system call. Often, it is a special instruction.
● What happens on a system call:

● It provides interface between a process and OS.


● These calls are available as assembly language instructions.
● Some system calls can be written in HLL programs.
● These calls normally resemble predefined functions/ subroutine calls.
● Languages such as C,C# and Perl have been used defined to replace assembly
language for system programs.

➢ Once a system call occurs, the processor is switched from the user mode to
kernel(privileged) execution mode.
➢ key parts of the current process, like the program counter and the stack pointer,
are saved.
➢ The current program execution flow is changed so that the program counter is
set to a fixed (determined by the hardware) memory address, which is within the
kernel’s address space. The stack pointer is pointed at a stack in the kernel’s address
space.
➢ The kernel’s handler determines which service the calling process wanted, and

OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 4


performs that service.
➢ When the kernel is finished, it returns from the system call and switches the
processor back to unprivileged (user) execution mode.
➢ Now the processor is executing the calling process’ program again, picking up

where it left off when it made the system call.


Types of System Calls:
System calls can be roughly grouped into five major categories: 4
1. Process Control :

Process means program under execution. If a single process is running at a time


then there is no need of scheduling. But when multiple processes are there it should
be properly handled.
Multiple processes are created while execution of program. These processes need to
communicate with each other.
After execution of a process it should be terminated or if some error occurs then it
should be terminated abnormally.
When processor switches from one process to another it need to save the
information about the current process (attributes).
Sometimes processes need to wait till certain event occurs.(wait time system call).
Following system calls are generated related to process management.
● Create/ Terminate.
● Load/Execute.
● End/Abort process.
● Ready process/Dispatch process.
● Suspend process/Resume Process.
● Get/Set Process Attributes.
● Wait event, signal event
● Allocate and deallocate memory
2. File management :

Operating system provides several system calls related to files.


Users need to create and delete files. This kind of system calls needs the name of
the file and some of its attributes.
User need to read, write and reposition a file. Once the operations are performed
user need to close a file.
Same operations are needed to be performed on directories.
User needs some attributes (name, type, size etc) values and needs to reset them
whenever necessary.
System calls related to file management are:

OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 5


● create new file, delete existing file
● open, close file
● Create and delete directories
● read, write, reposition
● get/set file attributes

3. Device Management :

The system calls are also used for accessing devices. Many of the system calls used
for files are also used for devices.
In multi user environment the request is made to use the device. After using the
device, it must be released. Using release system call the device is freed to be used
by another user. These functions are similar to open & close system calls of files.
● request device, release device
● read, write, reposition
● get/set device attributes
● logically attach or detach devices
4. Information Maintenance :
Many system calls exist only for the purpose of transferring information between
the user program and the operating system.
For example the information like, current date and time, number of current users,
version number of OS, the amount of free memory or disk space etc.
System calls related to information maintenance are:
● get/set time or date
● get/set system data
● get/set process, file, or device attributes
5. Communication:

Processes need to exchange information with each other. Various system calls are
used during this information exchange.
● create, delete communication connection
● send, receive messages
● transfer status information
● attach or detach remote devices

System component activities


1. Process Management:

A process is a program in execution. A process needs certain resources, including


CPU time, memory, files, and I/O devices, to accomplish its task.

OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 6


● Processes can create sub-processes to execute concurrently.
● A program by itself is not a process; a program is a passive entity, whereas a
process is an active entity.
● The execution of a process must progress in a sequential fashion. The CPU
executes one instruction of the process after another until the process completes.
● Operating System processes: Those execute system code.
● User processes: Those that execute user code.

The operating system is responsible for the following activities in connection with
process management.
a) Process creation :
It involves loading the program from secondary storage to main memory.
b) Process deletion:
When the process has successfully finished its execution or when the process is
terminated forcibly by OS.
c) Process scheduling or dispatching:
Transferring a process from ready state to run state.
d) Process synchronization:
It provides the mechanism for process synchronization for sharing resources
amongst concurrent processes.
e) Process communication:
It provides the mechanism for inter-process communication amongst concurrent
processes.
f) Deadlock handling:
It provides the mechanism for deadlock handling.
g) Process suspension:
Transferring a process from run state to wait state.
h) Process resumption:
Transferring a process from wait state to ready state.

2. Main-Memory Management
● For execution of a program it must be loaded into memory and when a program
terminates, the memory space occupied by this program should be freed.
● The operating system is responsible for the following activities in connections
with memory management.
a) Keep track of which segment of memory is currently being used and by whom.
b) Decide which processes to load when memory space becomes available.
c) Allocate and deallocate memory space as needed.
d) Swapping in and out of processes.

3. File Management

OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 7


● A file is a collection of related information defined by its creator. Commonly,
files represent programs (both source and object forms) and data.
● A file consists of a sequence of bits, bytes, lines, or records whose meanings are
defined by their creators.
● The operating system is responsible for the following activities in connections
with file management
a) File creation and deletion.
b) Directory creation and deletion.
c) Support of primitives for manipulating files and directories.
d) Mapping files onto secondary storage.
e) File backup on stable (nonvolatile) storage media.

4. I/O System Management


● The operating system has device drivers to facilitate I/O functions.
● The device drivers are nothing but software routines that control respective I/O
devices.
● I/O subsystem hides the peculiarities of specific hardware devices from the user.
Only the device driver knows the peculiarities of the specific device to whom it is
assigned.

The functions of OS related to I/O System management are:


a) Hiding the peculiarities of specific hardware devices from user.
b) Issue low level commands to the devices, catches interrupts and handles errors.
c) The operating system provides a device independent API to the user programs,
which includes buffering.

5. Secondary-Storage Management
● The main purpose of OS is to execute programs.
● Instructions and data must be placed in primary storage or cache.
● But the main memory is too small to accommodate all data and programs, and its
data are lost when power is lost.
● The computer system must provide secondary storage to back up main memory.
● Secondary storage consists of tapes, disks, and other media designed to hold
information that will eventually be accessed in primary storage.
The three major activities of an operating system related to secondary storage
management are:
a) Managing the free space available on the secondary-storage device.
b) Allocation of storage space when new files have to be written.
c) Scheduling the requests for memory access.

OPERATING SYSTEM CHAPTER -2 NOTES MEENA TALELE 8

You might also like