OSY Ch-2
OSY Ch-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))
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.
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.
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.
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
Layered Approach
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”.
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.
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]
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.
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.
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.
D) Performance Monitor:
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.