Docsity

Operating Systems and System Software, Summaries of Operating Systems

Toggle sidebar
bg1
OPERATING SYSTEMS
SYSTEM SOFTWARE
- Consists of programs designed to perform tasks associated with directly controlling and utilizing computer hardware.
It includes:
a) Operating systems
b) Computer Language Oriented software (Translator)
c) Utilities (Data Recovery programs, data conversion programs)
OPERATING SYSTEMS
Is a core set of programs that control and supervise the hardware of a computer and provide services to other system
software, application software, programmers and users of a computer.
It acts as an intermediary between users of computer hardware.
Abstract view of components of a computer system
N/B Operating system and computer architecture have had a great deal of influences on each other.
Classes of operating systems
They can be designed as:
a) Proprietary o/s designed for use by specific computer architecture. e.g. MS DOS, PC DOS that runs on IBM
and compatible computers using the Intel series of microprocessors.
b) Generic o/s designed for use by a wide variety of computer architectures e.g. UNIX that runs on both Intel and
Motorola Microprocessors
Parts of an operating System
i) Control Programs manage hardware and resources
Main program which is the Supervisor /Monitor / Executive/Kernel for controlling all other o/s programs
as well as other applications
Job Control Language is a portion of an o/s that allows a user to specify what a job requires in terms of
computer resources and o/s services. It is a users language of communication with an o/s e.g. commands
like DIR, ERASE.
ii) Services Programs external o/s programs that provide a service to the user or programmer of a computer
(perform routine but essential functions such as preparing a disk for use and copying files from one location to
another).
Operating System Capabilities (Types of o/s)
a) A particular o/s may incorporate one or more of these capabilities:
b) Single User processing only one user at a time to access a computer e.g. DOS
c) Multi-user processing allows 2 or more users to access a computer at the same time. Actual no of users depends on
the hardware and o/s design e.g. UNIX
d) Single Tasking allows one program to execute at a time and that program must finish executing before the next
program can begin e.g. DOS.
e) Context Switching allows several programs to reside in the memory but only one to be active at a time. Active
program is in the foreground and others in the background.
f) Multitasking / Multiprogramming allows single CPU to execute what appears to be more than one program at a
time. The CPU switches its attention between 2 or more programs in main memory as it receives requests for
processing from one program and the other. It happens so quickly that the programs appear to execute
simultaneously / executing concurrently.
User
System & Application Programs
Compiler, Assembler, Word Processing, Database systems, Spread Sheets
Operating system
Computer Hardware
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

Download Operating Systems and System Software and more Summaries Operating Systems in PDF only on Docsity!

OPERATING SYSTEMS

SYSTEM SOFTWARE

  • Consists of programs designed to perform tasks associated with directly controlling and utilizing computer hardware. It includes: a) Operating systems b) Computer Language Oriented software (Translator) c) Utilities (Data Recovery programs, data conversion programs) OPERATING SYSTEMS Is a core set of programs that control and supervise the hardware of a computer and provide services to other system software, application software, programmers and users of a computer. It acts as an intermediary between users of computer hardware.

Abstract view of components of a computer system

N/B –Operating system and computer architecture have had a great deal of influences on each other.

Classes of operating systems They can be designed as: a) Proprietary o/s designed for use by specific computer architecture. e.g. MS DOS, PC DOS that runs on IBM– and compatible computers using the Intel series of microprocessors. b) Generic o/s designed for use by a wide variety of computer architectures e.g. UNIX that runs on both Intel and– Motorola Microprocessors

Parts of an operating System i) Control Programs manage hardware and resources–  Main program which is the Supervisor /Monitor / Executive/Kernel for controlling all other o/s programs as well as other applications  Job Control Language is a portion of an o/s that allows a user to specify what a job requires in terms of– computer resources and o/s services. It is a users language of communication with an o/s e.g. commands’ like DIR, ERASE. ii) Services Programs external o/s programs that provide a service to the user or programmer of a computer– (perform routine but essential functions such as preparing a disk for use and copying files from one location to another).

Operating System Capabilities (Types of o/s) “ ” a) A particular o/s may incorporate one or more of these capabilities: b) Single User processing only one user at a time to access a computer e.g. DOS– c) Multi-user processing allows 2 or more users to access a computer at the same time. Actual no of users depends on– the hardware and o/s design e.g. UNIX d) Single Tasking allows one program to execute at a time and that program must finish executing before the next– program can begin e.g. DOS. e) Context Switching allows several programs to reside in the memory but only one to be active at a time. Active– program is in the foreground and others in the background. f) Multitasking / Multiprogramming allows single CPU to execute what appears to be more than one program at a– time. The CPU switches its attention between 2 or more programs in main memory as it receives requests for processing from one program and the other. It happens so quickly that the programs appear to execute simultaneously / executing concurrently.

User System & Application Programs Compiler, Assembler, Word Processing, Database systems, Spread Sheets Operating system

Computer Hardware

g) Multiprocessing / Parallel processing allows the simultaneous or parallel execution of programs by a computer– that has 2 or more CPUs’ h) Multithreading support several simultaneous functions with the same application.– i) Inter-processing / Dynamic linking allows any change made in one application to be automatically reflected in– any related linked applications e.g. a link between word processing and financial applications (linked together). j) Time sharing allows multiple users to access a single computer found on a large computer o/s where many users– need access at the same time. k) Virtual storage o/s with the capability of virtual storage called virtual memory, allows you to use a secondary– storage device as an extension of main memory. l) Real Time Processing allows a computer to control or to monitor the task performances of other machines and– people by responding to input data in a specified amount of time. To control processes immediate response is usually necessary. m) Virtual Machine (VM) Processing creates the illusion that there is more than one physical machine when in fact– there is only one. Such programming allows several users of a computer to operate as if each had the only terminal attached to the computer. Thus, users feel as if each is on a dedicated computer and has sole use of the CPU and I/O devices. When a VM operating system is loaded, each user chooses the o/s that is compatible with his or her intended application program to the VM o/s. Thus the V/M o/s gives users flexibility and allows them to choose o/s that best suits their needs.

Operating system functions a) Process Management b) Main Memory Management c) File / Secondary storage Management d) Input /Output (Device) System management e) Protection System (Security)

ASSIGNMENT ONE

  1. Explain the following terms as used by operating systems a) Kernel b) Interrupt
  2. Explain briefly System calls and outline major categories that they may be grouped.

Example is UNIX which had a simple layered structure consisting of:  System programs  The kernel i) Consists of everything below the system-call interface and above the physical hardware ii) Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level

c) Modules Most modern operating systems implement kernel modules. It uses object-oriented approach. Each core component is separate and each talks to the others over known interfaces. Each is loadable as needed within the kernel. Overall it is similar to layers but with more flexible

Solaris Modular approach

e) Virtual Machines A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware. A virtual machine provides an interface identical to the underlying bare hardware. The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory. The resources of the physical computer are shared to create the virtual machines. CPU scheduling can create the appearance that users have their own processor. Spooling and a file system can provide virtual card readers and virtual line printers. A normal user time-sharing terminal serves as the virtual machine operators console’

(a) Non virtual machine (b) virtual machine The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources. A virtual-machine system is a perfect vehicle for operating-systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation. The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine. Example is LINUX implementation. The technique is also implemented in the Java Virtual Machine.

f) Exokernels Gives each user a clone of actual computer, but with a subset of resources. Thus one Virtual Machine might get disk blocks 0 to 1023, the next one might get block 1024 to 2047 and so on. At bottom layer a kernel mode program runs (exokernel) which allocates resources to V.M and monitors utilization.

g) Client-Server Model / Microkernel System Structure

PROCESS MANAGEMENT

A process can be thought as a program in execution. It needs certain resources including CPU time, memory, file and I/O devices to accomplish its task.

The o/s is responsible for the following activities in connection with process management:  Creation and deletion of both user and system processes  Suspension and resumption of processes  Provision of mechanism for process synchronization  Provision of mechanism for process communication  Provision for mechanism for deadlock handling.

Process Model A process is more than a program. It includes current activity temporary data containing global value. A program is a passive entity e.g. contents of a file stored on disk where as a process is an entity. 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. It states may be: i) New process is being created– ii) Running Instructions are being executed– iii) Waiting process waiting for some event to occur.– iv) Ready waiting to be assigned to a processor– v) Terminated finished execution.–

Diagram of process state

Error: Reference source not found

INTER-PROCESS COMMUNICATION O/s must provide inter-process communication facility (IPC) which provides a mechanism to allow processes to communicate and to synchronize their actions to prevent Race conditions (a condition where 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).

To guard against this mechanisms are necessary to ensure that only one process at a time can be manipulating the data. Some of this mechanisms / techniques include:

Critical Section Problem. It is a segment of code in which a process may be changing common variables, updating a table, writing a file etc. Each process has its critical section while the other portion is referred to as Reminder section.

The important feature of the system is that when one has process is executing in its critical section no other process is to be allowed to execute its critical section. Each process must request permission to enter its critical section. A solution to critical section problem must satisfy the following: i) Mutual Exclusion If one process is executing its critical section then no other process can be executing in their– critical section. ii) Progress If no process is executing in its critical section and there exists some processes that wish to enter– critical sections then those processes that are not executing in their remainder section can be allowed. i) Bounded Waiting There must exist 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 (Prevents Bus waiting). Busy waiting occurs when one process is being executed in its critical section and process 2 tests to confirm if process 1 is through. It is only acceptable technique when the anticipated waits are brief; otherwise it could waste CPU cycles.

Techniques used to handle Critical section problem

1. Semaphores The fundamental principle is this: 2 or more processes can operate by means of simple signals, such that a process can be forced to stop at a specified place until it has received a special signal. Any complex coordinative requirement can be satisfied by the appropriate structure of signals. For signaling special variables called semaphores are used: To transmit a signal via semaphores, a process executes the primitive wait P(s); if the corresponding signal V(s) has not yet been transmitted the process is suspended until transmission takes place.

To achieve the desired effect we can view the semaphore as a variable that has an integer value upon which 3 operations are defined a) A semaphore may be initialized to a non-negative value b) The wait operation decrements these semaphore value. If the value becomes negative the process executing the wait is blocked. c) The signal operation increments the semaphore value. If the value is not positive then a process is blocked by await operation is unblocked A binary semaphore accepts only 2 values 0 or 1. For both semaphore and binary semaphore a queue is used to hold processes waiting on the semaphore. A strong semaphore has a mechanism of removing processes from a queue e.g. FIFO policy. A weak semaphore doesnt specify the order in which processes are removed from the queue.’ Example of implementation: Wait (S); Critical Section Signal (S);

2. Message passing Provides a means for co-operating processes to communicate when they are not using shared memory environment. Processes generally send and receive messages by using system calls such as: send (receiverprocess; message) or Receive (senderprocess; message).

A blocking send must wait for receiver to receive the message. A non-blocking send enables the sender to continue with other processing even if the receiver has not yet received the message. This requires buffering mechanisms to hold messages until the receiver receives it. Message passing can be flawless on some computers but in a distributed system it can be flawed or even lost, thus acknowledgement protocols are used.

One complication in distributed systems with send / receive message passing is in naming processes unambiguously so that send and receive calls references the proper process. Process creation and destruction can be coordinated through some centralized naming mechanisms but this can introduce considerable transmission overhead as individual machines request permission to use new names.

d) When a process terminates.

Scheduling scheme can either be: (i) Non pre-emptive process keeps CPU until when it release it (conditions 1 and 4)– (ii) Pre-emptive CPU can be taken from a process when it is midst of updating or processing data by another– process (conditions 2 and 3) Operating system has many schedulers but the three main schedulers are  LONG-TERM SCHEDULER This scheduler is responsible for selecting the process from secondary storage device like a disk and loads them into the main memory for execution. At is also known as a job scheduler. The primary objective of long-term scheduler is to provide a balance of mix of job to increase the number of processes in a ready queue. Long term scheduler provide a good performance by selecting processes with a combination of I/O and CPU bound type. Long-term scheduler selects the jobs from the batch-queue and loads them into the memory. In memory, these processes belong to ready queue.  SHORT-TERM SCHEDULER It allocates processes belonging to ready queue to CPU for immediate processing. Its main Objective is to maximize CPU utilization. This scheduler has to work more frequently and faster since it must select a new process quite often because CPU executes a process only for a few milliseconds before it goes for I/O operation.  MEDIUM-TERM Many a times, we need to remove a process from the main memory as this process may be in need of some I/O operation. So, such processes may be removed ( or suspended) from the main memory to the hard disk. Later on, these processes can be reloaded into the main memory and continued from where it was left earlier. This saving of suspended process is said to be rolled-out. And this swapping (in and out) is done by the medium-term scheduler. CPU dispatcher –a module that gives control of CPU to the process selected by the scheduler. Functions include: (i) Switching context (ii) Switching to user mode (iii) Jumping to proper location in the user program to restart that program.

Scheduling levels Three important levels of scheduling are considered. a) High level scheduling (Job Scheduling) determines which jobs should be allowed to compete actively for the– resources of the system. Also called Admission Scheduling. Once admitted jobs become processes or groups of processes. b) Intermediate level scheduling determines which processes shall be allowed to compete for the CPU.– c) Low level scheduling determines which ready process will be assigned the CPU when it next becomes– available and actual assigns the CPU to this process.

Different CPU scheduling algorithms are available, thus in determining which the best is for a particular situation many criteria have been suggested that can be used to compare them. They include: (i) CPU utilization keeps the CPU as busy as possible.– (ii) Throughput measure of work i.e. no of processes that are completed per time unit.– (iii) Turn around time The interval from time of submission to time of completion. It is sum of periods spent– waiting to get into memory, waiting in the ready queue, executing in CPU and doing I/O. (iv) Waiting Time Sum of periods spent waiting in ready queue.– (v) Response time Measure of time from submission of a request by user until the first response is produced. It is– amount of time it takes to start responding but not time that it takes to output that response. (vi) I/O Bounded-ness of a process when a process gets the CPU, does it use the CPU only briefly before– generating an I/O request? (vii) CPU Bounded-ness of a process when a process gets the CPU does it tend to use the CPU until its time– quantum expires.

Scheduling Algorithms

1. First Come First Served (FCFS) / First In First Out (FIFO) Scheduling Process that request CPU first is allocated the CPU first. Code for FCFS is simple to write and understand. Average waiting time under FCFS is often quite long. FCFS is non-preemptive discipline (once a process has the CPU it runs to completion).

Example Processes arrive at time o, with length of the CPU-burst time given in milliseconds. Process Burst Time (Time of CPU use) P1 24 P2 3 P3 3

If processes arrive in order P1, P2, P3; Using a Gantt chart.

Average waiting Time = (0 + 24 +27) / 3 = 17 ms

If processes arrive in order P2, P3, P

Average waiting Time = (0 + 3 + 6) / 3 = 3 ms

Thus Average waiting time under FCFS policy is generally not minimal and may vary substantially if processes CPU- Burst times vary greatly. FCFS algorithm is particularly troublesome for time sharing systems.

2. Shortest Job First (SJF) Scheduling When the CPU is available it is assigned to the process that has the smallest next CPU burst. If 2 processes have the same length next CPU Burst, FCFS scheduling is used to break the tie. It reduces Average waiting time as compared to FCFS. Example Process Burst Time (ms) P1 6 P2 8 P3 7 P4 3

Gantt chart for SJF:

Average waiting Time = (0 + 3 + 16 + 9) / 4 = 7 ms

Real difficulty of SJF is knowing the next CPU request and this information is not usually available. NB: SJF is non- preemptive in nature.

3. Shortest Remaining Tine (SRT) Scheduling It is the preemptive counterpart of SJF and is useful in time sharing. Currently executing process is preempted when a process with a short CPU burst is ready in a queue. Example Process Arrival Time Burst Time (ms) P1 0 8 P2 1 4 P3 2 9 P4 3 5

Gantt chart

P1 P2 P 0 24 27 30

P2 P3 P 0 3 6 30

P4 P1 P 0 3 9 16

P 24

Processes are permanently assigned to one queue generally based on some property of the process such as memory size, process priority or process type. Each queue has its own scheduling algorithm e.g. foreground -> RR, Background ->FCFS. In addition there must be scheduling between the queues which is commonly implemented as a fixed priority scheduling e.g. fore ground queue may have priority over back ground queue.

7. Multi-level Feedback queue scheduling Allows a process to move between queues. The idea is to separate processes with different CPU burst characteristic. If a process uses too much CPU time it will be moved to a lower priority queue. This scheme leaves I/O bound and interactive processes in the highest priority queues. Similarly a process that waits too long in a lower priority queue may be moved to a higher priority queue. This form of aging prevents starvation.

Exercises

  1. Consider the following set of processes, with the length of CPU burst time given in milliseconds. Process Burst Time Priority P1 10 3 P2 1 1 P3 2 3 P4 1 4 P5 5 2

The processes are assumed to have arrived in the order P1, P2, P3, P4, and P5 all at time 0. Draw for Gantt charts illustrating the execution of these processes using FCFS, SJF, Priority (1 is lowest priority) and RR (quantum = 1ms) scheduling. Calculate average waiting time for each algorithm.

  1. Assume that we have the workload shown. All 5 processes arrive at time 0 in order given with the length f burst time given in ms. Process Burst Time P1 10 P2 29 P3 3 P4 7 P5 12 Consider FCFS, SJF and RR (quantum = 10ms) scheduling algorithms for this set of processes, which algorithm would give the minimum average waiting time.

DEADLOCKS

Occurs when several processes compete for a finite number of resources i.e. a process is waiting for a particular event that will not occur. The event here may be resource acquisition and release.

Example of Deadlocks

  1. A traffic deadlock vehicles in a busy section of the city.–
  1. A simple resource Deadlock

This system is deadlocked because each process holds a resource being requested by the other process and neither process is willing to release the resource it holds. (Leads to deadly embrace).

  1. Deadlock in spooling systems A spooling system is used to improve system throughput by disassociating, a program from the slow operating speeds of devices such as printers e.g. lines of text are sent to a disk before printing starts. If disk space is small and jobs are many a dead lock may occur. Deadlocks Characterization Four necessary conditions for deadlock to exist:
  2. Mutual Exclusion condition a process claims exclusive control of resources they require.–
  3. Wait for Condition (Hold and Wait) Processes hold resources already allocated to them while waiting for– additional resources.
  4. No preemption condition resources cannot be removed from the processes holding them until the resources are– used to completion.
  5. Circular wait condition A circular chain of processes exists in which each process holds one or more resources that– are requested by the next process in the chain

MAJOR AREAS OF DEADLOCK RESEARCH IN COMPUTER SCIENCE a) Deadlock Detection b) Deadlock Recovery c) Deadlock Prevention d) Deadlock Avoidance

DEADLOCK DETECTION This is the process of actually determining that a deadlock exists and of identifying the processes involved in the deadlock. (i.e. determine if a circular wait exists). To facilitate detection of deadlocks resource allocation graphs are used which indicate resource allocation and requests. This graphs change as process request resources, acquire them and eventually release them to the o/s. Reduction of Resource Allocation Graphs IS a technique useful for detecting deadlocks i.e. processes that may complete their execution and the processes that will remain deadlocked are determined. If a processs resource request’ may be granted then we say that a graph may be reduced by that process (arrows connecting process and resource is removed). If a graph can be reduced by all its processes then the irreducible processes constitute the set of deadlocked processes in the graph. NB: - the order in which the graph reductions are performed does not matter; the final result will always be the same.

R

R

P P

Held by^ Requests

Requests Held by

There are 2 options for breaking a deadlock:

  1. Process termination killing some processes– Methods available include: a) Abort all deadlocked processes has a great expense– b) Abort one process at a time until the deadlock cycle is eliminated. A scheduling algorithm may be necessary to identify the process to abort. Factors that may determine which process is chosen;  Priority of the process  Time spent and time remaining  Number and type of resources the process has used (is it simple to preempt)  No of resources it need to complete  Is the process interactive or batch.
  2. Resource Preemption Preempts some resources from processes and give these resources to other processes until the deadlock cycle is broken. Issues to be addressed include:-  Selecting a victim i.e. a resource to preempt.  Roll Back a process that is preempted a resource needs to be rolled back to some safe state and restarted from– that state once the deadlock is over.  Starvation guarantee that resources will not always be preempted from some process.–

DEADLOCK PREVENTION Aims at getting rid of conditions that cause deadlock. Methods used include: a) Denying Mutual exclusion should only be allowed or non-shareable resources. For shareable resources– e.g. read only files the processes attempting to open it should be granted simultaneous access. Thus for’ shareable we do not allow mutual exclusion. b) Denying Hold and wait (wait for condition) To deny this we must guarantee that whenever a process– requests a resource it does not hold any other resources. Protocols used include: i) Requires each process to request and be allocated all its resources before it begins execution. While waiting for resources to be available it should not hold any resource may lead to serious– waste or resources. ii) A process only requests for a resource when it has none or it has to release all resources before getting a resource. Disadvantages of these protocols  Resource utilization is low since many of the resources may be allocated but unused for a long period.  Starvation is possible A process that needs several popular resources may have to wait– indefinitely because at least one of the resources that it needs is always allocated to some other process. c) Denying No preemption“ ” If a process that is holding some resource requests another resource that cannot be immediately allocated to it (i.e. it must wait) then all resources currently being held are preempted. The process will be started only when it can regain its old resources as well as the new ones that it is requesting.

d) Denying Circular wait All resources are uniquely numbered and processes must request resources in linear ascending order. It has been implemented in many o/s but has some difficulties i.e.

  • Addition of new resources required rewriting of existing program so as to give the unique numbers.
  • Jobs requiring resources in a different order from that one implemented by o/s; it required resources to be acquired and held possibly long before they are actually used (leads to waste)
  • Affects a users ability to freely and easily write applications code.’

DEADLOCK AVOIDANCE

The famous deadlock avoidance is Dijkstras Bankers Algorithm. Its goal is to improve less stringent (constraining)’ conditions than in deadlock prevention in an attempt to get better resource utilization. Avoidance does not precondition the system to remove all possibility of deadlock to loom, but whenever a deadlock is approached it is carefully sidestepped. NB: used for same type of resources e.g. tape drives or printers.

Dijkstras Bankers Algorithm says allocation of a resource is only done when it results in a safe state rather than in’ unsafe states. A safe state is only in which the total resource situation is such that all users would eventually be able to finish. An unsafe state is one that might eventually lead to a deadlock. Example of a safe state Assume a system with 12 equivalent tape drives and 3 users sharing the drives: State I Users Current Loan

Maximum Need User(1) 1 4 User(2) 4 6 User(3) 5 8 Available 2 The state is safe because it is still possible for all 3 users to finish i.e. the remaining 2 drives may be given to users(2)‘ ’ who may run to completion after which six tapes would be released for user(1) and user(3). Thus the key to a state being safe is that there is at least one way for all user to finish. Example of an unsafe state State II

Users Current Loan

Maximum Need User(1) 8 10 User(2) 2 5 User(3) 1 3 Available 1

A 3-way deadlock could occur if indeed each process needs to request at least one more drive before releasing any drives to the pool. NB: An unsafe state does not imply the existence of a deadlock of a deadlock. What an unsafe state does imply is simply that some an unfortunate of events might lead to a deadlock.

Example of safe state to unsafe state transition State III (Safe)

Users Current Loan

Maximum Need User(1) 1 4 User(2) 4 6 User(3) 5 8 Available 2 If User (3) requests an additional resource

State IV (Unsafe)

Users Current Loan

Maximum Need User(1) 1 4 User(2) 4 6 User(3) 6 8 Available 1

Therefore State IV is not necessarily deadlocked but the state has gone from a safe one to an unsafe one.

MEMORY MANAGEMENT

It is necessary in order to improve both utilization of the CPU and the speed of computers response to its users.’ Memory allocation techniques

1. Paging Main memory (physical memory) is broken into fixed blocks called frames. The processes (logical memory) are also broken into blocks of same size called pages. When a process is executed its pages are loaded into any available memory frames from the backing storage. Allocations of frames to processes are monitored by Free-frame list and page table. Example

Advantages  Minimize fragmentation Disadvantages  Page mapping hardware may lead to high cost of computer  Memory used to store various tables may be big  Some memory may remain unused if it is not sufficient for a frame.

2. Segmentation Processes are divided into variable sized segments determined by sizes of processs program, sub-routines, data’ structures e.t.c A segment is a logical grouping of information such as a routine, an array or data area that are determined by programmer. Each has a name and a length. Example: Users view of a program ’

Advantages  Eliminates internal fragmentation  Allows dynamic growth of segments  Facilitates the loading of only one copy of shared routines.

Before Allocation Free frame List 14 13 18 20 15

New Process

Page 0 Page 1 Page 2 Page 3

131415161 718192021

After Allocation Free frame List

New Process

Page 0 Page 1 Page 2 Page 3

Pg 0Pg 115161 7Pg 219Pg 321

New process page table Page Frame No 14 13 18 20

Logical Address space (Program in backing store)

Subroutine Stack

Sqrt

Symbol Table

Main Program

Segment 0

Segment 3

Segment 4

Segment 1 Segment 2

LimitBase 100014 004006300110032 0010004700Segm ent Table

Sgmt 0Sgmt 3Sgmt 2Sgmt 4Sgmt 1 Main Memory

1400 2400

3200 4300 4700

5700 6300 6700

Disadvantages  Considerable compaction overheads incurred in order to support dynamic growth and eliminate fragmentation.  Maximum segment size is limited to the size of main memory  Can cause external fragmentation when all blocks of free memory are too small to accommodate a segment.

3. Partitioned Allocation Ensures the main memory accommodates both o/s and the various user processes i.e. memory is divided into 2 partitions one for resident o/s and one for user processes. It protects o/s code and data from changes (accidental or malicious) by user processes. The o/s takes into account the memory requirements of each process and amount of available memory space in determining which processes are allocated memory. Example

Job Queue Process Memory Time P1 600 K 10 P2 1000 K 5 P3 300 K 20 P4 700 K 8 P5 500 K 15

OS

2160 K

0 400 K

2560 K

OS P

P P

0

400 K

1000K

2000K

2300K

2560K

OS P

P

0

400 K

1000K

2000K

2300K

2560K

OS P

P P

0

400 K

1000K

1700K 2000K

2300K

2560K

OS P

P P

0

400 K

1000K

1700K 2000K

2300K

2560K

OSP

P P

0

400 K

900 K

1000K

1700K 2000K

2300K

2560K

P Terminates

P Allocated

P Terminates

P Allocated