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

computer operating system lecture notes

Lecture notes

Uploaded by

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

computer operating system lecture notes

Lecture notes

Uploaded by

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

By Fred Omondi @2020 Computer Operating System 1

1.2 Specific objectives


At the end of this lecture you should be able:
 describe organization of computer systems
 describe the types of operating systems
 define operating system, functions, history
 define assembler, kernel, loader, compiler

Definition of operating system


An Operating system is a program that controls the execution of application programs
and acts as an interface between the user of a computer and the computer hardware.
Or its one program running at all times on the computer (usually called the kernel),
with all else being applications programs.
An Operating system is concerned with the allocation of resources and services, such as
memory, processors, devices and information. The Operating System correspondingly
includes programs to manage these resources, such as a traffic controller, a scheduler,
memory management module, I/O programs, and a file system.
In brief, an operating system is the set of programs that controls a computer. Some
examples of operating systems are UNIX, Mach, MS-DOS, MS Windows, Windows/NT,
OS/2 and MacOS.
The operating system is an important part of almost every computer system.A computer
system can be divided roughly into four components: the hardware, the operating
system and the application programs and the users. (see diagram below)

Functions of Operating System


1. Booting the computer
The process of starting or restarting the computer is known as booting. A cold boot is
when you turn on a computer that has been turned off completely. A warm boot is the
process of using the operating system to restart the computer.

2. Performs basic computer tasks


The operating system performs basic computer tasks, such as managing the various
peripheral devices such as the mouse, keyboard and printers. For example, most
operating systems now are plug and play which means a device such as a printer will
automatically be detected and configured without any user intervention.
3.Provides a user interface
A user interacts with software through the user interface. The two main types of user
interfaces are: command line and a graphical user interface (GUI). With a command line
interface, the user interacts with the operating system by typing commands to perform
specific tasks. An example of a command line interface is DOS (disk operating system).
By Fred Omondi @2020 Computer Operating System 2
With a graphical user interface, the user interacts with the operating system by using a
mouse to access windows, icons, and menus. An example of a graphical user interface is
Windows Vista or Windows 7.
The operating system is responsible for providing a consistent application program
interface (API) which is important as it allows a software developer to write an
application on one computer and know that it will run on another computer of the same
type even if the amount of memory or amount of storage is different on the two
machines.
4. Handles system resources
The operating system handles system resources such as the computer's memory and
sharing of the central processing unit (CPU) time by various applications or peripheral
devices. Programs and input methods are constantly competing for the attention of the
CPU and demand memory, storage and input/output bandwidth. The operating system
ensures that each application gets the necessary resources it needs in order to
maximise the functionality of the overall system.
5. Provides file management
The operating system also handles the organisation and tracking of files and directories
(folders) saved or retrieved from a computer disk. The file management system allows
the user to perform such tasks as creating files and directories, renaming files, coping
and moving files, and deleting files. The operating system keeps track of where files are
located on the hard drive through the type of file system. The type two main types of
file system are File Allocation table (FAT) or New Technology File system (NTFS)

Operating System as User Interface


As already mentioned every general purpose computer consists of the hardware,
operating system, system programs and application programs. The hardware consists of
memory, CPU, ALU, I/O devices, peripheral device and storage device. System program
consists of compilers, loaders, editors, OS etc. The application program consists of
business program, database program.
The diagram below shows the conceptual view of a computer system.
By Fred Omondi @2020 Computer Operating System 3

Every computer must have an operating system to run other programs. The operating
system and coordinates the use of the hardware among the various system programs
and application program for a various users. It simply provides an environment within
which other programs can do useful work.
The operating system is a set of special programs that run on a computer system that
allow it to work properly. It performs basic tasks such as recognizing input from the
keyboard, keeping track of files and directories on the disk, sending output to the
display screen and controlling a peripheral devices.
OS is designed to serve two basic purposes :
1. It controls the allocation and use of the computing system‘s resources among the
various user and tasks.
2. It provides an interface between the computer hardware and the programmer that
simplifies and makes feasible for coding, creation, debugging of application programs.
The operating system must support the following tasks:
1. Provides the facilities to create, modification of program and data files using and
editor. 2. Access to the compiler for translating the user program from high level
language to machine language.
3. Provide a loader program to move the compiled program code to the computer‘s
memory for execution.
4. Provide routines that handle the details of I/O programming.

Types of Operating systems (Classification)


Operating Systems are classified into different types depending on their capability of
processing
1. Single User and Single Task operating systems is for use by a single user for a
standalone single computer for performing a single task .operating system for
By Fred Omondi @2020 Computer Operating System 4
personal computers are single-user operating systems. For example, if the user is
editing a document, then a document cannot be printed on the printer
simultaneously. Single user operating systems are simple operating system designed
to manage one task at a time. Eg Ms Dos
2. Single User and Multitasking operating system allows execution of more than one
task or process concurrently. For this, the processor time is divided amongst
different tasks. This division of time is also called time sharing. The processor
switches rapidly between processes. For example, the user can listen to music on
the computer while writing an article using word processor software. The user can
switch between the applications and also transfer data between them.Windows 95
and all later versions of windows are examples of multitasking operating systems.
3. Multiuser operating systems is used in computer networks that allow same data and
applications to be accessed by multiple users at the same time .The users can also
communicate with each other. Linux, Unix, and windows 7 are examples of
multiuser operating systems.
4. Multiprocessing operating systems have two or more processors for a single running
process. Processing takes place in parallel and is also called parallel processing.
each processor works on different parts of the same task, or, on two or more
different tasks. Since execution takes place in parallel, they are used for high speed
execution, and to increase the power of computer. Linux, UNIX and Windows 7 are
examples of multiprocessing operating systems.
5. Real time operating systems are designed to respond to an event within a
predetermined time. These operating systems are used to control processes.
Processing is done within a time constraint. Operating systems monitors the events
that affect the execution of process and respond accordingly. They are used to
respond to queries in areas like medical imaging system, industrial control systems
etc. Lynx operating systems is an example of real time operating systems.
6. Embedded operating systems is embedded in a device in the rom. they are specific
to a device and are less resource intensive. They are used in appliances like
microwaves, washing machines, traffic control systems etc.

I/O System Management


One of the purposes of an operating system is to hide thepeculiarities of specific
hardware devices from the user.
The module that keeps track of the status of devices is called the I/O
(input/output)traffic controller. Each I/O device has a device handler that resides in a
separate process associated with that device. The I/O subsystem consists of
1. A memory management component that includes buffering, caching and spooling.
By Fred Omondi @2020 Computer Operating System 5
2. A general device driver interface.
Drivers are provided for specific hardware devices.
1.7 Assembler
Input to an assembler is an assembly language program. Output is an object program
plus information that enables the loader to prepare the object program for execution.
At one time, the computer programmer had at his disposal a basic machine that
interpreted, through hardware, certain fundamental instructions. He would program
this computer by writing a series of ones and zeros(machine language), place them into
the memory of the machine.

1.8Compiler
The high level languages – examples are FORTRAN, COBOL, ALGOL and PL/I – are
processed by compilers and interpreters. A compiler is a program that accepts a source
program in a high-level language and produces a corresponding object program. An
interpreter is a program that appears to execute a source program as if it was machine
language. The same name (FORTRAN, COBOL etc) is often used to designate both a
compiler and its associated language.

1.9 Loader
A loader is a routine that loads an object program and prepares it for execution. There
are various loading schemes: absolute, relocating and direct-linking. In general, the
loader must load, relocate, and link the object program. Loader is a program that
places programs into memory and prepares them for execution. In a simple loading
scheme, the assembler outputs the machine language translation of a program on a
secondary device and a loader is placed in core. The loader places into memory the
machine language version of the user‘s program and transfers control to it. Since the
loader program is much smaller than the assembler, this makes more core services
available to user‘s program.
1.10 Kernel
CPUs typically have (at least) two execution modes: user mode and kernel mode. User
applications run in user mode. The heart of the operating system is called the kernel.
This is the collection of functions that perform the basic services such as scheduling
applications. The kernel runs in kernel mode. Kernel mode is also called supervisor
mode or privileged mode. A kernel can be contrasted with a shell, the outermost part
of an operating system that interacts with user commands. Kernel and shell are terms
used more frequently in Unix operating systems than in IBM mainframe or Microsoft
Windows systems.
By Fred Omondi @2020 Computer Operating System 6
It typically makes these facilities available to application processes through inter-
process communication mechanisms and system calls. Operating system tasks are done
differently by different kernels, depending on their design and implementation.
While monolithic kernels execute all the operating system code in the same address
space to increase the performance of the system, microkernels run most of the
operating system services in user space as servers, aiming to improve maintainability
and modularity of the operating system. A range of possibilities exists between these
two extremes

History of Operating System


1.The 1940's - First Generations
The earliest electronic digital computers had no operating systems. Machines of the
time were so primitive that programs were often entered one bit at time on rows of
mechanical switches (plug boards).Programming languages were unknown (not even
assembly languages).Operating systems were unheard of.
2. The 1950's - Second Generation
By the early 1950's, the routine had improved somewhat with the introduction of punch
cards. The General Motors Research Laboratories implemented the first operating
systems in early 1950's for their IBM 701.The system of the 50's generally ran one job at
a time.
3. The 1960's - Third Generation
The systems of the 1960's were also batch processing systems, but they were able to
take better advantage of the computer's resources by running several jobs at once.
4. Fourth Generation
With the development of LSI (Large Scale Integration) circuits, chips, operating system
entered in the personal computer and the workstation age. Microprocessor technology
evolved to the point that it becomes possible to build desktop computers as powerful as
the mainframes of the 1970s.

1.11 Activities
Point out the differences between the kernel of early operating systems and the kernel
of current operating systems.
Explain how the kernel of current operating systems makes it easier to add new
components or modify existing ones, which is useful for distributed systems
By Fred Omondi @2020 Computer Operating System 7
1.12Self Assessment
1. Define Operating System ,Assembler, Loader, Compiler
2. Explain various function of operating system
3. Explain I/O system Management
4. Outline the history of operating systems

1.12 Summary
 Every general purpose computer consists of the hardware, operating system, system
programs and application programs
 Assembler :Input to an assembler is an assembly language program. Output is an object
program plus information that enables the loader to prepare the object program for
execution.
 A loader is a routine that loads an object program and prepares it for execution. There
are various loading schemes: absolute, relocating and direct-linking. In general, the
loader must load, relocate, and link the object program
 A compilers is a program that accepts a source program ‖ in a high-level language‖ and
produces a corresponding object program.
 The kernel is the central component of most computer operating systems; it is a bridge
between applications and the actual data processing done at the hardware level
 An Operating system is concerned with the allocation of resources and services, such as
memory, processors, devices and information. The Operating System correspondingly
includes programs to manage these resources, such as a traffic controller, a scheduler,
memory management module, I/O programs, and a file system.
HBT 2102 Computer Operating System Task One
Attempt the following tasks in our respective groups
Presentation Date:
1. Define Operating System ,Assembler, Loader, Compiler
2. Explain EIGHT functions of operating system
3. With the aid of a diagram, explain the conceptual view of a Computer
system
4. Outline the history of operating systems
5. Differentiate between Multitasking, Multiprocessing & Multiprogramming
6. Write brief notes in relation to the following types of Operating Systems
a. Windows
b. Unix
c. Linux
d. Macintosh
e. Ms-Dos
Lecture Two
2.1Introduction
Welcome to the second lecture on Operating Systems. In this lecture we shall examine the
principles of operating systems and operating systems architecture

2.2 Specific objectives


At the end of this lecture you should be able:
 describe operating system services and its components.

 Describe operating systems architechure

 define multitasking and multiprogramming

 describe timesharing, buffering & spooling.

2.3 Lecture Outline


2.4 Introduction
2.5 Operating System Services
2.6 Operating System Components and architecture
2.7 Batch System
2.8 Time Sharing System
2.9 Multiprogramming
2.10 Spooling
2.11 Multi programming
2.12 Properties of Operating System

2.4 Introduction
An operating system provides the environment within which programs are executed.
Internally, operating systems vary greatly in their makeup, since they are organized along
many different lines. The design of a new operating

system is amajor task. It is important that the goals of the system be well defined before
the design begins.
We can view an operating system from several viewpoints. One view focuses on the
services that the system provides, another, on the interface that it makes available to users
and programmers; a third, on its components and their interconnections
2.5 Operating System Services

P a g e | 1 Computer Operating System @Fred 2020


An operating system provides services to programs and to the users of those programs. It
provided by one environment for the execution of programs. The services provided by one
operating system is difficult than other operating system. Operating system makes the
programming task easier. The common service provided by the operating system are :
1. Program execution: Operating system loads a program into memory and executes the
program. The program must be able to end its execution, either normally or abnormally.

2. I/O Operation : I/O means any file or any specific I/O device. Program may require any
I/O device while running. So operating system must provide the required I/O.

3. File system manipulation : Program needs to read a file or write a file. The operating
system gives the permission to the program for operation on file.

4. Communication: Data transfer between two processes is required for some time. The
both processes are on the one computer or on different computer but connected through
computer network. Communication may be implemented by two methods:

a. Shared memory

b. Message passing.

5. Error detection: error may occur in CPU (central processing unit), in I/O devices or in
the memory hardware. The operating system constantly needs to be aware of possible
errors. It should take the appropriate action to ensure correct and consistent computing.

Operating system with multiple users provides following services.

1.Resource Allocation : If there are more than one user or jobs running at the same time,
then resources must be allocated to each of them. Operating system manages different types
of resources require special allocation code, i.e. main memory, CPU cycles and file storage.
There are some resources which require only general request and release code. For
allocating CPU, CPU scheduling algorithms are used for better utilization of CPU. CPU
scheduling algorithms are used for better utilization of CPU. CPU scheduling routines
consider the speed of the CPU, number of available registers and other required factors.

2. Accounting : Logs of each user must be kept. It is also necessary to keep record of which
user how much and what kinds of computer resources. This log is used for accounting
purposes. The accounting data may be used for statistics or for the billing. It also used to
improve system efficiency.

P a g e | 2 Computer Operating System @Fred 2020


3. Protection : Protection involves ensuring that all access to system resources is controlled.
Security starts with each user having to authenticate to the system, usually by means of a
password. External I/O devices must be also protected from invalid access attempts. In
protection, all the access to the resources is controlled. In multiprocess environment, it is
possible that, one process to interface with the other, or with the operating system, so
protection is required.

2.6 Operating System Components and architecture


2.6.1 Operating System Components
Modern operating systems share the goal of supporting the system components. The
system components are:
1. Process Management

2. Main Memory Management

3. File Management

4. Secondary Storage Management

5. I/O System Management

6. Networking

7. Protection System

8. Command Interpreter System

2.6.2 Operating System Architecture


Operating systems can be classified based on their structuring mechanism.Some of the
main structures used in operating systems are:
1. Monolithic systems
2. Layered systems
3. Virtual machines
4. Client/server a.k.a. Microkernels

Many of the concepts governing thesearchitectures apply to software architectures in general

1. Monolithic architecture

P a g e | 3 Computer Operating System @Fred 2020


It is the oldest architecture used for developing an operating system. An operating system
resides on kernel for anyone to execute and asystem call is involved i.e. switching from
user mode to kernel mode and transfer control to operating system which is shown as event
1. Many CPU’s have two modes, kernel mode, for the operating system in which all
instruction are allowed and user mode, for user program in which I/O devices and certain
other instructions are not allowed. Two operating systems then examine the parameter of
the call to determine which system call is to be carried out shown in event 2. Next, the
operating system index’s into a table that contains procedure that carries out system call.
This operation is shown in events. Finally, it is called when the work has been completed
and the system call is finished, control is given back to the user mode as shown in event 4.

2. Layered Architecture
The layered Architecture of operating system was developed in the 60’s in this approach;
the operating system is broken up into a number of layers. The bottom layer (layer 0) is the
hardware layer and the highest layer (layer n) is the user interface layer as shown in the
figure.

P a g e | 4 Computer Operating System @Fred 2020


The layered are selected such that each user functions and services of only lower level
layer. The first layer can be debugged without any concern for the rest of the system. It
uses basic hardware to implement this function once the first layer is debugged. Its correct
functioning can be assumed while the second layer is debugged and soon, if an error is
found during the debugging of a particular layer, the layer must be on that layer, because
the layer below it is already debugged. As a result, this design of the system is simplified
when the operating system is broken up into layers.
Os/2 operating system is an example of layered architecture of operating system and
another example is the earlier version of Windows NT.
The main disadvantage of this architecture is that it requires an appropriate definition of
the various layers &careful planning of the proper placement of the layer.

3. Virtual memory architecture

A virtual machine is an illusion of a real machine. It is created by a real machine’s


operating system, which makes a single real machine appear to be several real machines.

P a g e | 5 Computer Operating System @Fred 2020


The architecture of a virtual machine is shown above.
The best example of virtual machine architecture is the IBM 370 computer. In this system,
each user can choose a different operating system. Actually, the virtual machine can run
several operating systems at once, each of them on its virtual machine.
Its multiprogramming shares the resource of a single machine in a different manner.
The concepts of virtual machine are:-
a. Control program (cp):- cp creates the environment in which the virtual machine can
execute. It gives to each user, facilities of a real machine such as a processor, storage I/0
devices.
b. Conversation monitor system (cons):- cons is a system application having features of
developingprogram. It contains editor, language translator, and various application
packages.
c. Remote spooling communication system (RSCS):- provide virtual machine with the
ability to transmit and receive file in distributed system.
d. IPCS (interactive problem control system):- it is used to fix the virtual machine software
problems.

4. client/server architecture
This is a trend in modern operating system whereby the maximum code is moved into the
higher level so as to remove as much as possible from the operating system, minimizing
the work of the kernel. The basic approach is to implement most of the operating system
functions in the user processes so as to request a service, for instance, request to read a
particular file, the user sends a request to the server process, the server checks the
parameter and finds whether it is valid or not, after that the server does the work and sends
back the answer to the client server model which works on request- response technique i.e.
Client always sends request to the side in order to perform the task, and on the other side,
the server gates, complementing that request and sends back a response. The figure below
shows the client server architecture.

P a g e | 6 Computer Operating System @Fred 2020


In this model, the main task of the kernel is to handle all the communication between the
client and the server by splitting the operating system into a number of ports, each of
which can only handle some specific tasks. i.e. file server, process server, terminal server
and memory service.
Another advantage of the client-server model is it’s adaptability to the user in a distributed
system.

2.7 Batch System


Some computer systems only did one thing at a time. They had a list of the computer
system may be dedicated to a single program until its completion, or they may be
dynamically reassigned among a collection of active programs in different stages of
execution.Batch operating system is one where programs and data are collected together in
a batch before processing starts. A job is predefined sequence of commands, programs and
data that are combined in to a single unit called job. Memory management in batch system
is very simple. Memory is usually divided into two areas : Operating system and user
program area.
Scheduling is also simple in batch system. Jobs are processed in the order of submission i.e
first come first served fashion. When job completed execution, its memory is releases and
the output for the job gets copied into an output spool for later printing. Batch system often
provides simple forms of file management. Access to file is serial. Batch systems do not
require any time critical device management. Batch systems are inconvenient for users
because users cannot interact with their jobs to fix problems. There may also be long
turnaround times. Example of this system id generating monthly bank statement.
Advantages of Batch System
 Move much of the work of the operator to the computer.

P a g e | 7 Computer Operating System @Fred 2020


 Increased performance since it was possible for job to start as soon as the previous
job finished.
Disadvantages of Batch System
 Turnaround time can be large from user standpoint.

 Difficult to debug program.

 A job could enter an infinite loop.

 A job could corrupt the monitor, thus affecting pending jobs.

 Due to lack of protection scheme, one batch job can affect pending jobs.

2.8 Time Sharing System


Multi-programmed batched systems provide an environment where the various system
resources (for example, CPU, memory, peripheral devices) are utilized effectively.
Time sharing, or multitasking, is a logical extension of multiprogramming. Multiple jobs
are executed by the CPU switching between them, but the switches occur so frequently
that the users may interact with each program while it is running.
An interactive, or hands-on, computer system provides on-line communication between the
user and the system. The user gives instructions to the operating system or to a program
directly, and receives an immediate response. Usually, a keyboard is used to provide input,
and a display screen (such as a cathode-ray tube (CRT) or monitor) is used to provide
output.
If users are to be able to access both data and code conveniently, an on-line file system
must be available. A file is a collection of related information defined by its creator. Batch
systems are appropriate for executing large jobs that need little interaction.

P a g e | 8 Computer Operating System @Fred 2020


Time-sharing systems were developed to provide interactive use of a computer system at a
reasonable cost. A time-shared operating system uses CPU scheduling and
multiprogramming to provide each user with a small portion of a time-shared computer.
Each user has at least one separate program in memory. A program that is loaded into
memory and is executing is commonly referred to as a process. When a process executes,
it typically executes for only a short time before it either finishes or needs to perform I/O.
I/O may be interactive; that is, output is to a display for the user and input is from a user
keyboard. Since interactive I/O typically runs at people speeds, it may take a long time to
completed.
A time-shared operating system allows the many users to share the computer
simultaneously. Since each action or command in a time-shared system tends to be short,
only a little CPU time is needed for each user. As the system switches rapidly from one
user to the next, each user is given the impression that she has her own computer, whereas
actually one computer is being shared among many users.
Time-sharing operating systems are even more complex than are multi-programmed
operating systems. As in multiprogramming, several jobs must be kept simultaneously in
memory, which requires some form of memory management and protection

2.9 Multiprogramming
When two or more programs are in memory at the same time, sharing the processor is
referred to the multiprogramming operating system. Multiprogramming assumes a single
processor that is being shared. It increases CPU utilization by organizing jobs so that the
CPU always has one to execute.
Fig. 2.2 shows the memory layout for a multiprogramming system.
The operating system keeps several jobs in memory at a time. This set of jobs is a subset of
the jobs kept in the job pool. The operating system picks and begins to execute one of the
job in the memory.
Multiprogrammedsystem provide an environment in which the various system resources
are utilized effectively, but they do not provide for user interaction with the computer
system.
Jobs entering into the system are kept into the memory. Operating system picks the job and
begins to execute one of the job in the memory. Having several programs in memory at the
same time requires some form of memory management.
Multiprogramming operating system monitors the state of all active programs and system
resources. This ensures that the CPU is never idle unless there are no jobs.

P a g e | 9 Computer Operating System @Fred 2020


Advantages
1. High CPU utilization.
2. It appears that many programs are allotted CPU almost simultaneously.
Disadvantages
1. CPU scheduling is requires.
2. To accommodate many jobs in memory, memory management is required.

2.10 Spooling
Acronym for simultaneous peripheral operations on line. Spooling refers to putting jobs in
a buffer, a special area in memory or on a disk where a device can access them when it is
ready.
Spooling is useful because device access data that different rates. The buffer provides a
waiting station where data can rest while the slower device catches up.
Computer can perform I/O in parallel with computation, it becomes possible to have the
computer read a deck of cards to a tape, drum or disk and to write out to a tape printer
while it was computing. This process is called spooling.
The most common spooling application is print spooling. In print spooling, documents are
loaded into a buffer and then the printer pulls them off the buffer at its own rate.
Spooling is also used for processing data at remote sites. The CPU sends the data via
communications path to a remote printer. Spooling overlaps the I/O of one job with the
computation of other jobs.
One difficulty with simple batch systems is that the computer still needs to read the decks
of cards before it can begin to execute the job. This means that the CPU is idle during
these relatively slow operations.
Spooling batch systems were the first and are the simplest of the multiprogramming
systems.

P a g e | 10 Computer Operating System @Fred 2020


Advantage of Spooling
1. The spooling operation uses a disk as a very large buffer.
2. Spooling is however capable of overlapping I/O operation for one job with processor
operations for another job.

2.11 Multitasking
Multitasking refers to term where multiple jobs are executed by the CPU simultaneously
by switching between them. Switches occur so frequently that the users may interact with
each program while it is running. Operating system does the following activities related to
multitasking.

 The user gives instructions to the operating system or to a program directly, and
receives an immediate response.
 Operating System handles multitasking in the way that it can handle multiple
operations / executes multiple programs at a time.
 Multitasking Operating Systems are also known as Time-sharing systems.
 These Operating Systems were developed to provide interactive use of a
computer system at a reasonable cost.
 A time-shared operating system uses concept of CPU scheduling and
multiprogramming to provide each user with a small portion of a time-shared
CPU.
 Each user has at least one separate program in memory.

A program that is loaded into memory and is executing is commonly referred to as


process.

P a g e | 11 Computer Operating System @Fred 2020


When a process executes, it typically executes for only a very short time before it either
finishes or needs to perform I/O.
 Since interactive I/O typically runs at people speeds, it may take a long time to
complete. During this time a CPU can be utilized by another process.
 Operating system allows the users to share the computer simultaneously. Since
each action or command in a time-shared system tends to be short, only a little
CPU time is needed for each user.
 As the system switches CPU rapidly from one user/program to the next, each user
is given the impression that he/she has his/her own CPU, whereas actually one
CPU is being shared among many users.

2.12 Properties of Operating System


1. Batch :Jobs with similar needs are batched together and run through the computer as a
group by an operator or automatic job sequencer. Performance is increased by attempting
to keep CPU and I/O devices busy at all times through buffering , off line operation,
spooling and multiprogramming. A Batch system is good for executing large jobs that
need little interaction, it can be submitted and picked up latter.
2. Time sharing :Uses CPU s scheduling and multiprogramming to provide economical
interactive use of a system. The CPU switches rapidly from one user to another i.e. the
CPU is shared between a number of interactive users. Instead of having a job defined by
spooled card images, each program reads its next control instructions from the terminal
and output is normally printed immediately on the screen.
3. Interactive :User is on line with computer system and interacts with it via an interface.
It is typically composed of many short transactions where the result of the next transaction
may be unpredictable. Response time needs to be short since the user submits and waits for
the result.
4. Real time system :Real time systems are usually dedicated, embedded systems. They
typically read from and react to sensor data. The system must guarantee response to events
within fixed periods of time to ensure correct performance.
5. Distributed :Distributes computation among several physical processors. The
processors do not share memory or a clock. Instead, each processor has its own local
memory. They communicate with each other through various communication lines.

P a g e | 12 Computer Operating System @Fred 2020


1.11 Activities
Read about different operating system architectures that are not discussed in this lecture

1.12 Self Assessment


1. Explain various operating system services?
2. Describe the different operating system architectures
3. Differentiate Multitasking & Multiprogramming?
4. Define Spooling? Describe Spooling process?
5. Differentiate Multitasking & Multiprogramming?

1.12 Summary
 An operating system provides services to programs and to the users of those
programs. It provided by one environment for the execution of programs. The services
provided by one operating system is difficult than other operating system. Operating
system makes the programming task easier.
 Operating systems can be classified based on their structuring mechanism.Some of the
main structures used in operating systems are:Monolithic systems, Layered systems,
Virtual machines, Client/server a.k.a. Microkernels
 Batch operating system is one where programs and data are collected together in a
batch before processing starts. In batch operating system memory is usually divided
into two areas : Operating system and user program area.
 Time sharing, or multitasking, is a logical extension of multiprogramming. Multiple
jobs are executed by the CPU switching between them, but the switches occur so
frequently that the users may interact with each program while it is running.
 When two or more programs are in memory at the same time, sharing the processor is
referred to the multiprogramming operating system.
 Spooling is useful because device access data that different rates. The buffer provides
a waiting station where data can rest while the slower device catches up.

P a g e | 13 Computer Operating System @Fred 2020


1.13 Suggestion for further reading
1. Abraham Silberschatz, Greg Gagne, Peter Baer Galvin(2002):Operating System
Concepts, Wiley
2. Andrew S. Tanenbaum , Modern Operating Systems 3 e, (c) 2008 Prentice-Hall
1.14 Extracted from
1. Prof. Harsh Bhor,Prof. UdayRote,Prof. UmeshShinde Operating Systems
(K.J.S.I.E.I.T SION MUMBAI)

P a g e | 14 Computer Operating System @Fred 2020


BIT 1106 OPERATING SYSTEMS

LECTURE FOUR
4.0 Introduction
Welcome to the forth lecture on operating systems. In this lecture we shall cover the basic of process
synchronisation and inter-process communication. We will introduce the concepts of mutual
exclusion, semaphores, monitors which will be covered in more detail in the lecture on concurrency
control.

4.1 Specific Objectives

At the end of the lecture you should be able to:


1. Describe process synchronisation
2. Describe inter process communication in operating systems
3. Describe the terms mutual exclusion, semaphores, monitors

4.2 Lecture Outline


4.2.1 Process Synchronisation
4.2.2 Mutual Exclusion
4.2.3 Semaphores
4.2.4 Monitors
4.2.5 Inter communication

4.2.1 Process Synchronisation


Multiprogramming created an environment for concurrent classic processes. It also made it possible
to create a group of cooperating processes to work concurrently on a single problem.
Process synchronization or coordination seeks to make sure that concurrent processes or threads don’t
interfere with each other when accessing or changing shared resources.
To illustrate this suppose Betty , John, and Pat decide to have a meeting in Betty’s office. They must
next agree on a time for the meeting. They each consult their calendars to decide when all of them
wish to meet. By reaching an agreement about the time of the meeting, they are explicitly committing
to synchronize their independent schedules so that they will all be in the same place at the same time.
In the software context, synchronization refers to the act of ensuring that independent
processes/threads begin to execute a designated block of code at the same logical time .

1
When multiple processes are accessing shared data without access control the final result depends on
the execution order creating what we call race conditions. This is a serious problem for any
concurrent system using shared variables. We need access control using code sections that are
executed atomically. An Atomic operation is one that completes in its entirety without interruption.
Multiple cooperating threads introduce the potential for new synchronization problems in software
implementations: deadlock, critical sections, and non-determinacy

4.2.1.1 Critical sections


Segments of code that touch shared resources are called critical sections thus, no two processes
should be in their critical sections at the same time.
For example If a bus and a car get to an intersection at the same time, there will be a collision. We say
that the intersection is a critical section of each street. It is acceptable for the bus or the car to use the
intersection if the other is not currently using it. However, there will be a “transportation failure” if
the bus and the car enter the intersection at the same time. Critical sections occur in concurrent
software whenever two processes/threads access a common shared variable.
Like the bus and the car, there may be certain parts of the two processes that should not be executed
concurrently. Such parts of the code are the software critical sections.
A solution to the critical section problem must satisfy the following three requirements:
1. Mutual Exclusion
If process Pi is executing in its critical section, then no other process can be executing in their critical
section.
2. Progress
If no process is executing in its critical section and some processes wish to enter their critical sections,
then only those processes that are not executing in their remainder section can participate in the
decision on which will enter its critical section next, and this selection cannot be postponed
indefinitely.
3. Bounded Waiting
There exists a bound on the number of times that other processes are allowed to enter their critical
sections after a process has made a request to enter its critical section and before that request is
granted.
4.2.1.2 Deadlock
The existence of critical sections creates an environment in which a new problem can occur: this is
referred to as a deadlock. In a deadlock situation, two or more processes/threads get into a state
whereby each is controlling a resource that the other needs. For example, suppose two pirates have
2
each obtained half of a treasure map .Each pirate needs the other half of the map to obtain the treasure,
but neither will give up his half of the map. This is a deadlock.

4.2.1.3 Non determinacy


The operating system must respond to events, which will occur in an unpredictable order but it must
preserve the consistency of the whole system. If we have two processes, say P1 and P2, running
concurrently and P1 produces the events E1, E2, E3 and P2 produces the events E3, E4, E5. These six
events might occur in different orders, such as E1,E2 , E4, E3, E5,E6 or E3, E1, E4, E2, E3, E5 and
the operating system will keep all the system in a coherent way.

4.2.2 Mutual Exclusion


A mutual exclusion (mutex) is a program that prevents simultaneous access to a shared resource. This
concept is used in concurrent programming with a critical section. Only one thread owns the mutex at
a time, thus a mutex with a unique name is created when a program starts. When a thread holds a
resource, it has to lock the mutex from other threads to prevent concurrent access of the resource.
Upon releasing the resource, the thread unlocks the mutex.

Mutex comes into the picture when two threads work on the same data at the same time. It acts as a
lock and is the most basic synchronization tool. When a thread tries to acquire a mutex, it gains the
mutex if it is available, otherwise the thread is set to sleep condition. Mutual exclusion reduces
latency and busy-waits using queuing and context switches. Mutex can be enforced at both the
hardware and software levels

4.2.3 Semaphores
In software, a semaphore is an OS abstract data type that performs operations similar to the traffic
light. The semaphore will allow one process to control the shared resource while the other process
waits for the resource to be released. Before discussing the principles of operation of semaphores,
let’s consider the assumptions under which semaphores operate. An acceptable solution to the critical
section problem has these requirements:
 Only one process at a time should be allowed to be executing in its critical section ie mutual
exclusion.
 If a critical section is free and a set of processes all want to enter the critical section, then the
decision about which process should be chosen to enter the critical section should be made by
the collection of processes instead of by an external agent such as a scheduler.

3
 If a process attempts to enter its critical section and the critical section becomes available,
then the waiting process cannot be blocked from entering the critical section for an indefinite
period of time.
 Once a process attempts to enter its critical section, then it cannot be forced to wait for more
than a bounded number of other processes to enter the critical section before it is allowed to
do so.

A semaphore is a simpler construct than a monitor because it’s just a lock that protects a shared
resource – and not a set of routines like a monitor. The application must acquire the lock before using
that shared resource protected by a semaphore. A mutex is the most basic type of semaphore. In a
mutex, only one thread can use the shared resource at a time. If another thread wants to use the shared
resource, it must wait for the owning thread to release the lock.

4.2.4 Monitors

A monitor is a set of multiple routines which are protected by a mutual exclusion lock. None of the
routines in the monitor can be executed by a thread until that thread acquires the lock. This means
that only ONE thread can execute within the monitor at a time. Any other threads must wait for the
thread that’s currently executing to give up control of the lock.

However, a thread can actually suspend itself inside a monitor and then wait for an event to occur. If
this happens, then another thread is given the opportunity to enter the monitor. The thread that was
suspended will eventually be notified that the event it was waiting for has now occurred, which
means it can wake up and reacquire the lock.

4.2.5 Inter communication


Inter processor communication in a multiprocessor system is used to generate information about
certain sets of computations finishing on one processor and to let the other processors waiting for
finishing the computations take note of the information. Similarly, there is inter process
communication from a process to another.

4.2.5.1 Need of Inter Process Communication


Assume that there is need to send through the kernel an output data (a message of a known size with
or without a header or a flag to notify an event) for processing or taking note of by another task
Global variables problems shared data and no encapsulation of the data or message accessibility

4
by other tasks .
Inter Process Communication (IPC) functions in the OS provide the solutions means that a process
(scheduler, task or ISR) generates some information by signal (for other process start) or value (for
example of semaphore) or generates an output so that it lets another process take note or use it
through the kernel functions for the IPCs

4.2.5.2 Inter Process Communication (IPC) in Multitasking System


It is used to signal for other processes to start or generate message from the certain sets of
computations finishing on one task and to let the other tasks take note of signal or get the message

4.3 Self Test


1.Define the following terms:
a) critical sections
b) Non determinacy
c) Bounded Waiting
2. Describe the need for Inter Process Communication
3. Differentiate between semaphores and monitors

5
4.4 Summary
 Process synchronization or coordination seeks to make sure that concurrent processes or
threads don’t interfere with each other when accessing or changing shared resources.
 Segments of code that touch shared resources are called critical sections thus, no two
processes should be in their critical sections at the same time.
 The existence of critical sections creates an environment in which a new, subtle problem
can occur: deadlock.
 A mutual exclusion (mutex) is a program object that prevents simultaneous access to a
shared resource.
 A semaphore is a simpler construct than a monitor because it’s just a lock that protects a
shared resource – and not a set of routines like a monitor
 A monitor is a set of multiple routines which are protected by a mutual exclusion lock.
 Inter processor communication in a multiprocessor system is used to generate information
about certain sets of computations finishing on one processor and to let the other
processors waiting for finishing the computations take note of the information

4.5 References
1. Chapter Eight: Basic Synchronization Principles Nutt, G. Operations Systems, Third
Edition (2003) Addison-Wesley

2. Chapter-7 L12: "Embedded Systems - Architecture, Programming and Design" , Raj


Kamal, Publs.: McGraw-Hill, Inc

You might also like