Os Notes
Os Notes
com
2010-2011
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
resources
to
processes
(Manage
www.eeecube.com
www.eeecube.com
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.
www.eeecube.com
www.eeecube.com
System Components
Process Management
A process is only ONE instant of a program in execution.
There are many processes can be running the same program.
The five major activities of an operating system in regard to process
management are:
Creation and deletion of user and system processes.
Suspension and resumption of processes.
A mechanism for process synchronization.
A mechanism for process communication.
A mechanism for deadlock handling.
www.eeecube.com
System Components
Main-Memory Management
Main-Memory is a large array of words or bytes. 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 major activities of an operating system in regard to memory-management
are:
Keep track of which part of memory are currently being used and by whom.
Decide which processes are loaded into memory when memory space
becomes available.
Allocate and deallocate memory space as needed.
www.eeecube.com
System Components
File Management
A file is a collected of related information defined by its
creator. Computer can store files on the disk (secondary
storage), which provide long term storage.
www.eeecube.com
System Components
I/O System Management
One of the purposes of an operating system is to hide the
peculiarities of specific hardware devices from the user.
Secondary-Storage Management
Generally speaking, systems have several levels of
storage, including primary storage, secondary storage and
cache storage. Instructions and data must be placed in primary
storage or cache to be referenced by a running program.
www.eeecube.com
System Components
Networking
A distributed system is a collection of processors that do not share
memory, peripheral devices, or a clock. The processors communicate with
one another through communication lines called network.
Protection System
Protection refers to mechanism for controlling the access of
programs, processes, or users to the resources defined by a computer
system.
www.eeecube.com
Program Execution
The system must be able to load a program into memory and to run
it. The program must be able to end its execution, either normally or
abnormally (indicating error).
I/O Operations
A running program may require I/O. This I/O may involve a file or an
I/O device.
File System Manipulation
The output of a program may need to be written into new files or
input taken from some files. The operating system provides this service.
Error Detection
An error is one part of the system may cause malfunctioning of the
complete system. To avoid such a situation the operating system constantly
monitors the system for detecting the errors.
www.eeecube.com
www.eeecube.com
www.eeecube.com
Process State
As a process executes, it changes state. The state of a
process is defined in part by the current activity of that
process. Each process may be in one of the following states:
www.eeecube.com
www.eeecube.com
www.eeecube.com
Basic Concepts
The idea of multiprogramming is relatively simple. A
process is executed until it must wait, typically for the
completion of some I/O request. In a simple computer system,
the CPU would then just sit idle.
Scheduling is a fundamental operating-system function.
Almost all computer resources are scheduled before use.
www.eeecube.com
Context Switch
To give each process on a multiprogrammed machine a
fair share of the CPU, a hardware clock generates interrupts
periodically.
This allows the operating system to schedule all processes
in main memory (using scheduling algorithm) to run on the
CPU at equal intervals. Each switch of the CPU from one
process to another is called a context switch.
www.eeecube.com
Preemptive Scheduling
CPU scheduling decisions may take place under the
following four circumstances:
1. When a process switches from the running state to the waiting state (for.
example, I/O request, or invocation of wait for the termination of one of
the child processes).
2. When a process switches from the running state to the ready state (for
example, when an interrupt occurs).
3. When a process switches from the waiting state to the ready state (for
example, completion of I/O).
4. When a process terminates.
www.eeecube.com
Dispatcher
Switching context.
Switching to user mode.
Jumping to the proper location in the user program to restart that program
Scheduling Criteria
www.eeecube.com
CPU utilization.
Throughput.
Turnaround time.
Waiting time.
Response time.
www.eeecube.com
www.eeecube.com
24
3
3
P1
P2
P3
P1
0
P2
24
27
P3
30
Shortest-Job-First Scheduling
P4
0
P1
9
Process
Burst Time
P1
P2
P3
P4
P3
P2
16
24
www.eeecube.com
www.eeecube.com
Priority Scheduling
Process
Burst Time
Priority
P1
P2
P3
P4
P5
10
1
2
1
5
3
1
3
4
2
P2
P5
P1
P3
P4
Round-Robin Scheduling
Process
Burst Time
P1
24
P2
P3
www.eeecube.com
www.eeecube.com
www.eeecube.com
Memory size
Process priority
Process type
Preemptive or
Non-preemptively
www.eeecube.com
6. Process Synchronization
A cooperating process is one that can affect or be
affected by the other processes executing in the
system.
Cooperating processes may either directly share a
logical address space(that is, both code and data), or
be allowed to share data only through files. The
former case is achieved through the use of
lightweight processes or threads. Concurrent access
to shared data may result in data inconsistency.
In this lecture, we discuss various mechanisms to
ensure the orderly execution of cooperating
processes that share a logical address space, so that
data consistency is maintained.
www.eeecube.com
Cooperating Processes
The concurrent processes executing in the operating
system may be either independent processes or
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.
www.eeecube.com
Computation speedup
Modularity
Convenience
www.eeecube.com
Race condition
When several processes access and
manipulate the same data concurrently and
the outcome of the execution depends on the
particular order in which the access takes
place, is called a race condition.
www.eeecube.com
www.eeecube.com
www.eeecube.com
DEADLOCKS
A process requests resources; if the resources are not
available at that time, the process enters a wait state. It may
happen that waiting processes will never again change state,
because the resources they have requested are held by other
waiting processes. This situation is called a deadlock.
In this lecture, we describe methods that an operating system
can use to deal with the deadlock problem.
www.eeecube.com
Resources
A process must request a resource before using it, and must
release the resource after using it.
A process may request as many resources as it requires to
carry out its designated task.
a process may utilize a resource in only the following
sequence:
Request
Use
Release
www.eeecube.com
Deadlock Characterization
In a deadlock, processes never finish executing and
system resources are tied up, preventing other jobs
from ever starting.
Before we discuss the various methods for dealing
with the deadlock problem, we shall describe
features that characterize deadlocks.
www.eeecube.com
Necessary Conditions
A deadlock situation can arise if the following four
conditions hold simultaneously in a system:
Mutual exclusion
Hold and wait
No preemption
Circular wait
www.eeecube.com
www.eeecube.com
Deadlock Prevention
By ensuring that at least one of these conditions cannot hold,
we can prevent the occurrence of a deadlock
Mutual Exclusion not required for sharable resources; must hold for
nonsharable resources.
Hold and Wait must guarantee that whenever a process requests a
resource, it does not hold any other resources.
No Preemption o If a process that is holding some resources requests
another resource that cannot be immediately allocated to it, then all
resources currently being held are released.
Circular Wait impose a total ordering of all resource types, and require
that each process requests resources in an increasing order of
enumeration.
www.eeecube.com
Deadlock Avoidance
Requires that the system has some additional a priori
information available.
Simplest and most useful model requires that each process declare
the maximum number of resources of each type that it may need.
The deadlock-avoidance algorithm dynamically examines the
resource-allocation state to ensure that there can never be a
circular-wait condition.
Resource-allocation state is defined by the number of available and
allocated resources, and the maximum demands of the processes.
www.eeecube.com
Deadlock Detection
If a system does not employ either a deadlock-prevention or a
deadlock avoidance algorithm, then a deadlock situation may
occur. In this environment, the system must provide:
An algorithm that examines the state of the system to
determine whether a deadlock has Occurred.
An algorithm to recover from the deadlock
www.eeecube.com
Memory Management
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
Virtual Memory
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
Protection
Domain of Protection
Security
cryPtograPhy
authentication
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com
www.eeecube.com