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

1.1 What Operating Systems Do?

The operating system acts as an intermediary between the user and hardware. It controls hardware resources and coordinates their use among application programs and users. The OS provides four main functions: executing programs, making problem solving easier, making the computer convenient to use, and providing a basis for application programs. It views the computer from both the user perspective, focusing on usability, and the system perspective, focusing on resource allocation and error control. The OS controls I/O device operations and program execution to prevent errors. [END SUMMARY]

Uploaded by

Shivali
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views

1.1 What Operating Systems Do?

The operating system acts as an intermediary between the user and hardware. It controls hardware resources and coordinates their use among application programs and users. The OS provides four main functions: executing programs, making problem solving easier, making the computer convenient to use, and providing a basis for application programs. It views the computer from both the user perspective, focusing on usability, and the system perspective, focusing on resource allocation and error control. The OS controls I/O device operations and program execution to prevent errors. [END SUMMARY]

Uploaded by

Shivali
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 36

Module 1 Operating System

Introduction to OS
Operating system –

• Program that acts as intermediary between user and hardware.


• provides basis for application programs
• One program running at all times on the computer
• Is also called as kernel

Goals of OS –
Execute programs, makes problem solving easier, make the computer convenient to use.

1.1 What Operating systems do?


Four components of computer are – Hardware, OS, Application programs and users.

The hardware—the central processing unit (CPU), the memory, and the input/output (I/O) devices—
provides the basic computing resources for the system. The application programs—such as word
processors, spreadsheets, compilers, and Web browsers—define the ways in which these resources
are used to solve users’ computing problems. The operating system controls the hardware and
coordinates its use among the various application programs for the various users. Let us explore OS
from two viewpoints - User and System view.

1.1.1 User View


The user’s view of the computer varies according to the interface being used.
a. Most users use PC consisting of monitor, keyboard and system unit. Here OS is designed for ease
of use, attention is paid to speed, and no attention is paid for resource utilization. Mainly
optimized for single user experience.
b. Some users use a terminal connected to Mainframe ( or a minicomputer). Here OS is designed
for maximize resource utilization and assured that everyone gets their own share.

1
Module 1 Operating System
Introduction to OS
c. Some users use a workstation connected to network. Here OS is designed to compromise
between individual usability and resource utilization.
d. Few users use handheld computers where OS is designed for individual usability.
performance per unit of battery life is very important factor.
e. Most of embedded devices have very less user intervention and they have fixed job and time
constraints.

1.1.2 System view


a. An OS as a resource allocation
Computer system has resources like – CPU, memory, I/O devices, file etc, all these resources
are required for solving a problem. These resources are managed by OS, and are also allocated
by OS when user programs and users require THEM
b. OS as control program
OS controls the operations of I/O devices and execution of user programs to prevent
errors.

1.2 Computer System organization


This contains – Computer System operation, storage structure and I/O structure.

1.2.1 Computer system operation –


❖ A computer consists of one or more CPUs, and number of device controllers. Controllers
are in charge of specific type of device.
❖ CPU and controller can execute concurrently
❖ Memory controller is used to synchronize access to the shared memory

Following are the events that occur for a computer to start running –

➢ When computer is switched on, Bootstrap is initial program that gets started.
Bootstrap program initializes all aspects of the system from CPU registers to device controllers
to memory contents.
➢ Then loads OS into memory
➢ OS executes the first function init() and waits for some event to occur
➢ Occurrence of event is signaled by an interrupt from either hardware or the software (fig 1.2)
➢ Hardware interrupt is triggered by sending a signal to the CPU
➢ Software interrupt is triggered by executing a system call
➢ when CPU is interrupted, CPU stops current computation and transfers control to
interrupt service routine (ISR)
➢ Finally ISR executed, on completion CPU resumes the interrupted computation

2
Module 1 Operating System
Introduction to OS

Common functions of interrupt are -



Interrupt transfers control to the ISR generally, through the interrupt vector, which contains the
addresses of all the service routines

Interrupt architecture must save the address of the interrupted instruction.

Incoming interrupts are disabled while another interrupt is being processed to prevent a lost
interrupt

A trap is a software generated interrupt caused either by an error or user request

A modern OS is interrupt-driven

1.2.2 Storage structure

✓ Programs must be in main memory for CPU execution. Interaction with the memory is
done through series of load and store instruction. Load instruction moves a word from main
memory to an internal register with in CPU. Store instruction moves the contents of the
register to main memory.

✓ Programs and data should reside in main memory permanently. This is not possible
since main memory is small and it is volatile. Therefore most computers provide secondary
storage as an extension to main memory.
✓ These secondary storage devices store huge amount of data and it is nonvolatile
✓ Wide range of storage system can be organized in a hierarchy as shown below-
✓ The higher levels are expensive, but they are fast. As we move down the hierarchy, the
cost per bit generally decreases, whereas the access time generally increases.

3
Module 1 Operating System
Introduction to OS

✓ The top four levels are constructed using semiconductor memory. Storage system
above solid state disk are volatile, below are non volatile.

✓ Another form of solid-state disk is flash memory, which is popular in cameras and personal
digital assistants (PDAs), in robots, and increasingly for storage on general-purpose computers.

1.2.3 I/O Structure



A computer consists of CPUs and multiple device controllers as shown in fig 1.5.

A controller is in charge of specific type of device. Controller maintains some local buffer storage and set
of special purpose registers

OS has device driver for each controller. This device driver understands the device controller and
provides the rest of the operating system with a uniform interface to the device.

To start an I/O operation Interrupt driven, Driver loads the appropriate registers within the
controller; controller examines the contents of the registers to determine what actions to take.
Controller transfers data from the device to its local storage; controller informs the driver via
an interrupt that it has finished its operation. Driver then returns control to OS.

Above is fine for small amounts of data transfer, but if huge amount of data transfer then direct
memory access (DMA) is used. In DMA, the controller transfers block of data from buffer
storage directly to main memory without CPU intervention.

4
Module 1 Operating System
Introduction to OS
1.3 Computer System Architecture

Based on the number of general purpose processors used, architecture is classified into – single
processor systems, multiprocessor systems and clustered systems.

1.3.1 Single processor systems


Here there is one main CPU capable of executing a general-purpose instruction set, including
instructions from user processes. Almost all single processor systems have other special-purpose
processors in the form of device-specific processors, such as disk, keyboard, and graphics controllers.
These special-purpose processors run a limited instruction set and do not run a user process. For
example, a disk-controller microprocessor receives a sequence of requests from the main CPU and
implements its own disk queue and scheduling algorithm.

1.3.2 Multiprocessor systems


These are the systems that have two or more processors in close communication, sharing the computer
bus and sometimes the clock, memory, and peripheral devices. Advantages –

✓ Increased throughput – more work done in less time


✓ Economy of scale – cost less than multiple single processor systems since they share
peripherals, mass storage and power supplies.
✓ Increased Reliability – Failure of one system will not halt the system.

The ability to continue providing service proportional to the level of surviving hardware is called graceful
degradation. Some systems go beyond graceful degradation and are called fault tolerant, because they
can suffer a failure of any single component and still continue operation.
Multiple processor systems are of two types – Asymmetric multiprocessing (AMP) and symmetric
multiprocessing (SMP).
Asymmetric multiprocessing – uses master slave relationship. Each processor is assigned a specific task.
Master system schedules and allocates work to slave processors and thus controls the system
Symmetric multiprocessing – No master slave relationship. Each processor runs an identical copy of OS,
and all are peers (Fig 1.6). Processors run simultaneously. Resources are shared dynamically.
Disadvantage – one CPU may sit idle, few may be overloaded resulting inefficiency.

5
Module 1 Operating System
Introduction to OS
1.3.3 Clustered systems

✓ Multiprocessor systems where two or more CPUs are coupled together, they share
common storage and closely linked via LAN. These provide high availability service.

✓ Cluster software runs on cluster nodes. Each nodes monitor one or more nodes. If the
monitored node fails then monitoring node will take ownership
Two types of clustered systems are – Asymmetric clustering and Symmetric clustering.
In Asymmetric clustering – one node is hot standby node while others are running the applications. Hot
standby mode monitors the active server, if server fails; the hot standby mode becomes the active
server.
Symmetric clustering – Two or more nodes are running applications and monitoring each other. This
structure is more efficient, as it uses all of the available hardware.

1.4 Operating system structure


Here come Batch systems, multiprogrammed systems and Time sharing systems

1.4.1 Batch systems –


• Early computers were physically enormous machines run from a console. Input devices were
card reader, tape drives. output devices were line printers, tape drives and card punches
• Users prepared job containing program, data and control information, submitted this job to
computer operator. Job was in the form of punch cards and output appeared later.
• To speed up processing, operator batched jobs with similar needs and ran them through the
computer

1.4.2 Multiprogrammed systems


❖ This provide an environment in which various system resources are utilized effectively
but don’t provide for user interaction with the computer system.

❖ OS keeps jobs in memory simultaneously as shown in fig 1.9. OS picks one of the jobs
and CPU is assigned to it, when this job needs any I/O interaction then this job is put to hold,
next job will be selected for execution, thus CPU utilization is increased here.

❖ If multiple jobs are ready to be brought to memory and no enough memory then job
scheduler will decide which jobs should be in memory, similarly if several jobs are ready to run
then CPU scheduler which decide which to be executed.

6
Module 1 Operating System
Introduction to OS

1.4.3 Time sharing (multitasking) systems



This is a logical extension of multiprogramming

Here CPU executes multiple jobs by switching among them, but the switches occur so frequently
that the users can interact with each program while it is running.

Time sharing requires an interactive computer system, which provides direct communication
between the user and the system. Here response time should be short and this is done by
Swapping technique, whereby processes are swapped in and out of main memory to the disk.

Time sharing systems must provide file system, disk management, CPU scheduling to support
concurrent execution and job synchronization for orderly execution.

1.5 Operating system operations


Dual mode operation and Timer are the two operations.
Modern OS is interrupt driven; events are signaled by the occurrence of interrupt or trap. A trap is
software generated interrupt caused either by error or request for an OS Service to be performed.

1.5.1 Dual mode operation

➢ To ensure the proper execution of the operating system, there should be way to
distinguish between the execution of operating system code and user defined code. This is done
by adding a bit called 'mode bit' to the hardware of the computer to indicate the current mode:
kernel (0) or user (1).

➢ At system boot time, the hardware starts in kernel mode. OS is then loaded and starts
user applications in user mode. Whenever a trap or interrupt occurs, the hardware switches
from user mode to kernel mode, at that time mode bit value is set to kernel mode. System
always switches to user mode before passing control to user program. fig (1.10)

➢ Dual mode protects OS from errant users, and errant users from one another. This
protection is achieved by executing privileged instruction only in kernel mode. If such
instructions are attempted in user mode, then hardware treats as illegal and traps to OS.
System calls are invoked by user program to ask OS to perform privileged instruction execution.

7
Module 1 Operating System
Introduction to OS

1.5.2 Timer

➢ User program is not allowed to get stuck in infinite loop or to fail to call system services and
never return control to OS. To accomplish this, Timer is set to interrupt the computer after a
specified period. The period may be fixed (for ex- 1/60 second) or variable (for ex- 1 ms to 1sec).

➢ A variable timer is generally implemented by a fixed-rate clock and a counter. The


operating system sets the counter. Every time the clock ticks, the counter is decremented.
When the counter reaches 0, an interrupt occurs. Instructions that modify the timer are
privileged instruction.

➢ Before turning over control to the user, the operating system ensures that the timer is
set to interrupt. If the timer interrupts, control transfers automatically to the operating system,
which may treat the interrupt as a fatal error or may give the program more time.

1.6 Process Management


Program in execution is a process; process requires resources like – CPU, memory and file to perform a
task. These resources are allocated to process when the process is created or when it is running.
When the process terminates, all the OS reclaims all the reusable resources. There are two types of
process – Single threaded process and Multi-threaded process. In Single threaded process there is only
one program counter which specifies the location of the next instruction to be executed where as in
Multi-threaded process, each thread will have program counter.
The operating system is responsible for the following activities in connection with process management:
• Scheduling processes and threads on the CPUs
• Creating and deleting both user and system processes
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication

1.7 Memory Management



Main memory is the large array of words or bytes, ranging in size from hundreds of thousands to billions.
Each word or byte will have their own address.

The CPU reads the instruction from main memory during instruction fetch cycle & reads and writes data
during the data-fetch cycle

The main memory is the only storage device which a CPU is able to address & access directly.

For a program to be executed, it must be loaded into memory & mapped to absolute addresses. When
the program terminates, all available memory will be returned back.

8
Module 1 Operating System
Introduction to OS

To improve the utilization of CPU & the response time several programs will be kept in memory.

Several memory management schemes are available & selection depends on the Hardware design of the
system.

The OS is responsible for the following activities
o Keeping track of which parts of the memory are used & by whom.
o Deciding which process and data to move into and out of memory.
o Allocating & de-allocating memory space as needed.

1.8 Storage Management


Grouped into – File System management, Mass storage management, Caching and I/O systems.

1.8.1 File-system management



Computers can store information on several different types of physical media like Magnetic disk,
optical disk, and magnetic tape. Each of these medium is controlled by device such as tape drive
or disk drive, and they will have their own unique characteristics like speed, capacity, data
transfer etc.

OS implements the abstract concept of a file by managing mass storage media like tapes, disks etc.,

The OS is responsible for the following activities, o
Creating & deleting files.
o Creating & deleting directories.
o Supporting primitives for manipulating files & directories.
o Mapping files onto secondary storage.
o Backing up files on stable (non volatile) storage media.

1.8.2 Mass storage management



Computer system must provide secondary storage to back up main memory because, o It is
too small to accommodate all data and programs.
o Data held in this memory is lost when power goes off.

Most programs including compilers, assemblers, word processors, editors etc are stored on
the disk until loaded into the memory and then use disk as both source and destination of
processing. Hence proper management of disk storage is very important.

The OS is responsible for the following activities,
o Free space management.
o Storage allocation.
o Disk scheduling.
➢ Slower, low cost and high capacity backup storage devices are called tertiary devices which
are used for back-up of the regular disk data, seldom used data, long term archival storage
etc. Eg. Magnetic tapes and their drives, CD and DVD drives and platters like tape and optical
platters
1.8.3 Caching
➢Cache is a fast memory used for storing information on a temporary basis
➢ Whenever CPU needs information, first it looks in cache memory, if it is not available
then the information is looked in the source and then it is copied to cache memory if it is
frequently used.
➢ Internal programmable registers like index registers can be used as high-speed cache for the
main memory.
9
Module 1 Operating System
Introduction to OS

Caches have limited size and thus Cache management is an important design problem.

In a hierarchical storage structure, the same data may appear in different levels of storage
system. For ex, Suppose that an integer A is to be incremented by 1 is located in file B which
resides on disk, the migration of integer A from Disk to Register is shown in below fig


Once the increment to A takes place in the internal registers, the value of A differs in various
storage systems. The value of A becomes same only after the new value of A is written from
the internal register back to the disk.

In multitasking environments, extreme care must be taken to use most recent value, not matter
where it is stored in the storage hierarchy.

The situation becomes more complicated in multiprocessor environment, where each CPU
is associated with local cache. A care must be taken to make sure that an update to the
value of A in one cache is immediately reflected in all other caches. This situation is called as
cache coherency.

The situation becomes even more complex in a distributed environment. Several copies of
the same file can be kept on different computers. Since the various replicas may be accessed
and updated concurrently, some distributed systems ensure that, when a replica is updated
in one place all other replicas are also updated as soon as possible.

1.8.4 I/O Systems


✓OS hides peculiarities of hardware devices from the user.
✓ I/O subsystem consists of several components like,
o The memory management component that includes buffering, caching and spooling.
o A general device driver interface.
o Drivers for specific hardware devices.
Only the device driver knows the peculiarities of each of the devices

1.9 Protection and Security



Protection is a mechanism for controlling the access of processes or users to the resources
defined by a computer system. This mechanism must provide means to specify the controls
to be imposed and to enforce the controls.

Protection can improve reliability by detecting latent errors at the interfaces between component
subsystems.

Security means defence of the system against external and internal attacks. Attacks include viruses,
worms, DOS & Identity theft.

The mechanism of protection and security must be able to distinguish among all its users.
a. User identities [User IDs] include name and associated number one per user,
b. Group identifier [group ID] allows set of users to be defined and controls managed
within.

10
Module 1 Operating System
Introduction to OS
1.10 Distributed Systems

A distributed system is a collection of physically separate heterogeneous computer systems
that are networked to provide the users with access to various resources that the system
maintains.

A distributed system is one in which Hardware or Software components located at the networked
computers communicate & coordinate their actions only by passing messages.

Distributed systems depend on networking for their functionality. Network may vary by the protocols
used, distance between nodes (LAN, WAN, MAN, etc) & transport media.

A network operating system is an OS that provides features such as file sharing across the network
and allows different processes on different computers to exchange messages.

The advantages of Distributed Systems are,
o Resource sharing
o Higher reliability
o Better price performance ratio
o Shorter response time
o Higher throughput
o Incremental growth

1.11 Special Purpose Systems


The special purpose computers are those, whose functions are more limited and whose objectives
are to deal with limited computation domains. Ex. Real time Embedded Systems, Multimedia
Systems and Handheld Systems.

Real time embedded systems –



Embedded computers are found everywhere from car engines, robots, alarm systems, medical
imaging systems, industrial control systems, microwave ovens, weapon systems etc.

Embedded systems runs on real time OS & have very specific task and run an OS with very limited
features. Usually they have limited or no user interface.

A real time system should have well defined, fixed time constraints. Hence they are often
used as controlled device in a dedicated application. Real time OS uses priority scheduling
algorithm to meet the response requirement of a real time application.

Real time systems are of two types
o Hard Real Time Systems
o Soft Real Time Systems

A hard real time system guarantees that the critical tasks to be completed on time. Whereas soft real
time system is a less restrictive.

Multimedia systems

A recent trend in technology is the incorporation of multimedia data.

Multimedia data consists of audio and video files along with conventional files (text files, word
document, etc).

The difference from conventional data is that the multimedia data must be delivered or streamed
according to some time restrictions.

Multimedia applications includes video conferencing, news, stories download over the internet,
live webcasts of speeches and so on

11
Module 1 Operating System
Introduction to OS
Handheld systems

Handheld systems include Personal Digital Assistants (PDAs), Cellular telephones, palm and pocket
PCs and so on, which uses special purpose embedded OS.

Main challenges faced by developers of handheld systems are limited size of devices.
Because of small size they have small amount of memory, slow processors and small display
screens.

1.12 Computing Environments


Traditional computing, Client-server computing, Peer-to-peer computing, web based computing.

1.12.1 Traditional computing-


• Used in office environment:

PCs connected to a network, with servers providing file and print services.
• Used in home networks:

At home, most users had a single computer with a slow modem.

Some homes have firewalls to protect their networks from security breaches.
• Web technologies are stretching the boundaries of traditional computing.

Companies establish portals, which provide web accessibility to their internal servers.

Network computers are terminals that understand web computing.

Handheld PDAs can connect to wireless networks to use company's web portal.
• Systems were either batch or interactive.
1. Batch system processed jobs in bulk, with predetermined input.
2. Interactive systems waited for input from users.

1.12.2 Client-server computing –


➢Structure of specialized client server system is shown below -

➢ Servers can be broadly categorized as - Compute servers and File servers

➢ Compute-server system provides an interface to which a client can send a


request to perform an action (for example, read data). In response, the server
executes the action and sends back results to the client.
➢ File-server system provides a file-system interface where clients can create, read, and delete
files. For example: web server that delivers files to clients running web browsers
1.12.3 Peer-to-Peer (P2P) computing –

Here nodes are considered peers, and may act as either a client or a server (fig 1.11).
bottleneck of client server system is removed. Thus Services can be provided by several nodes
distributed throughout the network.

A node must first join the network of peers. Determining what services are available is done in one of
two general ways:
1. When a node joins a network, it registers its service with a centralized lookup service on the
network. Any node desiring a specific service first contacts this centralized lookup

12
Module 1 Operating System
Introduction to OS
service to determine which node provides the service.
2. A peer broadcasts a request for the service to all other nodes in the network. The
node (or nodes) providing that service responds to the peer.

Fig 1.11 peer-to-peer system

1.12.4 Web based computing



Web computing has increased the emphasis on networking.

Devices that were not previously networked have been wired or wireless nowadays.

The network connectivity is faster through improved network technology and optimized network
implementation code.

Web based computing has given rise to a new category of devices called load balancers
which distribute network connections among a pool of similar servers

Chapter 2: Operating System Structures

2.1 Operating system services


An OS provides an environment for the execution of the programs. It provides services to programs and
users.
The common services provided by the OS are –
1. User Interface
➢ Almost all OS have a user-interface (UI). Different interfaces are:
i) CLI (Command line Interface)
This uses text commands and method for entering the text commands.
ii) Batch interface
Commands & directives to control those commands are entered into
files, and those files are executed.
iii) GUI (Graphical User Interface)
➢ The interface is a window-system with a pointing-device to
→ direct I/O
→ choose from menus and
→ make selections.
2. Program execution
System must be able to load a program into memory and run the
program 3. I/O operations
The OS must provide a means to do I/O operations because users cannot control
I/O devices directly.
4. File system manipulation
Programs need to – read & write files, create & delete files, search for a given file and allow or
deny access to files
5. Communications
In few situations – one process need to communicate to another process, this is achieved
through interprocess communication via shared memory concept and message passing.

13
Module 1 Operating System
Introduction to OS
6. Error detection
Errors may occur in CPU, memory hardware, I/O devices, or in user program. For each type of
error, OS take appropriate action to ensure correct and consistent computing.

OS also performs some common functions for efficient operation of the system. They are –
1. Resource allocation
OS manages different types of resources, depending on the process requirement resources will
be allocated and deallocated by OS.
2. Accounting
OS keeps track of which user uses how many resources and what kind of resources. This
information will be used for billing purpose or for gathering usage statistics.
3. Protection & Security
Protection ensures that all the access to the system is controlled. Security starts with each user
having authenticated to the system, usually by means of a password. External I/O devices must
also be protected from invalid access.

2.2 User operating system interface


There are two fundamental approaches for users to interface with OS,
a. Command Interpreter
b. Graphical User Interface

Command interpreter (CI)



Some OS has command interpreter in the kernel, where as in UNIX, CI is treated as special
program that runs when user first logs on or when job is initiated. Some system will have
multiple command interpreters, user can choose from them.

The main function of the command interpreter is to get and execute the next user-specified command.
Many of the commands are like – create file, manipulate file, delete file etc.

Advantages of CIs are,
• Command interpreter program is small.
• Command interpreter does not have to be changed when new commands are added.
• New commands can be easily added to the system.

Two ways to implement -
1. Command interpreter itself contains code to execute command.
2. Commands are implemented through system programs. This is used by UNIX.

Graphical user interface (GUI)



GUI provides user-friendly graphical interface, users employ mouse based window and menu system.

The mouse is used to move a pointer to the position of an icon that represents file, program or folder.
By clicking on the icon, the program is invoked.

2.3 System calls


These provide an interface to the OS services. System calls are usually written in C, C++ and certain
low level tasks will be written in assembly language.
Developer will be provided with application programming interface (API).
The API
→ defines a set of functions
→ includes the parameters passed to functions and the return values.
The Programmers design programs according to an API. The functions that make up an API invoke
the actual system-calls on behalf of the programmer.

14
Module 1 Operating System
Introduction to OS
A simple program to copy file contents from source file to destination file involves so many system calls.
Same is explained in fig 2.1.

Fig 2.1 Explain how system calls are used


Benefits of API -
1. Program portability.
2. Actual system-calls are more detailed to work with than the API available to the
programmer.

The relationship between an API, the system-call interface, and the operating system is shown in Fig 2.2,
which illustrates how the operating system handles a user application invoking the open() system call

Fig 2.2 open () system call

Three general methods are used to pass parameters to OS –


• registers,
• stored In table, in block, in memory and address of the block is passed as a parameter in
a register, using a table in memory
• Using a stack where parameters are pushed on to a stack and popped off the stack.

15
Module 1 Operating System
Introduction to OS

Fig 2.3 Passing of parameters as a table

2.4 Types of system calls


1. Process control
2. File management
3. Device management
4. Information maintenance
5. Communications

2.4.1 Process control


• System calls used for process control are :
➢ end, abort - A running program needs to be able to halt its execution either normally (end) or
abnormally (abort). If program runs into a problem, error message may be generated and dumped into a
file. This file can be examined by a debugger to determine the cause of the problem.

➢ load, execute - A process executing one program can load and execute another
program. When the loaded program terminates, in case control returns to the existing
program then memory image of the existing program should be saved. If both programs
continue concurrently, then new process should be multi-programmed.

➢ create process, terminate process – Once process is created, it should be controlled.


Process should be terminated if it is in correct or no longer needed.

➢ get process attributes, set process attributes -


During process execution, sometimes it is required to determine and reset the attributes of a
process such as job’s priority or maximum execution time.

➢ wait for time


Need to wait for processes to finish their execution.

➢ wait event, signal event


Process should be signaled when event occurs

➢ allocate and free memory


Process resources should be allocated as and when required. It will be freed during process
termination.

16
Module 1 Operating System
Introduction to OS
2.4.2 File Management
System calls used:
➢ create file, delete file – APIs are available for creating and deleting file
➢ open, close – file can be opened and can be used for storing information
➢ read, write, reposition – file once opened can be used for reading or writing purpose.
➢ get file attributes, set file attributes
File attributes include file name, file type, protection codes and accounting information.
System calls exist to determine the values of file-attributes and reset the file-attributes if
necessary.

2.4.3 Device Management


A program needs additional resources like memory, tape drives or files. If resources are available
then they can be granted and the control will be returned to the user program. If resources are
unavailable then program have to wait until sufficient resources are available. There are system
calls for managing devices. They are -
➢ request device, release device;
➢ read, write, reposition;
➢ get device attributes, set device attributes;
➢ logically attach or detach devices.
Files can be thought of as virtual devices. Thus, many of the system calls used for files are also used
for devices.
In multi-user environment,
1. First request is made to the device, to ensure exclusive use of it.
2. After the device task is completed, device will be released.
Due to lot of similarity between I/O devices and files, OS (like UNIX) merges the two into a combined
file-device structure. UNIX merges I/O devices and files into a combined file-device structure.

2.4.4 Information maintenance


Many system calls exist simply for the purpose of transferring information between the user
program and the OS. For ex, Most systems have a system call to return current time and
current date. Other system calls may return information about the system, such as number
of current users, version number of the OS, amount of free memory or disk space
The OS keeps information about all its processes, and there are system calls to access this information.

2.4.5 Communications
Two models of communication - Message-passing model and Shared Memory Model.
There are system calls for create, delete communication connection, send and receive messages,
transfer status information and attach or detach remote devices.

Message Passing Model


Information is exchanged through an IPC provided by OS.
Steps for communication:
• Firstly, a connection must be opened using open connection system-call. For this hostname and
process identifiers are passed
• The recipient-process must give its permission for communication to take place with an
accept connection system-call.
• Then, client & server exchange messages by read message and write message system
calls.
• Finally, the close connection system-call terminates the communication.

17
Module 1 Operating System
Introduction to OS
• Advantages:
1. Useful when smaller numbers of data need to be exchanged.
2. It is also easier to implement than is shared memory.

Shared Memory Model


• Processes use map memory system-calls to gain access to regions of memory owned by
other processes.
• Several processes exchange information by reading and writing data in the shared
memory. The shared memories are determined by the processes and are not under the
control of OS.
• The processes are also responsible for ensuring that they are not writing to the same
location simultaneously.

Advantage - Shared memory allows maximum speed and convenience of communication,


Disadvantage - Problems exist in the areas of protection and synchronization.

2.5 System Programs


They provide a convenient environment for program development and execution. They are
sometimes also known as system utilities. Different categories of system programs are –

File Management - These programs create, delete, copy and rename, print, dump, and allow
manipulating files and directories.

Status information – These programs provide information regarding the system date, time,
amount of available memory, number of users. This information is printed to the terminal.
Few programs even provide logging and debugging information.

File modification – Few text editors is available to create and modify the content of files stored on disk.

Programming-language support – Compilers, assemblers, debuggers and interpreters for
common programming languages are provided to the user

Program loading and execution – For loading the programs into memory, system provides
absolute loaders, relocatable loaders, linkage editors and overlay loaders.

Communications – These programs are used for creating virtual connections between processes,
users and computer systems. Example programs are – web browsers, word processors,
spreadsheets and games.

2.6 OS Design and implementation


Approaches for design and implementation of OS –

2.6.1 Design Goals –


The first problem in designing a system is to define goals and define specifications.
The design of the system will be affected by choice of hardware and type of system such as
1. batch or time shared
2. single user or multiuser
Two basic groups of requirements:
1. User goals and 2. System goals

User Goals
• The system should be
→ convenient to use
→ easy to learn and to use

18
Module 1 Operating System
Introduction to OS
→ reliable, safe, and fast.

System Goals
• The system should be
→ Easy to design
→ implement, and maintain
→ Flexible, reliable, error free, and efficient.

2.6.2 Mechanisms and Policies



Mechanisms determine how to do something, where as policies determine what will be done. Ex –
timer construct is a mechanism for ensuring CPU protection, but deciding how long the timer is to be set
for a particular user is a policy decision

Separating policy and mechanism is important for flexibility

Policies change over time, whereas mechanisms should be general

Policy decisions are important for all resource allocation.

2.6.3 Implementation
OS is designed next step is implementing it, earlier it was implemented in assembly language, but now
a days higher level languages such as C or C++ is used, only some small sections of assembly code is
written for device drivers interaction.
Advantages of higher-level languages:
1. Faster development and
2. OS is easier to port.
Disadvantages – reduced speed and increased storage requirements

After the system is written and is working correctly, bottleneck routines should be identified and
replaced with assembly language equivalents.

2.7 OS Structure
➢Simple structure
➢ Layered approach
➢ Microkernels
➢ Modules
2.7.1 Simple Structure

No well defined structure, OS was started as small, simple and limited systems. Ex- MS-DOS &
UNIX.

MS-DOS was not divided into modules; entire functionality was provided in the least
space. The interfaces and levels of functionality was not separated, hence application
programs were able to access the basic I/O routines which is vulnerable to errors

UNIX was initially limited by hardware functionality. Two parts of UNIX – kernel and
system programs. The kernel is further separated into a series of interfaces and device
drivers. The kernel provides following functions through system calls – file system, CPU
Scheduling and memory management. Here the disadvantage is difficult to enhance as
changes in one section badly affects other areas.

19
Module 1 Operating System
Introduction to OS

application program

resident system program

MS-DOS device drivers

ROM BIOS device drivers

Fig 2.7 MS-DOS layer structure

(the users)

Shells and commands


Compilers and interpreters
System libraries

System call interface to the kernel

Signals terminal file system CPU scheduling


handling swapping block I/O Page replacement Kernel
Character I/O system system demand paging
Terminal drivers disk and tape drivers virtual memory

Kernel interface to the hardware

terminal controllers device controllers memory controllers


terminals disks and tapes physical memory

Fig 2.8 UNIX system structure

2.7.2 Layered Approach



The OS is divided into a number of layers. Each layer is built on the top of another layer. The bottom
layer is the hardware. The highest is the user interface. [fig 2.7.2]

A layer is an implementation of an abstract-object. The object is made up of data and operations that can
manipulate the data.

Fig 2.7.2 A Layered OS

20
Module 1 Operating System
Introduction to OS

➢ The layer consists of a set of routines that can be invoked by higher layers. Here higher
layer does not need to know how lower layer operations are implemented; it should only know
the operations of lower layer.
Advantage: Simplicity of construction and debugging.
Disadvantages: Less efficient than other types. Ex – When a user program executes an I/O operation,
it executes a system call that is trapped to the I/O layer, which calls memory management layer, which
in turn CPU layer, so at each layer the parameters may be modified, data may need to be passed, so it is
a overhead.

2.7.3 Microkernels

As the name conveys it’s a light weight kernel. Here all nonessential components from the kernel is removed
and implemented as system and user level programs.

The main function of the microkernel is to provide a communication facility between client program
and various services running in user-space.

Communication is provided by message passing. Ex- if a client program wishes to access a file, it must
interact with the file server.
Ex- Microkernel OS are QNX, Tru64 UNIX
• Advantages:
1. Ease of extending the OS. (New services are added to user space w/o modification of kernel).
2. Easier to port from one hardware design to another.
3. Provides more security & reliability.(If a service fails, rest of the OS remains untouched.).
4. Provides minimal process and memory management.
Disadvantage:
. Performance decreases due to increased system function overhead

Fig 2.7.3 Architecture of a typical microkernel

2.7.4 Modules
Here object oriented programming techniques are used to create a modular kernel. Kernel has set of
core components and dynamically links to additional services either during boot time or during run
time.
Seven types of modules in the kernel – [ ex - solaris shown in fig 2.7.4]
1. Scheduling classes
2. File systems
3. Loadable system calls
4. Executable formats
5. STREAMS modules
6. Miscellaneous

21
Module 1 Operating System
Introduction to OS
7. Device and bus drivers

Fig 2.7.4 Solaris loadable modules

Advantages – Kernel provides only core services & few features are implemented dynamically. Flexible
than layered system because any module can all any other module. Efficient like microkernel as the
primary module has only core functions and knowledge how to load and communicate with other
modules is enough to get the services.
Ex – The Apple Mac OS X OS uses hybrid structure. ( fig 2.11) Structure is shown below -
The top layers include
→ Application environments and
→ set of services providing a graphical interface to applications.
Kernel environment consists primarily of
→ Mach microkernel and
→ BSD kernel.

→ memory management;
→ support for RPCs & IPC and
→ thread scheduling.

→ BSD command line interface


→ support for networking and file systems and
→ implementation of POSIX APIs

→ device drivers and


→ dynamic loadable modules

application environments and


common services

BSD

Mach

Fig 2.11 The Mac OS X structure

22
Module 1 Operating System
Introduction to OS
2.8 Virtual Machines
Idea behind a virtual machine is to abstract the hardware of a single computer into several different
execution environments.
OS creates illusion that process has own processor & own memory. The virtual machine provides an
interface that is identical to underlying hardware as shown in fig 2.8 (b)

Fig 2.8 System models (a) Nonvirtual machine (b) Virtual machine

Problem: Virtual-machine software itself will need substantial disk space to provide virtual
memory. Ex – Say there are 7 virtual machines and 3 disk drives, Here while allocating disk
drive to each virtual machine care need to be taken. Solution will be to provide virtual
disks that are identical in all respects except size.

Advantages:
1. Complete protection of the various system resources.
2. It is a perfect vehicle for OS’s R&D.
Disadvantage:
Difficult to implement due to effort required to provide an exact duplicate to underlying machine

Virtual machine software run in kernel mode since it is OS, where as virtual machine run in user mode.
Thus there should be virtual user mode and virtual kernel mode, both run in a physical user mode. Thus
actions that cause transfer from user mode to kernel mode must also ca use a transfer from virtual user
mode to virtual kernel mode on a virtual machine. Thus compared to real OS time taken here will be
more for task completion.

Examples – Two popular contemporary virtual machines are VMware and the Java virtual machine.

2.8.1 VMware –

This runs as an application on a host OS such as Windows or Linux and allows to run several different
guest OS’s as independent virtual machines. If developer want to test a new application on different OS
then it is best to go for VMware.

23
Module 1 Operating System
Introduction to OS
One such VMware architecture is shown in fig 2.8.1. Here Linux is running as host OS; FreeBSD,
Windows NT and Windows XP are running as guest OS. The virtualization layer is the heart of VMware,
as it abstracts the physical hardware into isolated virtual machines running as guest OS.

Fig 2.8.1 VMware architecture

2.8.2 The Java Virtual Machine (JVM)

➢ The JVM is a specification for an abstract computer. It consists of a class loader


and a Java interpreter that executes the architecture-neutral byte codes as shown in fig
2.8.2.

➢ The class loader loads the compiled .class files from both the Java program and the
Java API for execution by the Java interpreter. After class is loaded, verifier checks whether the
.class file is valid java byte code and does not overflow or underflow the stack. Once class
passes verification, then it is run by the Java interpreter. JVM also handles garbage collection.

➢ JVM may be implemented in software on top of the host OS or as part of web


browser. It can also be implemented in hardware on a chip specifically designed to run java
programs. JIT compiler is used for faster compilation process.

Fig 2.8.2 The Java Virtual Machine

24
Module 1 Operating System
Introduction to OS
2.9 OS Generation
• OS is designed to run on any class of machines and for this the system must be configured for each
specific computer site
• Process known as SYSGEN is used for configuring a system for each specific computer site
• SYSGEN program must determine the following information for configuring the hardware system:
1. What CPU will be used? -
2. How will boot disk be formatted?
3. How much memory is available?
4. What devices are available?
5. What OS options are desired?
• A system-administrator can use the above information to modify a copy of the source code of the OS.
• The OS is then completely compiled and later it is tailored to the system described.

2.10 System Boot


The procedure of starting a computer by loading the kernel is known as booting the system.
The bootstrap program
→ locates the kernel
→ loads the kernel into main memory and
→ starts execution of kernel.
When system is rebooted, the instruction register is loaded with an initial boot strap program and
execution starts there. Bootstrap program will be stored in ROM. Bootstrap program initializes all
aspects of the system, from CPU registers to device controllers and the contents of the main memory.
Then it starts the OS.
In few OS, boot strap loader is stored in firmware, and the OS is on the disk. Here bootstrap runs
diagnostics and has bit of code that can read a single block from disk to memory and execute the code
from that boot block. The program stored in the boot block is enough to load the OS into memory and
begin its execution.
Disk that has a boot partition is called boot disk or system disk.

25
Module 1 Operating System
Introduction to OS
Chapter 3: Process Concept

Process is unit of work. System consists of collection of processes. Processes are categorized into user
process and OS process. OS process executes system code where as user process executes user code.

3.1 Process Overview

3.1.1 The Process


Program is a passive entity such as an executable file stored on disk. A program becomes a process
when an executable-file is loaded into memory. A process is a program in execution. It includes (Figure
3.1):
1. Program counter to indicate the current activity.
2. Registers content of the processor.
3. Process stack contains temporary data.
4. Data section contains global variables.
5. Heap is memory that is dynamically allocated during process run time.

Fig 3.1

If many copies of a program are run then each is a separate process. The text-sections are
equivalent, but the data-sections vary.

3.1.2 Process State

When process gets executed, it changes state depending on the current activity of that process.
Process will be in one of the following states.

• New: The process is being created.


• Running: Instructions are being executed.
• Waiting: The process is waiting for some event to occur (such as I/0 completions).
• Ready: The process is waiting to be assigned to a processor.
• Terminated: The process has finished execution.
Only one process can be running on any processor at any instant.

26
Module 1 Operating System
Introduction to OS
3.1.3 Process Control Block
In OS, each process is represented by a PCB (Process Control Block) also called as task control block.

Fig 3.1.3 PCB

PCB contains following information about the process (Figure 3.1.3):

1. Process State

→ new, ready, running, waiting or halted.


2. Program Counter
• This indicates the address of the next instruction to be executed for the process.
3. CPU Registers
These include

→ accumulators (AX)
→ index registers (SI, DI)
→ stack pointers (SP) and
→ general-purpose registers (BX, CX, DX).
4. CPU Scheduling Information
This includes
→ priority of process
→ pointers to scheduling-queues and
→ scheduling-parameters.
5. Memory Management Information
This includes
→ value of base- & limit-registers and
→ value of page-tables( or segment-tables).
6. Accounting Information
This includes
→ amount of CPU time
→ time-limit and
→ process-number.
7. I/O Status Information
This includes
→ list of I/O devices & → list of open files.

3.1.4 Threads
Process is a program that may either performs a single thread of execution or multiple thread of execution.

27
Module 1 Operating System
Introduction to OS
3.2 Process Scheduling
The objective of multiprogramming is to have some process running at all times to maximize CPU utilization,
where as in case of timesharing objective is to switch the CPU between processes so frequently that users
can interact with each program while it is running. To meet the above two objectives Process scheduler is
used
to select an available process for program- execution on the CPU.

3.2.1 Scheduling Queues


There are three types of scheduling-queues -
1. Job Queue
This consists of all processes in the system. As processes enter the system, they are put
into a job-queue.

2. Ready Queue
o This consists of the processes that are residing in main-memory and ready & waiting
to execute (Figure 3.2).
o This queue is generally stored as a linked list.
o A ready-queue header contains pointers to the first and final PCBs in the
list. o Each PCB has a pointer to the next PCB in the ready-queue.
o
3. Device Queue
✓ This consists of the processes that are waiting for an I/O device.
✓ Each device has its own device-queue.

Fig 3.2 The ready queue and various I/O devices

When the process is executing, one of following events could occur (Figure 3.3):
1. The process could issue an I/O request and then be placed in an I/O queue.
2. The process could create a new sub process and wait for the sub process’s termination.
3. The process could be interrupted and put back in the ready-queue.

28
Module 1 Operating System
Introduction to OS

Fig 3.3 Queuing diagram representation of process scheduling


3.2.2 Schedulers
A Process migrates among the various scheduling queues throughout its lifetime. OS must select process from these
queues for CPU execution. This selection process is done by scheduler. Three types of schedulers exist - Long-term
scheduler, Short-term scheduler and Medium-term schedulers. In Batch system, long term and short term schedulers
are used.
Long-term Scheduler Short-term Scheduler
Also called job scheduler. Also called CPU scheduler.
Selects which processes should be brought Selects which process should be executed
into the ready-queue. next and allocates CPU.
Need to be invoked only when a process Need to be invoked to select a new process
leaves the system and therefore executes for the CPU and therefore executes much
much less frequently. more frequently.
May be slow, few minutes may separate the Must be fast ‘,’ a process may execute for
creation of one new process and the next. only a few milliseconds.
Controls the degree of multiprogramming.

Long term scheduler should make careful selection of process because processes can be described as either -
1. I/O-bound Process
Here process spends more time doing I/O operation than doing computations and hence many short CPU
bursts. In this type of process ready queue will almost always be empty

2. CPU-bound Process
Here process spends more time doing computations than doing I/O operation and hence few very long CPU
bursts. In this type of process device queue will almost always be empty.
So Long term scheduler should select a good process mix of I/O-bound and CPU-bound processes

Some time-sharing systems have medium-term scheduler, which is an intermediate level of scheduling.
This is required because in few systems long term scheduler is not required. (Figure 3.4).
a. The scheduler removes processes from memory and thus reduces the degree of
multiprogramming.
b. Later, the process can be reintroduced into memory, and its execution can be continued
where it left off. This scheme is called swapping. Swapping is required to improve the
process.
c. The process is swapped out, and is later swapped in, by the medium term scheduler .

29
Prof. Veena ISE SCE
Module 1 Operating System
Introduction to OS

Figure 3.4 Addition of medium-term scheduling to the queuing diagram

3.2.3 Context Switch


Context-switch means saving the state of the current process and switching the CPU to another process as
shown in fig 3.2.3. The context of a process is represented in the PCB of the process; it includes
→ value of CPU registers
→ process-state and
→ memory-management information.
During context switch, current state of the CPU whether in kernel or user mode should be saved and
then the state should be restored to resume operations.

Disadvantages:
1. Context-switch time is pure overhead, because the system does no useful work
while switching.
2. Context-switch times are highly dependent on hardware support.

Fig 3.2.3 Diagram showing CPU switch from process to process

3.3 Operations on Processes


In most of the systems processes can execute concurrently, and they may be created and deleted
dynamically.

3.3.1 Process creation


A process may create a new process via a create-process system-call. The creating process is called
a parent-process. The new process created by the parent is called the child-process (Sub-process).

30
Module 1 Operating System
Introduction to OS
OS identifies processes by pid (process identifier), which is typically an integer-number.
A process needs following resources to accomplish the task:
→ CPU time
→ memory and
→ I/O devices.

Child-process may
→ get resources directly from the OS or
→ get resources of parent-process. This prevents any process from overloading the
system. Initialization data will also be passed to the child process from parent process.
Two options exist when a process creates a new process:
1. The parent & the children execute concurrently.
2. The parent waits until all the children have terminated.

Two options exist in terms of the address-space of the new process:



The child-process is a duplicate of the parent-process (it has the same program and data as the
parent).

The child-process has a new program loaded into it.

Example – process creation in UNIX


➢ In UNIX, each process is identified by its process identifier (pid). A new process is created by the
fork() system-call (fig 3.5)
➢ The new process consists of a copy of the address-space of the original process.
➢ Both the parent and the child continue execution with one difference:
1. The return value for the fork() is zero for the new (child) process.
2. The return value for the fork() is nonzero pid of the child for the parent-process.

Typically, the exec() system-call is used after a fork() system-call by one of the two processes to
replace the process's memory-space with a new program. The parent can issue wait() system-
call to move itself off the ready-queue. (Fig 3.6)

31
Module 1 Operating System
Introduction to OS
Fig 3.5 UNIX program to create new process

Fig 3.6 Process creation

3.3.2 Process Termination


A process terminates when it executes the last statement in the program. OS deletes the process by using
exit() system-call. Then, the OS de-allocates all the resources of the process. The resources include
→ memory
→ open files and
→ I/O buffers.

→ A process can cause the termination of another process via TerminateProcess() system-call.
→ Users could arbitrarily kill the processes.

A parent terminates the execution of children for following reasons:


1. The child has exceeded its usage of some resources.
2. The task assigned to the child is no longer required.
3. The parent is exiting, and the OS does not allow a child to continue.
In some systems, if a process terminates, then all its children must also be terminated. This

phenomenon is referred to as cascading termination.

3.4 Interprocess Communication


Processes executing concurrently in the OS may be either Independent processes or Co-operating
processes.

1. A process is independent if the process cannot affect or be affected by the other processes.
Here process does not share data with other processes.
2. A process is co-operating if the process can affect or be affected by the other processes and
the process shares data with other processes.

Advantages of process co-operation:


➢ Information Sharing-
Since many users may be interested in same piece of information (ex: shared file).
➢ Computation Speedup
Task is divided into subtasks. Each subtask should be executed in parallel with the other
subtasks. The speed can be improved only if computer has multiple processing elements such as

→ CPUs or
→ I/O channels.
➢ Modularity
Divide the system-functions into separate processes or threads.

➢ Convenience

32
Module 1 Operating System
Introduction to OS
An individual user may work on many tasks at the same time. For ex, a user may be editing, printing,
and compiling in parallel.

Two basic models of IPC (Fig 3.7):


1) Shared-memory and
2) Message passing.

Fig 3.7 Message passing Shared memory

3.4.1 Shared Memory systems

➢ Communicating-processes must establish a region of shared-memory. A shared-memory resides in


address-space of the process that created shared memory; other processes must attach their address-
space to the shared-memory. The processes can then exchange information by reading and writing data
in the shared-memory.
➢ The processes are also responsible for ensuring that they are not writing to the same
location simultaneously.
For ex, producer-consumer problem:
Producer-process produces information that is consumed by a consumer-process
Two types of buffers can be used:
1. Unbounded-buffer places no practical limit on the size of the buffer.
2. Bounded-buffer assumes that there is a fixed buffer-size.
Let’s check bounded buffer used to enable processes to share memory –

#define BUFFER_SIZE 10
typedef struct {
… } item ;
Item buffer[BUFFER_SIZE] ;
int in=0, out = 0 ;

Producer process code is –


Item nextProduced ;
while (true) {
while (((in+1) % BUFFER_SIZE) == out)
; /* do nothing */
Buffer[in] = nextProduced ; in = ( in + 1)% BUFFER_SIZE ;

33
Module 1 Operating System
Introduction to OS
Consumer process code is –
Item nextConsumed ;
while (true) {
while (in == out)
; /* do nothing */
nextConsumed = buffer[out]
out =
(out+1)%BUFFER_SIZE;

Advantages:
1. Allows maximum speed and convenience of communication.
2. Faster because accessing data will be similar to normal memory read and write.

3.4.2 Message passing systems


Here messages are exchanged between cooperating processes; these allow processes to communicate
and to synchronize their actions without sharing the same address-space.
For example, a chat program used on the World Wide Web.

Messages can be of either fixed size or variable size -


➢ If fixed-sized messages are used, the system-level implementation is simple. However, the
programming task becomes more difficult.
➢ If variable-sized messages are used, the system-level implementation is complex. However, the
programming task becomes simpler.
A communication-link must exist between processes to communicate. Three methods for implementing

a link:
1. Direct or indirect communication.
2. Symmetric or asymmetric communication.
3. Automatic or explicit buffering.

3.4.2.1 Naming
Processes that want to communicate must have a way to refer to each other. They can use either direct or
indirect communication.
Direct Communication Indirect Communication
Each process must explicitly name the Messages are sent to/received
recipient/sender. from mailboxes (or ports).
Properties of a communication link: Properties of a communication link:
➢ ➢
A link is established automatically between every A link is established between a pair of processes
pair of processes that want to communicate. The only if both members have a shared mailbox.

processes need to know only each other’s identity to A link may be associated with more than two
communicate. processes.
➢ ➢
A link is associated with exactly two processes. A number of different links may exist

Exactly one link exists between each pair of between each pair of communicating processes.

processes. send() and receive() primitives are defined as –
send(A, message) -> send msg to mailbox A
receive(A, message) -> receive msg from mailbox A

34
Module 1 Operating System
Introduction to OS
Symmetric addressing: Mailbox owned by a process:
➢ ➢
Both sender and receiver processes must name the The owner can only receive, and the user can
other to communicate. only send.
➢ ➢
send() and receive() primitives are defined as – The mailbox disappears when its owner
send(P, message) -> send msg to process P process terminates.
receive(Q, message) -> receive msg from process Q

Asymmetric addressing: Mailbox owned by the OS:


➢ ➢
Only the sender names the recipient; the recipient The OS allows a process to:
needn't name the sender. 1. Create a new mailbox

send(P , message) send msg to process P 2. Send & receive messages via it

receive(id, msg)receive msg from any process 3. Delete a mailbox.

3.4.2.2 Synchronization
Message passing may be either blocking or non-blocking also known as synchronous and
asynchronous.

Synchronous Message Passing Asynchronous Message Passing


Blocking send: Non-blocking send:
➢ ➢
The sending process is blocked until the The sending process sends the message
message is received by the receiving process and resumes operation.
or by the mailbox.
Blocking receive: Non-blocking receive:
➢ ➢
The receiver blocks until a message is The receiver retrieves either a valid
available. message or a null.

3.4.2.3 Buffering
Messages exchanged by processes reside in a temporary queue. Three ways to implement a queue:
1. Zero Capacity
➢ The queue-length is zero.
➢ The link can't have any messages waiting in it.
➢ The sender must block until the recipient receives the message.
2. Bounded Capacity
➢ The queue-length is finite.
➢ If the queue is not full, the new message is placed in the queue.
➢ The link capacity is finite.
➢ If the link is full, the sender must block until space is available in the queue.
3. Unbounded Capacity
➢ The queue-length is potentially infinite.
➢ Any number of messages can wait in the queue.
➢ The sender never blocks.

VTU Question Paper Questions


1. Explain fundamental difference between i) N/w OS and distributed OS ii) web based and
Embedded computing. . (8)

2. What do you mean by cooperating process? Describe its four advantages. (6)
3. What are different categories of system programs? Explain. (6)
4. Define OS. Discuss its role from different perspectives. (7).

35
Module 1 Operating System
Introduction to OS
5. List different services of OS. Explain. (6)
6. Explain the concept of virtual machines. Bring out its advantages. (5)
7. Difference between a trap and an interrupt (2)
8. Define an operating system. Discuss its role with user and system view points. (06)
9. Give features of symmetric and asymmetric multiprocessing systems (4)

10.Briefly explain common classes of services provided by various OS for helping use for
ensuring efficient operation of system. (10)
11. Define OS. Explain its two view points (5)
12. What are OS operations? Explain (6)
13. Define Virtual machine. With diagram, explain its working. What are its benefits? (9)

14.Distinguish among following terminologies: Multiprogramming systems, multitasking


systems, multiprocessor systems. (12)
15. What are system calls? With examples explain different categories of system call? (10)

16. List and explain services provided by an OS that are designed to make using computer system more
convenient for the user. (8)
17. Is separation of mechanism and policy desirable while designing an OS. Discuss with an Ex. (4)

18. With a neat diagram of VM ware architecture explain the concept of virtual machines and the main
advantage of using VM architecture. (8)
19. Differentiate between multiprogramming and multiprocessing (5)
20. Explain various functions of OS with respect to process and memory management. (5)

21. Explain any two facilities provided for implementing interacting process in programming language
and OS. (5)

36

You might also like