Operating System - Module II
Operating System - Module II
Operating System - Module II
Operating System Structure & Processes: Introduction, System Components, Operating System
Structure, Operating System Services, System Calls, System Programs, Process, Process States,
Process Control.
System Components
Computer system can be divided into four components:
❖ Hardware – provides basic computing resources
CPU, memory, I/O devices
❖ Operating system - Controls and coordinates use of hardware among various
applications and users
DOS, Windows, Unix, Linux
❖ Application programs – define the ways in which the system resources are used
to solve the computing problems of the users
Word processors, compilers, web browsers, database systems, video
games
❖ Users
People, machines, other computers
1. Simple structure:
• Some internal structure exists but interfaces and functionality are not separated
• MS-DOS is an example of such system. It was not divided into modules carefully.
2. Layered approach:
• The highest or top most layer (layer N) is application program with user interface
• Modularity: each layer only uses operations and services from lower layers
• Example: OS/2
• This approach simplifies debugging & system verification, i.e. the first layer can be debugged
without concerning the rest of the system. Once the first layer is debugged, its correct
functioning is assumed while the 2nd layer is debugged & so on.
• If an error is found during the debugging of a particular layer, the error must be on that layer
because the layers below it are already debugged. Thus the design & implementation of the
system are simplified when the system is broken down into layers.
• Each layer is implemented using only operations provided by lower layers. A layer doesn‘t
need to know how these operations are implemented; it only needs to know what these
operations do.
• The layer approach was first used in the operating system. It was defined in six layers.
• The main difficulty with this approach involves the careful definition of the layers, because
a layer can use only those layers below it. For example, the device driver for the disk space
used by virtual memory algorithm must be at a level lower than that of the memory
management routines, because memory management requires the ability to use the disk
space.
• It is less efficient than a non layered system (Each layer adds overhead to the system call &
the net result is a system call that take longer time than on a non layered system).
3. Microkernel :
• As much modules as possible are moved out from kernel to user level (as processes)
Detriments:
Performance overhead of user space to kernel space communication
4. Virtual Machines :
• Any layers below are seen as hardware that is usable for current layer
• Virtual machine gives client machines an interface that is identical to actual hardware
• Creates an illusion of many processes that use their own processor and run its own
operating system there along with its own (virtual) memory
• This client operating system can be very simple (even single-user and single-tasking)
• Program execution
• I/O operations
• File System manipulation
• Communication
• Error Detection
• Resource Allocation
• Protection
Program execution
Operating systems handle many kinds of activities from user programs to system programs like
printer spooler, name servers, file server, etc. Each of these activities is encapsulated as a
process.
A process includes the complete execution context (code to execute, data to manipulate, registers,
OS resources in use). Following are the major activities of an operating system with respect to
program management −
I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software. Drivers hide
the peculiarities of specific hardware devices from the users.
An Operating System manages the communication between user and device drivers.
• I/O operation means read or write operation with any file or any specific I/O device.
• Operating system provides the access to the required I/O device when required.
A file represents a collection of related information. Computers can store files on the disk
(secondary storage), for long-term storage purpose. Examples of storage media include magnetic
tape, magnetic disk and optical disk drives like CD, DVD. Each of these media has its own
properties like speed, capacity, data transfer rate and data access methods.
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions. Following are the major activities of an operating
system with respect to file management −
Communication
In case of distributed systems which are a collection of processors that do not share memory,
peripheral devices, or a clock, the operating system manages communications between all the
processes. Multiple processes communicate with one another through communication lines in the
network.
The OS handles routing and connection strategies, and the problems of contention and security.
Following are the major activities of an operating system with respect to communication −
Error handling
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the
memory hardware. Following are the major activities of an operating system with respect to error
handling −
In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles
and files storage are to be allocated to each user or job. Following are the major activities of an
operating system with respect to resource management −
Protection
Considering a computer system having multiple users and concurrent execution of multiple
processes, the various processes must be protected from each other's activities.
Protection refers to a mechanism or a way to control the access of programs, processes, or users
to the resources defined by a computer system. Following are the major activities of an operating
system with respect to protection −
SYSTEM CALLS
1. System calls provide an interface between user programs and operating system.
2. It is a programmatic way in which a computer program requests a service from the kernel
of the operating system.
When a program is executing in user mode, it is not in privileged mode. So whenever it needs
any hardware resource like RAM or printer, it needs to make a call to the kernel and this is
known as SYSTEM CALL.
When a program is executing in kernel mode, it is executing in privileged mode. So it can access
any hardware resource. So when a program needs to access any resource while it is running in
user mode it makes a System Call to the kernel then a context switch occurs which takes the
program from user mode to kernel mode. After the resource is accessed one more context switch
occurs which takes back the program’s execution to user mode.
Now you may wonder why aren’t all programs occurring in kernel mode so we can skip the
context switching. This is because if a program crashes in kernel mode entire system will be
halted. So most programs are executed in user mode because if it crashes there, entire system
won’t be affected.
A) Process Control
Processes need to be controlled as in a running process must be able to halt its execution either
normally or abnormally.Also one process may need to run some other process to complete its
own execution. So all these system calls come under this category.
1. end, abort
2. load, execute
3. create process, terminate process
4. get process attributes, set process attributes
5. wait for time, wait event, signal event
6. allocate and free memory
B) File Management
System calls which deal with operations related to files fall under this type.
C) Device Management
A process may need several resources for its execution. So system calls used for asking
permission from the kernel to use those resources are included in this type.
D) Information Maintenance
We need to keep all the information up to date so these system calls help us to do that.
E) Communication
Processes need to communicate with each other for many reasons like if they need certain
resource which is held by any other process. These system calls assist in doing so.
Process Management
Process
• A program in execution.
• An instance of a program
• process execution must progress in sequential fashion.
• A process is a unit of work in a computer system.
• The terms process and job are used interchangeably
Representation of a Process
A process comprises of
Operations on a Process
Process state: As a process executes, it changes state. The state of a process is defined by the
correct activity of that process. Each process may be in one of the following states.
Many processes may be in ready and waiting state at the same time. But only one process can be
running on any processor at any instant.
Attributes of a Process
A Process Control Block is a data structure maintained by the Operating System for every process.
The PCB is identified by an integer process ID (PID). A PCB keeps all the information needed to
keep track of a process as listed below in the table –
Process State: The current state of the process i.e., whether it is ready, running, waiting, or
whatever.
By Prof Nitu Dash
Process privileges: This is required to allow/disallow access to system resources.
Process ID: Unique identification for each of the process in the operating system.
Program Counter: It is a pointer to the address of the next instruction to be executed for this
process.
CPU registers: Various CPU registers where process need to be stored for execution for running
state.
CPU Scheduling Information: Process priority and other scheduling information which is
required to schedule the process.
Memory management information: This includes the information of page table, memory limits,
Segment table depending on memory used by the operating system.
Accounting information: This includes the amount of CPU used for process execution, time
limits, execution ID etc.
IO status information: This includes a list of I/O devices allocated to the process.