Operating System - Module II

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

Operating System - Module II

MODULE-II (08 Hours)

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

By Prof Nitu Dash


Operating System Structure

1. Simple structure:

• Designed to get maximal functionality with scarce memory

• Not divided into modules

• Some internal structure exists but interfaces and functionality are not separated

• Applications extend operating system as they find convenient

• MS-DOS is an example of such system. It was not divided into modules carefully.

• Another example of limited structuring is the UNIX operating system.

2. Layered approach:

• Operating system is divided into layers

• Each layer uses services of lower layers

• The lowest or bottom layer (Layer 0) is hardware

• 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

By Prof Nitu Dash


• The layers are selected such that each uses functions (or operations) & services of only lower
layer.

• 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.

By Prof Nitu Dash


The main disadvantage of the layered approach is:

• 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)

• The modules communicate using message passing


• Mach example of microkernel. Mac OS X kernel (Darwin) partly based on Mach.

By Prof Nitu Dash


Benefits:
Easier to extend a microkernel
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode)
More secure

Detriments:
Performance overhead of user space to kernel space communication

4. Virtual Machines :

• Logical next step from layered system

• 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)

• IBM has been the main maker of virtualized architectures

pros and cons


• Perfect protection of system resources because of virtual machine isolation
• No direct sharing of resources because of this
• Theoretically a powerful means for operating systems research and development
• More efficient use of hardware
• Implementation is complex, especially when architecture is not fully virtualized and needs
special tricks to achieve near-100% emulation of hardware; fully virtualizable hardware is
a big bonus

By Prof Nitu Dash


Operating System – Services
An Operating System provides services to both the users and to the programs.

• It provides programs an environment to execute.


• It provides users the services to execute the programs in a convenient manner.

Following are a few common services provided by an operating system −

• 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 −

• Loads a program into memory.


• Executes the program.
• Handles program's execution.
• Provides a mechanism for process synchronization.
• Provides a mechanism for process communication.
• Provides a mechanism for deadlock handling.

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.

By Prof Nitu Dash


File system manipulation

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 −

• Program needs to read a file or write a file.


• The operating system gives the permission to the program for operation on file.
• Permission varies from read-only, read-write, denied and so on.
• 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.

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 −

• Two processes often require data to be transferred between them


• Both the processes can be on one computer or on different computers, but are connected
through a computer network.
• Communication may be implemented by two methods, either by Shared Memory or by
Message Passing.

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 −

• The OS constantly checks for possible errors.


• The OS takes an appropriate action to ensure correct and consistent computing.

By Prof Nitu Dash


Resource Management

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 −

• The OS manages all kinds of resources using schedulers.


• CPU scheduling algorithms are used for better utilization of CPU.

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 −

• The OS ensures that all access to system resources is controlled.


• The OS ensures that external I/O devices are protected from invalid access attempts.
• The OS provides authentication features for each user by means of passwords.

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.

By Prof Nitu Dash


1. User mode
2. Kernel mode

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.

TYPES OF SYSTEM CALLS

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.

1. create file, delete file


2. open, close
3. read, write, reposition
4. get file attributes, set file attributes

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.

1. request device, release device


2. read, write, reposition

By Prof Nitu Dash


3. get device attributes, set device attributes
4. logically attach or detach devices

D) Information Maintenance

We need to keep all the information up to date so these system calls help us to do that.

1. get time or date, set time or date


2. get system data, set system data
3. get process, file, or device attributes
4. set process, file, or device attributes

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.

1. create, delete communication connection


2. send, receive messages
3. transfer status information
4. attach or detach remote devices

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

Process = program + runtime activity

Difference between process and program


1) Both are same beast with different name or when this beast is sleeping (not executing) it is
called program and when it is executing becomes process.
2) Program is a static object whereas a process is a dynamic object.
3) A program resides in secondary storage whereas a process resides in main memory.
4) The span time of a program is unlimited but the span time of a process is limited.
5) A process is an 'active' entity whereas a program is a 'passive' entity.
6) A program is an algorithm expressed in programming language whereas a process is
expressed in assembly language or machine language.

By Prof Nitu Dash


Code or program How process is stored
in memory

Representation of a Process
A process comprises of

• The program code, also called text section


• Data section contains global variables / public or static variables
• Heap contains memory dynamically allocated during run time
• Current activity including program counter, processor registers
• Stack containing temporary data : Function parameters, return addresses, local variables

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.

New: The process is being created.

By Prof Nitu Dash


Ready: The process is waiting to be assigned to a processor.
Running: Instructions are being executed.
Waiting: The process is waiting for some event to occur.
Terminated: The process has finished execution.

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

Process Control Block (PCB)

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.

Pointer: A pointer to parent process.

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.

By Prof Nitu Dash

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy