0% found this document useful (0 votes)
39 views

OSY Ch-2

The document discusses operating system services and system calls. It provides: 1) A list of 9 common operating system services including user interface, program execution, I/O operations, file system manipulation, communications, error detection, and resource allocation. 2) Explanations and examples of 4 operating system services - user interface, program execution, I/O operations, and file system manipulation. 3) A definition of system calls as an interface between processes and the operating system that allows processes to request services from the OS. 4) Examples of the open() and close() system calls, describing their purpose and functionality.

Uploaded by

Pankaj Sangale
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)
39 views

OSY Ch-2

The document discusses operating system services and system calls. It provides: 1) A list of 9 common operating system services including user interface, program execution, I/O operations, file system manipulation, communications, error detection, and resource allocation. 2) Explanations and examples of 4 operating system services - user interface, program execution, I/O operations, and file system manipulation. 3) A definition of system calls as an interface between processes and the operating system that allows processes to request services from the OS. 4) Examples of the open() and close() system calls, describing their purpose and functionality.

Uploaded by

Pankaj Sangale
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/ 12

2.

1 SERVICES PROVIDED BY OS

Q] List services provided by OS and explain any four of them. [S-10, 11,12,13,15, W-09, 11, 12, 14]
(List – 2 Marks, Any four – 2 Marks (½ Mark each))

Operating System Services:


1. User Interface
2. Program execution
3. I/O operations
4. File-system manipulation
5. Communications
6. Error detection
7. Resource Allocation
8. Accounting
9. Protection and Security

OS services provided to the user:-

1. User Interface: -
All operating systems have a user interface that allows users to communicate with the
system.
There are three types of user interfaces are available:-
1. Command line interface (CLI): - It uses text commands and a method for
entering them. For example:- Working on DOS prompt.
2. Batch interface: - User creates batch file which contains multiple executable
commands in a sequence which gets executed one by one or sequentially.
3. Graphical user interface (GUI): - This interface is a window system with a
pointing device to direct I/O, select from menus and keyboard to enter the text.
For example, Windows system provides icons for selecting an application. Double
clicking on that icon will open that application.

2. Program execution
Operating system provides an environment where the user can conveniently run programs.
To run a program, the program is loaded into the main memory and then CPU is assigned
to that process for its execution.
It also performs other important tasks like allocation and de-allocation of memory, CPU
scheduling etc.
It also provides service to end process execution either normally or abnormally by
indicating error.

3. I/O operations
When a program is running, it may require input/output resources such as a file or devices
such as printer.
For efficiency and protection users usually cannot control I/O devices directly.
So the operating system provides a service to do I/O.
4. File-system manipulation
Programs may need to read and write data from and to the files and directories.
Operating system manages the secondary storage.
User gives a command for reading or writing to a file.
Operating system helps user programs to perform their task such as opening a file, saving
a file and deleting a file from the storage disk.
It also provides services for file permission management to allow or deny access to files or
directories based on file ownership.

5. Communications
In the system, one process may need to exchange information with another process.
Communication can be implemented via shared memory or through message passing, in
which packets of information are moved between processes by the operating system.

6. Error detection
Error detection occurs at both the hardware and software levels.
At the hardware level, all data transfers are checked to ensure that data have not been
corrupted.
At the software level, media must be checked for data consistency; for instance, whether
the number of allocated and unallocated blocks of storage matches the total number on
the device.

OS services provided to the system:-

1. Resource allocation: -
When there are multiple users or multiple processes running at the same time, resources
must be allocated to each of them.
Operating system manages resource allocation to the processes. These resources are CPU,
main memory, file storage and I/O devices.
For maximizing use of CPU, operating system does CPU scheduling.

2. Accounting:
Operating system keeps track of usages of various computer resources allocated to users.

3. Protection & security:

When several separate processes execute concurrently, one process should not interfere
with the other processes or operating system itself.
Protection provides controlled access to system resources.
Security is provided by user authentication such as password for accessing information.
EXPLANATION OF HOW SYSTEM CALLS WORK:-
Let’s first use an example to illustrate how system calls are used: writing a simple program to read
data from one file and copy them to another file. The first input that the program will need is the
names of the two files: the input file and the output file. One approach is for the program to ask the
user for the names. In an interactive system, this approach will require a sequence of system calls, first
to write a prompting message on the screen and then to read from the keyboard the characters that
define the two files. When the program tries to open the input file, for example, it may find that there is
no file of that name or that the file is protected against access. In these cases, the program should print
a message on the console (another sequence of system calls) and then terminate abnormally (another
system call). If the input file exists, then we must create a new output file. We may find that there is
already an output file with the same name. This situation may cause the program to abort (a system
call), or we may delete the existing file (another system call) and create a new one (yet another system
call). When both files are set up, we enter a loop that reads from the input file (a system call) and
writes to the output file (another system call). Each read and write must return status information
regarding various possible error conditions. On input, the program may find that the end of the file has
been reached or that there was a hardware failure in the read (such as a parity error). The write
operation may encounter various errors; depending on the output device (for example, no more disk
space). Finally, after the entire file is copied, the program may close both files (another system call),
write a message to the console or window (more system calls), and finally terminate normally (the
final system call). This system-call sequence is shown in Figure.
2.2 SYSTEM CALL

Q] Describe the purpose of system calls? State two system calls with its functions. [W-16]
Q] What is system call? Explain use of any two categories of system call.
[W-14]
Q] What is system call? With the help of diagram explain open ( ) system call. [S-17]

System Call
System calls provide an interface between the process and the operating system.

Purpose of System Call


System calls allow user-level processes to request some services from the operating
system which the process itself is not allowed to do.
System call provides basic functionality to user to operate operating system.
System calls are programming interface to the services provided by the Operating system.

System Call Implementation:


1. Each system call associated with a particular number.
2. System call interface maintains a table indexed according to these numbers.
3. The system call interface invokes intended system call in operating system kernel
& returns status of the system call and any return values.
4. The caller needs to know nothing about how the system call is implemented.
Just needs to obey API and understand what OS will do as a result call.
5. Most details of operating system interface are hidden from programmers by
API. It is managed by run-time support library.

Fig: - System Call Implementation


Open System Call ():
Open () system call is basically for opening a file.
Open () system call is used by the programs for initializing an access to the file.
When this call is used, it returns file descriptor.
This descriptor is positive integer value.
It indicates the position of the file from the table of open files.
Close System Call ():
Close () System call is used to close the file that is recently opened.
It basically removes all resources allocated to the file that is closed.
It clears the memory including buffers.
It clears the memory including buffers.
It even updates the metadata related to closed files.

Types of System Call

Q] Sate any four types of system call provided by an operating system. [W 14,S 15,16, 17]
Q] List any four system calls for device management and communication. [W15]
System calls related to Process Control:
 End, Abort
 Load, Execute
 Create process, Terminate process, Ready process, Dispatch process
 Suspend, Resume
 Get Process attribute, set Process attribute
 Wait for time
 Wait event
 signal event

System calls Related to File Management:


 Create file, delete file
 Open file , Close file
 Read, Write, Reposition
 Get file attribute , set file attribute,
 Create a link, Change the working directory.

System calls Related to Device Management:


 Request a device, Release a device
 Read, Write, Reposition,
 Get device attribute, Set device attribute
 Logically attach or detach device

System calls Related to Information Maintenance:


 Get Time or Date, Set Time or Date
 Get System data, Set system data
 Get process, file or device attributes, Set Process, file or Device attributes.

System calls Related to Communication:


 create, delete communication connection
 send, receive messages,
 transfer status information
 attach or detach remote devices
Memory Management Related System Calls:
 shmget
 shmat
 shmdt
 shmctl

Layered Approach

Q] Explain Layered Approach for the Operating System. [W-16]

The operating system is divided into a number of layers (levels).


Each layer is built on top of lower layers.
An operating-system layer is an implementation of an abstract object made up of data and
the operations that can manipulate those data.
The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.
A typical operating-system layer—say, layer M—consists of data structures and a set of
routines that can be invoked by higher-level layers.
Layer M, in turn, can invoke operations on lower-level layers.
Each layer is selected such that each layer uses functions (operations) and services of only
lower-level layers.
The main advantages of Layered Approach are: it is simple to construct and debug.
The major difficulty with the layered approach involves appropriately defining the various
layers, because a layer can use only those layers below it.

Fig: A layered operating system


Microkernel [W-16, S-16, W-14]

Q] Describe Microkernel Operating System Structure.


In this system, kernel provides only the most essential operating system functions like
process management, communication primitives and low level memory management.
Nonessential components are removed from the kernel and they are implemented as
system and user-level programs outside the kernel.
These system programs and user level programs implemented outside the kernel,
provides the remaining operating system services. These programs are known as servers.
Due to separation of functionality of kernel, size of the kernel is reduced.
This reduced kernel is called as microkernel.
The application programs and various servers that are running in user space
communicate with each other using messages that are passed through microkernel.
The microkernel validates the messages and passes them between the various modules of
the operating system and permits access to the hardware.

Write following points if asked for 6 marks:

One benefit of the microkernel approach is that it makes extending the operating system
easier.
All new services are added to user space and consequently do not require modification
of the kernel.
When the kernel does have to be modified, the changes tend to be fewer, because the
microkernel is a smaller kernel.
The resulting operating system is easier to port from one hardware design to another.
Monolithic Systems

Draw and explain monolithic structure of operating system. [W15, S14, S17, S16, W15]
(Explanation- 3Marks, Diagram-3Marks)
This approach is well known as “The Big Mess”.

The structure is that there is no structure.

The operating system is written as a collection of procedures, linked together into a


single large executable binary program.

Each procedure in the system has a well-defined interface in terms of parameters and
results.

Each procedure is free to call any other one, if the second procedure provides some useful
computations

1. First compilers compile all the individual procedures (or files containing the
procedures).
2. After this it binds them all together into a single object file with the linker.

In terms of information hiding, there is essentially none- every procedure is visible to every
other one.

However, even in Monolithic systems, it is possible to have at least a little structure.

The services like system calls, are requested by putting the parameters in well-defined places,
such as in registers or on the stack and then executing a special trap instruction known as a
kernel call or supervisor call.
COMPONENTS OF OS
Q] List system component. Explain any two. [S-15]
(List - 1Mark, Description of any two – 1 ½ Marks each)
Q] List components of OS. Explain any one in detail. [W-14]
(List - 1 Mark, Description of any one - 3 Marks)
Q] Describe activities of I/O system and secondary storage management. [S-17]
Q] List and explain components of operating system. (6 MARKS) [W-16]

Ans: List of System Components:


1. Process management
2. Main memory management
3. File management
4. I/O system management
5. Secondary storage management
1. Process Management
The operating system manages many kinds of activities ranging from user programs to
system programs like printer spooler, name servers, file server etc.
Each of these activities is encapsulated in a process.
A program does nothing unless its instructions are executed by CPU.
A program in execution is called as Process.
A process includes the complete execution context (code, data, registers, resources in
use etc.).
A word processor program being run by an individual user on PC is a process.
A system task, such as sending output to a printer can also be a process.
A process needs certain resources including CPU Time, memory, files and I/O devices to
accomplish its task. After creating the process it will also require some initialization data. So
this data and the resources becomes the part of Process.
It is process, rather than application, that the operating system controls and schedules for
execution by the CPU.

The five major activities of an operating system in regard to process management are
 Creation and deletion of user and system processes.
 Suspension and resumption of processes.
 A mechanism for process synchronization.
 A mechanism for process communication.
 A mechanism for deadlock handling.

2. Main-Memory Management
Primary-Memory or Main-Memory is a large array of words or bytes.
Each word or byte has its own address.
Main-memory provides storage that can be accessed directly by the CPU.
So a program to be executed must be in the main memory.
Services provided under Memory Management are directed to keep track of memory and
allocating/ deallocating it to various processes. The OS keeps a list of free memory locations.
Before a program is loaded in the memory from the disk, this MM consults the free list,
allocates the memory to the process, depending upon the program size and updates the list of
free memory.
The major activities of an operating in regard to memory-management are:
 Keep track of which part of memory are currently being used and by whom.
 Decide which process are loaded into memory when memory space becomes
available
 Allocate and de-allocate memory space as needed.

3. File Management
A file is a collection of related information defined by its creator.
Computer can store files on the disk (secondary storage), which provide long term
storage.
Some examples of storage media are magnetic tape, magnetic disk and optical disk.
Each of these media has its own properties like speed, capacity, and access methods.
A file systems normally organized into directories to ease their use.
These directories may contain files and other directions.
The five main major activities of an operating system in regard to file management are
 The creation and deletion of files.
 The creation and deletion of directories.
 The support for manipulating files and directions.
 The mapping of files onto secondary storage.
 The backup of files on stable storage media.

4. I/O System Management


Input / Output device management provides an environment for the better interaction
between system and the I/O devices such as printers, scanners, tape drives etc.
To interact with I/O devices in an effective manner, the operating system uses some
special programs known as device driver.
A device driver is a specific type of computer software that is developed to allow interaction
with hardware devices.
Activities:
 Providing interfaces to other system components.
 Managing devices
 Transferring data
 Detecting I/O completion

5. Secondary-Storage Management
Systems have several levels of storage, including primary storage, secondary storage and
cache storage.
Instructions and data must be placed in primary storage or cache to be referenced by a
running program.
Because 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.
It is ordinarily divided into bytes or words consisting of a fixed number of bytes.
The three major activities of an operating system in regard to secondary storage management
are:
 Managing the free space available on the secondary-storage device
 Allocation of storage space when new files have to be written.
 Scheduling the requests for memory access.

Operating System tools


Following are the Operating System tools:
 User Management
 Device Management
 Security policy
 Performance Monitor
 Task Scheduler

A) User management:
User management is one of the important tool that OS has to provide.
OS can be Multiuser or Single User.
In case of Multiuser OS, the levels of rights and privileges can be different.
So OS need to keep log of everything related to user (e.g Login and Logout Time)
User management includes everything from creating a user to deleting a user on your system.
Command line tools include commands like useradd, userdel, usermod, passwd, etc.
These are mostly used by the server administrators.
Useradd: With useradd commands you can add a user.
Userdel: To delete a user account userdel command is used.
Usermod: The command usermod is used to modify the properties of an existing user.
Passwd: A user can set the password with the command passwd.

B) Device Management:

Device management is responsible for managing all the hardware devices of the computer
system.
It may also include the management of the storage device as well as the management of all the
input and output devices of the computer system.
It is the responsibility of the operating system to keep track of the status of all the devices in
the computer system.
The status of any computing devices, internal or external may be either free or busy.
If a device requested by a process is free at a specific instant of time, the operating system
allocates it to the process.
OS is also capable of device communication.
C) Security policy:

Various operating system security policies may be implemented based on the organization.
Security policy is used by OS to ensure that it maintains integrity, confidentiality, and
availability.
OS Security protects systems and data from malware, threats, viruses, etc.
Security policies handle all preventative activities and procedures to ensure an operating
system's protection, including steal, edited, and deleted data.

Some major activities related to security are:

1. Installing and updating anti-virus software


2. Ensure the systems are patched or updated regularly
3. Implementing user management policies to protect user accounts and privileges.
4. Installing a firewall and ensuring that it is properly set to monitor all incoming and
outgoing traffic.

D) Performance Monitor:

Most fundamental linux Performance Monitor commands :


1) vmstat: Virtual memory statistics
The vmstat command reports information about processes, memory,

2) top: table of processes


It is Process activity monitoring command that display Linux processes.
It provides a dynamic real-time view of a running system i.e. actual process activity.

3) free: Show Linux server memory usage


The Linux free command shows a summary of RAM usage, including total, used, free, shared,
and available memory and swap space.

4) iostat: It is used for monitoring system input/output statistics for devices and partitions.

5) netstat: The netstat command displays network status and protocol statistics.

You might also like