




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















1. Process Management: A process can be thought of as a program in execution. A time-shared
user program such as a compiler is a process. A word- processing program being run by an individual
user on a PC is a process. A system task, such as sending output to a printer is also a process.
A process needs certain resources, which includes CPU time, memory, files and I/O devices to
accomplish its task. These resources are either given to the process when it is created, or allocated
to it while it is running. Various initialization data (input) may be passed along with the physical and
logical resources that are obtain by the process creation. E.g. a process whose function is to display
the status of a file on the screen of a terminal. The process will be given as an input the name of a
file, and will execute the appropriate instructions and system calls to obtain and display on the
terminal the desired information. After the termination of the process, the O.S. will reclaim any
reusable resources.
Program by itself is not a process; a program is a passive entity, such as the contents of a file
stored on disk, whereas a process is an active entity, with a program counter specifying the next
instruction to execute. The CPU executes one instruction of the process after another sequentially,
until the process completes. At any time, at most one instruction is executed on behalf of the
process. Thus, if two processes may be associated with the same program, they are however
considered two separate execution sequences.
A process is the unit of work in a system. Such a system consists of a collection of processes,
some of which are Operating System processes (those that execute system code) and the rest
of which are user processes (those that execute user code). All these processes can potentially
execute concurrently, by multiplexing the CPU among them.
The O.S. is responsible for the following activities in connection with process management:
computer systems. Main memory is a large array of words or bytes having Megabytes or Gigabyte
size. Each word or byte has its own address. Main memory is a repository of quickly accessible data
shared by the CPU and I/O devices. The central processor reads instructions from main memory
during the instruction-fetch cycle , and it both reads and writes data from main memory during
the data-fetch cycle. The I/O operations implemented via DMA also read and write data in main
memory. The main memory is the only large storage device that the CPU is able to address and
access directly.E.g. The CPU 6o process data from disk, those data must first be transferred to main
memory by CPU-generated I/O calls. Equivalently, instructions must be in memory for the CPU to
execute them.
For a program to be executed, it must be mapped to absolute addresses and loaded into memory.
As the program executes, it accesses program instructions and data from memory by generating
these absolute addresses. Eventually, the program terminates, its memory space is declared
available, and the next program can be loaded and executed.
Several programs must be in memory to improve the utilization of CPU and to increase the computers
speed in response to its users.
There are so many memory management schemes available depending upon the design of the
hardware and the on the particular situation.
The O.S. is responsible for the following activities in connection with memory management:
available.
accommodate all data and programs, and because the data that it holds are lost when power is lost,
the computer system must provide secondary storage to back up main memory. Most modern
computer systems use disks as the principal on-line storage medium, for both programs ( including
compilers, assemblers, sort routines, editors, and formatters) and data. Disk acts as both source as
well as destination of the process and therefore, there must be a proper management of the disk
storage.
The O.S. is responsible for the following activities in connection with disk management:
The entire speed of operation of the computer system depends upon the speeds of disk subsystems
and of the algorithms that manipulate that subsystem.
4. File Management: A file is a collection of related information defined by its creator. Commonly,
files represent programs (both source and object forms) and data. Data files may be numeric,
alphabetic, or alphanumeric. Files may be free-form (e.g. text files) or may be formatted rigidly
(e.g. fixed fields). A file consists of a sequence of bits, bytes, lines, or records whose meaning
defined by their creators. The operating system maps files onto physical media (mass storage
media), and accesses these files via the storage devices(Magnetic tape, magnetic disk, and optical
disk). Also, files are normally, organized into directories to ease their use. When multiple users have
access to files, we may want to control by whom and in what ways (e.g., read, write, append) files
may be accessed.
The O.S. is responsible for the following activities in connection with file management:
from the user e.g. in UNIX I/O devices are hidden from the operating system. Devices itself are
system from outsiders is also important and therefore user have to authenticate himself to
the system, usually by means of a password, to be allowed access to the resources and also
for the external I/O devices, including modems and network adapters.
Command Interpreter: Is the interface between user and OS. Some O.S. includes the command
interpreter in the kernel. Other O.S. , such as MS-DOS and UNIX, treat the command interpreter
as a special program that is running when a job is initiated, or when a user first logs on(on time-
sharing systems). This program is sometimes called the control-card interpreter or the
command-line interpreter , and is often known as the shell. Its function is simple: To get the
next command statement and execute it. The command statements themselves deal with process
creation and management, I/O handling, secondary storage management, main-memory
management, file – system access, protection, and networking. The MS-DOS and UNIX shells operate
in this way.
System calls provide the interface between a process and the operating system. These calls are
generally available as assembly-language instructions.
Certain systems allow system calls to be made directly from a high-level language program, in which
case the calls normally resemble predefined function or subroutine calls.
Several languages-such as C,C++, and Perl-have been defined to replace assembly language for
system programming. These languages allow system calls to be made directly. E.g., UNIX system
calls may be invoked directly from a C or C++ program. System calls for modern Microsoft Windows
platforms are part of the Win32 application programmer interface(API), which is available for use by
all the compilers written for Microsoft Windows. Three most common APIs are Win32 API for
Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and
Mac OS X), and Java API for the Java virtual machine (JVM)
Example of System Calls:
System call sequence to copy the contents of one file to another file
System calls occur in different ways, depending upon the computer in use. For example, to get input,
we may need to specify the file or device to use as the source, and the address and length of the
memory buffer into which the input should be read. .Of course, the device or file and length may be
implicit in the call.
Three general methods are used to pass parameters to the operating system.
cases, parameters are generally stored in a block or table in memory, and the address of the block
is passed as a parameter in a register as shown in the figure. This is the approach taken by Linux
o Get device attributes, set device attributes - to get or set the device attributes
o Logically attach or detach devices - to logically attach or detach the device from the
process.
come under this category.
o Get time or date, set time or date
o Get system data, set system data
o Get process, file, or device attributes
o Set process, file, or device attributes
Two types of process communication exist namely Shared memory method and Message
passing method.
Message passing method is entirely controlled by operating system kernel hence involve a
large no of system calls like
o Create, delete communication connection
o Send, receive messages
o Transfer status information
o Attach or detach remote devices
In shared memory method the kernel performs the initialization of the communication. Then
the process take care of the communication with their codes. Thus a memory map system
call occurs to start with the communication.
System programs: Different categories of system programs.
System programs provide a convenient environment for program development and execution. Some
of them are simply user interfaces to system calls; others are considerably more complex. They are
divided into the following categories:
generally manipulate files and directories.
available memory or disk space, number of users, or similar status information. That
information is then formatted, and is printed to the terminal or other output device or file.
of files stored on disk or tape.
programming languages (such as C, C++, Java, Visual Basic and perl) are often provided to
the user with the O.S.
loaded into memory to be executed the system may provide absolute loaders, relocatable
loaders, linkage editors, and overlay loaders. Debugging systems for either high-level
languages or machine languages are needed also.
among processes, users, and different computer systems. They allow users to send
messages to one another’s screens, to browse web pages, to send e-mail, to log in remotely,
or to transfer files from one machine to another.
processors and text formatters, spreadsheets, database systems, compiler compilers,
plotting and statical-analysis packages, and games.
command.
Simple structure, Layered approach, Kernel based approach
Simple structure
The operating system is created without a well defined structure.Frequently ,such operating system
started as small,simple and limited systems and then grew beyond their original scope.
MS-DOS ia an example of such a system( see figure)
MS-DOS Layer Structure
We can view the traditional UNIX operating system as shown in the figure:
programs, resulting a smaller kernel In general, however, microkernels typically provide minimal
process and memory management, in addition to a communication facility.
The main function of the microkernel is to provide a communication(by message passing) facility
between the client program and the various services that are also running isn user space.
The benefits of the microkernel approach include the ease of extending the O.S. All the new services
are added to user space and consequently do not require modification of the kernel. When the kernel
does have to be modified, the changes tend to be fewer, because the microkernel is a smaller kernel.
The resulting O.S. is easier to port from one hardware design to another. The microkernel also
provides more security and reliability, since most services are running as user- rather than kernel-
process. If a service fails, the rest of O.S. remains untouched. Tru64 UNIX(formerly Digital UNIX),
Apple MacOSX Server O.S. are based on the Mach kernel(michrokernel). QNX is a real-time
O.S.uses michrokernel, providing services for message passing and process scheduling. Window NT
including Win32, OS/2 and POSIX use michrokernel approach.
System Design and Implementation
OS design issues:
1. Design Goals: The first problem in designating a system is to define the goals and specifications
of the system. The design of the system will be affected by the choice of hardware and type of
system : batch, time shared, single user, multi-user, distributed, real time, or general purpose.
The requirements can be divided into two basic groups: user goals and system goals.
User goals: The system should be convenient and easy to use, easy to learn, reliable, safe and fast.
System goals: the operating system should be asy to design, implement, and maintain; it should be
flexible, reliable, error free, and efficient.
2. Mechanisms and Policies: The specification and design of an operating system is a highly
creative task and general software engineering principles do exist that are especially applicable
to operating systems. One important principle is the separation of policy from mechanism.
Mechanisms determine how to do something: policies determine what will be done. Policies are
likely to change across places or over time. In the worst case, each change in policy would require
a change in the underlying mechanism. A general mechanism would be more desirable. A change in
policy would then require redefinition of only certain parameters of the system. For instance, if, in
one computer system, a policy decision is made that I/O-intensive programs should have priority
over CPU-intensive ones, then the opposite policy could be instituted easily on some other computer
system if the mechanism were properly separated and were policy independent.
Microkernel-based operating systems take separation of mechanism and policy by implementing a
basic set of primitive building blocks, via user created kernel modules, or via user programs
themselves. These blocks are almost policy free. Policy decisions must be made for all resource-
allocation and scheduling problems.
3. Implementation: The operating system must be written in high level languages such as C o
C++, because it is far easier to port-to move to some other hardware. e.g. MS-DOS was written in
Intel 8088 assembly language and consequently, it is available on only the Intel family of CPUs. The
UNIX operating system, on the other hand, which is written mostly in C, is available on number of
different CPUs, including Intel80X86, Pentium, Motorola 680X0, ULTRA SPARC, Compaq Alpha, and
Major performance improvements in operating systems are more likely to be the result of better
data structures and algorithms in high-level languages than the assembly language codes. After the
system is written and working correctly, bottleneck routines can be identified and replaced with
assembly-language equivalents.
A process may be in one of 2 states not running and running Figure illustrates when OS creates a
new process it inters that process into the system in the not running state. Thus the process exists
and is waiting for an opportunity to execute. From time to time the currently running process will be
interrupted and the dispatcher portion of the OS will select a new process to run. The former process
moves from running state to not running state and one of the process moves to the running state.
when a process is interrupted it is transferred to the queue of waiting processes alternatively if the
process has completed or aborted, the process is discarded.
Five state model:
Only one process can be running on any processor at any instant, although many processes may be
ready and waiting.
The 5 states in the above diagram are as follows.
The process that is currently being executed.
Processes those are ready to execute when given the opportunity.
A process that cannot execute until some events occur.
A process that has first been created but has not yet been admitted in the pool of executable
processes.
A process that has been released from the pool of executable processes either because it is
halted or aborted for some reasons.
A process exits the system in 2 stages.
i) A process is terminated when it reaches a natural completion point
ii) When another process with appropriate authority causes the process to abort / terminate,
moves the process to EXIT STATE.
The ways of managing processes is quite complicated & put of are scope but knowing the concept is
essential.
Process
Image
Process
General Structure Of Operating System Control Tables
If the OS is to manage processes and resources it must have information about current status of
each process and resource. The OS constructs and maintains tables of information about each entity
that it is managing. Above figure shows 4 different types of tables maintained by OS =>memory,
I/O, File and process.
I Memory tables are used to keep track of both main and secondary memory & reserved for use
by the OS. The remainder is available for use by the processes. Processes are maintained on
Memory
Memory Tables
this process.
architecture. They include accumulators, index registers, stack pointers, and general-purpose
registers, plus any condition-code information. Along with the program counter, this state
information must be saved when an interrupt occurs, to allow the process to be continued
correctly afterward
scheduling queues, and any other scheduling parameters.
value of the base and limit registers, the page tables, or the segment tables, depending on the
memory system used by the OS.
time limits, account numbers, job or process numbers, and so on.
process, a list of open files, and so on.
The PCB simply serves as the repository for any information that may vary from process to process.
The following diagram shows how the CPU switch from process to process by using
PCB after the interrupt or system call.
Operation on processes: Creation, Termination,
Cooperation among the processes.
A process may create several new processes, via a create-process system call , during the course
of execution. The creating process is called a parent process , whereas the new processes are
called the children of that process. Each of these new processes may in turn create other processes,
forming a tree of processes as shown below.
In general, a process will need certain resources(such as CPU time, memory, files, I/O devices) to
accomplish its task. When the process creates a sub process, that sub process may be able to
obtain its resources directly from the OS, or it may be controlled to a subset of the resources of the
parent process. The parent may have to partition its resources among its children, or it may be able
to share some resources(such as memory or files) among several of its children. Restricting a child
process to a subset of the parent’s resources prevent any process from overloading the system by
creating too many sub processes.
When a process is created it obtains along with the resources, initialization data (or input from the
file, say F1) that may be passed along from the parent process to the child process. It may also get
the name of the output device. New process may get two open files, F1 and the terminal device, and
may just need to transfer the datum between the two.
When a process creates a new process, two possibilities exist in terms of execution:
There are also two possibilities in terms of the address space of the new process:
In UNIX, each process is identified by its process identifier (PID) , which is a unique integer. A
new process is created by the fork system call. The new process consists of a copy of the address
space of the original process. which helps the parent process to communicate easily with its child
process. Both processes(the parent & the child) continue execution at the instruction after the fork
system call, with one difference: The return code for the fork system call is zero for the new(child)
process, whereas the (nonzero) process identifier of the child is returned to the parent.
Cooperating Processes:
A process is independent if it cannot affect or be affected by the other processes executing in the
system. On the other hand, a process is cooperating if it can affect or be affected by the other
processes executing in the system. Process cooperation is required for the following reasons:
(for instance, a shared file), we must provide an environment to allow concurrent access to
these types of resources.
subtasks, each of which will be executing in parallel with the others. Such a speedup can
be achieved only if the computer has multiple processing elements (such as CPUs or I/O
channels).
into separate processes or threads.
instance, a user may be editing, printing, and compiling in parallel.
Concurrent execution of cooperating processes requires mechanism that allow processes to
communicate with one another and to synchronize their actions.
Interprocess Communication: Direct & indirect communication, message passing,
synchronization, buffering.
Interprocess Communication: The OS provides the means for cooperating processes to
communicate with each other via an interprocess communication (IPC) facility.
IPC provides a mechanism to allow processes to communicate and to synchronize their actions
without sharing the same address space. IPC is particularly useful in a distributed environment where
the communicating processes may reside on different computers connected with a network e.g. chat
program used on the world wide web.
IPC is best provided by a message-passing system , and the message systems can be defined in
many ways.
Message-Passing System: Message system is to allow processes to communicate with one another
without the need to resort to shared data. Services are provided as ordinary user processes operate
outside the kernel. Communication among the user processes is accomplished through the passing
of messages. An IPC facility provides at least two operations: send(message) and receive(message).
Messages sent by a process can be of either fixed or variable size.
If processes P and Q want to communicate, they must send messages to and receive from each
other; a communication link must exist between them. There are several methods for logical
implementation of a link as follows:
Direct Communication: Each process that wants to communicate must explicitly name the
recipient or sender of the communication. The send and receive primitives are defied as:
A communication link in this scheme has the following properties:
communicate. The processes need to know only each other’s identity to communicate.
This scheme exhibits symmetry in addressing ; that is, both the sender and the receiver processes
must name the other to communicate. A variant of this scheme employs asymmetry in
addressing. Only the sender names the recipient; the recipient is not required to name the sender.
In this scheme, the send and receive primitives are as follows:
the name of the process with which communication has taken place.
The disadvantage in both schemes: Changing the name of a process may necessitate examining all
other process definitions. All references to the old name must be found, so that they can be modified
to the new name. This situation is not desirable from the viewpoint of separate compilation.
Indirect Communication: The messages are sent to and received from mailboxes , or ports.
Each mailbox has a unique identification. Two processes can communicate only if they share a
mailbox. The send and receive primitives are defined as follows:
In this scheme, a communication link has the following properties:
shared mailbox.
each link corresponding to one mailbox.
If processes P1, P 2 and P 3 all share mailbox A. Process P 1 sends a message to A, while P 2 and P 3
each execute a receive from A. Which process will receive the message depends upon the one of
the scheme that use choose as follows:
P 2 or P 3 , but not both, will receive the message). The system may identify the receiver to
the sender.
If the mailbox is owned by process(that is, the mailbox is part of the address space of the process),
then we distinguish between the owner(who can only receive messages through this mailbox) and
the user (who can only send messages to the mailbox). When a process that owns a mailbox
terminates, the mailbox disappears. Any process that subsequently sends a message to this mailbox
must be notified that the mailbox no longer exists.
On the other hand, a mailbox owned by the OS is independent and is not attached to any particular
process. The OS then must provide a mechanism that allows a process to do the following: