Вы находитесь на странице: 1из 34

Answer ALL questions

PART A - (10 X 2 = 20 Marks)


1. List down the functions of operating systems
2. What do you mean by multiprogramming?
3. What do you mean by short term scheduler?
4. What is a deadlock?
5. What is address binding?
6. What do you mean by page fault?
7. What is a file? List some operations on it.
8. What are the various file accessing methods?
9. What is rotational latency?
10. What is a swap space?

PART B- (5 X 16 = 80 Marks)

11. (a) (i) Explain how hardware protection can be achieved and discuss in detail the dual mode of
operations. (8 Marks)
(ii) Explain in detail any two operating system structures. (8 Marks)
(Or)
(b) What is meant by a process? Explain states of process with neat sketch and discuss the process state
transition with a neat diagram. (16 Marks)

12. (a) What is a critical section? Give examples. What are the minimum requirements that should be
satisfied by a solution to critical section problem? Write Peterson Algorithm for 2-process
synchronization to critical section problem and discuss briefly. (16 Marks)
(Or)
(b) Allocation Maximum Available
abcdabcdabcd
p0 0 0 1 2 0 0 1 2 1 5 2 0
p1 1 0 0 0 1 7 5 0
p2 1 3 5 4 2 3 5 6
p3 0 6 3 2 0 6 5 2
p4 0 0 1 4 0 6 5 6

Answer the following


(i) What is the content of the need matrix?
(ii) Is the system in a safe state?
(iii) If the request for process p1 arrives for (0,4,2,0) can it be granted immediately. (16 Marks)

13. (a) Given memory partition of 100 KB, 500 KB, 200 KB and 600 KB (in order). Show with neat
sketch how would each of the first-fit , best-fit and worst-fit algorithms place processes of 412 KB, 317
KB, 112 KB and 326 KB(in order). Which algorithm is most efficient in memory allocation? (16 Marks)
(Or)
(b) Explain the concept of demand paging. How can demand paging be implemented with virtual
memory? (16 Marks)

14. (a) (i) Explain various file allocation methods in detail. (8 Marks)
(ii) What are the possible structures for directory? Discuss them in detail. (8 Marks)
(Or)
(b) Explain in detail the free space management with neat diagram. (16 Marks)

15. (a) Explain in detail various disk scheduling algorithms with suitable example. (16 Marks)
(Or)
(b) Write short notes on the following :
(i) I/O Hardware (8 Marks)
(ii) RAID structure. (8 Marks)

MODEL EXAM QUESTION ANSWER KEY

1. List down the functions of operating systems


1.Program execution 2. I/O operation 3. File system manipulation 4. Error detection 5.Resource
allocation

2. What do you mean by multiprogramming?

Executing multiple programs simultaneously

3. What do you mean by short term scheduler?


Short term scheduler selects which process should be executed next and allocates CPU.

4. What is a deadlock?

A process requests resources; if the resources are not available at that time, the process
enters a wait state. Waiting processes may never again change state, because the resources they
have requested are held by other waiting processes. This situation is called a deadlock.

5. What is address binding?

Binding logical address with physical address is called as address binding,


6. What do you mean by page fault?

If the process tries to access a page that was not brought into memory causes page fault.

7. What is a file? List some operations on it.

File: Collection of Records. File Operations: Open,close,Read, write.


8. What are the various file accessing methods?

1.Sequential file access 2. Random file access 3. Indexed sequential file access.
9. What is rotational latency?

Rotational latency: the amount of time for the desired sector of a disk to rotate under the read/write
heads of the disk drive.

10. What is a swap space?

It is the storage put separately on disks.

PART B- (5 X 16 = 80 Marks)

11. (a) (i) Explain how hardware protection can be achieved and discuss in detail the dual mode of
operations. (8 Marks)
(ii) Explain in detail any two operating system structures. (8 Marks)
Sharing system resources requires operating system to ensurethat an incorrect program cannot
cause other programs to execute incorrectly.Provide hardware support to differentiate between at least
twomodes of operations.
1. User mode – execution done on behalf of a user.
2. Monitor mode (also supervisor mode or system mode) –
execution done on behalf of operating system

Dual-Mode Operation (Cont.)


_ Mode bit added to computer hardware to indicate the currentmode: monitor (0) or user (1).
_ When an interrupt or fault occurs hardware switches to monitor modemonitor user interrupt/fault
set user mode_ Privileged instructions can be issued only in monitor mode

I/O Protection
_ All I/O instructions are privileged instructions. Must ensure that a user program could never gain
control of the computer in monitor mode (i.e., a user program that, as part of its execution, stores a new
address in the interruptvector).
Memory Protection
Must provide memory protection at least for the interrupt vectorand the interrupt service routines.
In order to have memory protection, add two registers that determine the range of legal addresses a
program may access:base register – holds the smallest legal physical memory
address. limit register – contains the size of the range.Memory outside the defined range is protected.
Operating

OPERATING SYSTEM STRUCTURE:

Process Management

The operating system manages many kinds of activities ranging from user programs to system
programs like printer spooler, name servers, file server etc. Each of these activities is
encapsulated in a process. A process includes the complete execution context (code, data, PC,
registers, OS resources in use etc.).

It is important to note that a process is not a program. 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.

Main-Memory Management

Primary-Memory or Main-Memory is a large array of words or bytes. Each word or byte has its
own address. Main-memory provides storage that can be access directly by the CPU. That is to
say for a program to be executed, it must in the main memory.

The major activities of an operating in regard to memory-management are:

 Keep track of which part of memory are currently being used and by whom.
 Decide which process are loaded into memory when memory space becomes available.
 Allocate and deallocate memory space as needed.
(b) What is meant by a process? Explain states of process with neat sketch and
discuss the process state transition with a neat diagram. (16 Marks)
Definition

The term "process" was first used by the designers of the MULTICS in 1960's. Since then, the
term process, used somewhat interchangeably with 'task' or 'job'. The process has been given
many definitions for instance

 A program in Execution.
 An asynchronous activity.
 The 'animated sprit' of a procedure in execution.
 The entity to which processors are assigned.
 The 'dispatchable' unit.

A process goes through a series of discrete process states.

 New State: The process being created.


 Running State: A process is said to be running if it has the CPU, that is, process actually
using the CPU at that particular instant.
 Blocked (or waiting) State: A process is said to be blocked if it is waiting for some
event to happen such that as an I/O completion before it can proceed. Note that a process
is unable to run until some external event happens.
 Ready State: A process is said to be ready if it use a CPU if one were available. A ready
state process is runable but temporarily stopped running to let another process run.
 Terminated state: The process has finished execution

Process State Transitions

Following are six(6) possible transitions among above mentioned five (5) states

FIGURE

 Transition 1 occurs when process discovers that it cannot continue. If running process initiates
an I/O operation before its allotted time expires, the running process voluntarily relinquishes the
CPU.

This state transition is:


        Block (process-name): Running → Block.
 
 Transition 2 occurs when the scheduler decides that the running process has run long enough and
it is time to let another process have CPU time.

This state transition is:


   
Time-Run-Out  (process-name): Running → Ready.
 
 Transition 3 occurs when all other processes have had their share and it is time for the first
process to run again

This state transition is:

    Dispatch (process-name): Ready → Running.


 
 Transition 4 occurs when the external event for which a process was waiting (such as arrival of
input) happens.

This state transition is:

    Wakeup (process-name): Blocked → Ready.


 
 Transition 5 occurs when the process is created.

This state transition is:

    Admitted (process-name): New → Ready.


 
 Transition 6 occurs when the process has finished execution.

This state transition is:

    Exit (process-name): Running → Terminated.

PROCESS CONTROL BLOCK:

A process in an operating system is represented by a data structure known as a process control


block (PCB) or process descriptor. The PCB contains important information about the specific
process including

 The current state of the process i.e., whether it is ready, running, waiting, or whatever.
 Unique identification of the process in order to track "which is which" information.
 A pointer to parent process.
 Similarly, a pointer to child process (if it exists).
 The priority of process (a part of CPU scheduling information).
 Pointers to locate memory of processes.
 A register save area.
 The processor it is running on.

The PCB is a certain store that allows the operating systems to locate key information about a
process. Thus, the PCB is the data structure that defines a process to the operating systems.

12. (a) What is a critical section? Give examples. What are the minimum
requirements that should be
satisfied by a solution to critical section problem? Write Peterson Algorithm for
2-process
synchronization to critical section problem and discuss briefly. (16 Marks)
Mutual exclusion with busy waiting

The operating system can choose not to preempt itself. That is, no preemption for system
processes (if the OS is client server) or for processes running in system mode (if the OS is self
service). Forbidding preemption for system processes would prevent the problem above where
x<--x+1 not being atomic crashed the printer spooler if the spooler is part of the OS.

But simply forbidding preemption while in system mode is not sufficient.

 Does not work for user-mode programs. So the Unix printer spooler would not be helped.

 Does not prevent conflicts between the main line OS and interrupt handlers.

o This conflict could be prevented by disabling interrupts while the main line is in its
critical section.

o Indeed, disabling (a.k.a. blocking) interrupts is often done for exactly this reason.

o Do not want to block interrupts for too long or the system will seem unresponsive.

 Does not work if the system has several processors.

o Both main lines can conflict.

o One processor cannot block interrupts on the other.

Software solutions for two processes

Initially P1wants=P2wants=false

Code for P1 Code for P2

Loop forever { Loop forever {

P1wants <-- true ENTRY P2wants <-- true


while (P2wants) {} ENTRY while (P1wants) {}

critical-section critical-section

P1wants <-- false EXIT P2wants <-- false

non-critical-section } non-critical-section }

Explain why this works.

But it is wrong! Why?

Let's try again. The trouble was that setting want before the loop permitted us to get stuck. We
had them in the wrong order!

Initially P1wants=P2wants=false

Code for P1 Code for P2

Loop forever { Loop forever {

while (P2wants) {} ENTRY while (P1wants) {}

P1wants <-- true ENTRY P2wants <-- true

critical-section critical-section

P1wants <-- false EXIT P2wants <-- false

non-critical-section } non-critical-section }

Explain why this works.

But it is wrong again! Why?

So let's be polite and really take turns. None of this wanting stuff.

Initially turn=1

Code for P1 Code for P2

Loop forever { Loop forever {

while (turn = 2) {} while (turn = 1) {}


critical-section critical-section

turn <-- 2 turn <-- 1

non-critical-section } non-critical-section }

This one forces alternation, so is not general enough. Specifically, it does not satisfy condition
three, which requires that no process in its non-critical section can stop another process from
entering its critical section. With alternation, if one process is in its non-critical section (NCS)
then the other can enter the CS once but not again.

In fact, it took years (way back when) to find a correct solution. Many earlier ``solutions'' were
found and several were published, but all were wrong. The first true solution was found by
Dekker. It is very clever, but I am skipping it (I cover it when I teach G22.2251). Subsequently,
algorithms with better fairness properties were found (e.g., no task has to wait for another task to
enter the CS twice).

What follows is Peterson's solution. When it was published, it was a surprise to see such a simple
soluntion. In fact Peterson gave a solution for any number of processes. A proof that the
algorithm for any number of processes satisfies our properties (including a strong fairness
condition) can be found in Operating Systems Review Jan 1990, pp. 18-22.

Initially P1wants=P2wants=false and turn=1

Code for P1 Code for P2

Loop forever { Loop forever {

P1wants <-- true P2wants <-- true

turn <-- 2 turn <-- 1

while (P2wants and turn=2) {} while (P1wants and turn=1) {}

critical-section critical-section

P1wants <-- false P2wants <-- false

non-critical-section non-critical-section

Hardware assist (test and set)

TAS(b), where b is a binary variable, ATOMICALLY sets b<--true and returns the OLD value of b.
Of course it would be silly to return the new value of b since we know the new value is true.

Now implementing a critical section for any number of processes is trivial.


loop forever {

while (TAS(s)) {} ENTRY

CS

s<--false EXIT

NCS

P and V and Semaphores

Note: We will only do busy waiting, which is easier. Some authors use the term semaphore only
for blocking solutions and would call our solutions spin locks.

End of Note.

Difference between busy waiting and blocking.

The entry code is often called P and the exit code V (Tanenbaum only uses P and V for blocking,
but we use it for busy waiting). So the critical section problem is to write P and V so that

loop forever

critical-section

non-critical-section

satisfies

1. Mutual exclusion.

2. No speed assumptions.

3. No blocking by processes in NCS.


4. Forward progress

5. (b) Allocation Maximum Available


abcd abcd abcd
p0 0012 0012 1520
p1 1000 1750
p2 1354 2356
p3 0632 0652
p4 0014 0656

NEED= MAX-ALLOCATION
Abcd
P0 0000
P1 0750
P2 1002
P3 0020
P4 0642

Resources allocated from allocation matrix


A(0+1+1+0+0=)2+1=3
B(0+0+3+6+0=)9+5=14
C(1+0+5+3+1=)10+2=12
D(2+0+4+2+4=)12+0=12
Therefore the resource vector is 3 14 12 12

The state of the system is the current allocation of resources to processes and consist of two
vectors. A safe state is one in which there is at least one sequence that does not result in
deadlock ie all processes can run to completetion. Let us analyze various states:

Initial state:
Allocation Maximum Available
abcd abcd ab c d
p0 0000 0012 3 14 12 12
p1 0750 1 0 0 0 Resource vector
p2 1002 1354
p3 0020 0632 A B C D
p4 0642 0014 1 5 3 2

P0 runs to completion

Allocation Maximum Available


abcd abcd ab c d
p0 0000 0012 3 14 12 12
p1 0701 1 0 0 0 Resource vector
p2 1002 1354
p3 0020 0632 A B C D
p4 0642 0014 1 5 3 2

P2 runs to completion

Allocation Maximum Available


abcd abcd ab c d
p0 0000 0012 3 14 12 12
p1 0750 1 0 0 0 Resource vector
p2 0000 1354
p3 0020 0632 A B C D
p4 0642 0014 2 8 8 6
P1 runs to completion

Allocation Maximum Available


abcd abcd ab c d
p0 0000 0012 3 14 12 12
p1 0000 1 0 0 0 Resource vector
p2 0000 1354
p3 0020 0632 A B C D
p4 0642 0014 3 11 13 10
The intial state after P0 exits(as it has all the resources needed)

Allocation Maximum Available


abcd abcd ab c d
p0 0000 0012 3 14 12 12
p1 0750 1 0 0 0 Resource vector
p2 1002 1354
p3 0020 0632 A B C D
p4 0642 0014 1 5 3 2

Now P1 requests for 0,4,2,0 and if the resources are allocated immediately the state will be as
given below.
Allocation Maximum Available
abcd abcd ab c d
p0 0000 0012 3 14 12 12
p1 0330 1 4 2 0 Resource vector
p2 1002 1354
p3 0020 0632 A B C D
p4 0642 0014 1 1 1 2
P2 exits available vector will be (1,1,1,1)+(1,3,5,4)=2,4,6,6
P3 available 2,4,6,6
P3 exits available vector will be (2,4,6,6)+(0,6,3,2)=2,10,9,8

13. (a) Given memory partition of 100 KB, 500 KB, 200 KB and 600 KB (in order). Show with
neat
sketch how would each of the first-fit , best-fit and worst-fit algorithms place processes of 412
KB, 317 KB, 112 KB and 326 KB(in order). Which algorithm is most efficient in memory
allocation? (16 Marks)
a. First fit:
b. 212K is put in 500k Partition
c. 417 K is put in 600k Partition
d.112k Is put in 288k partition (new partition 288k=500k-212k)
e. 426K must wait.
f. Best fit:
g.212K is put in 300k Partition
h. 417 K is put in 500k Partition
i.112k Is put in 200k partition
j. 426K is put in 600k partition.
K. Worst fit:
l.212K is put in 600k Partition
m. 417 K is put in 500k Partition
n.112k Is put in 388k partition
e. 426K must wait.
In this example Best fit turns out to be the best.

(b) Explain the concept of demand paging. How can demand paging be implemented
with virtual
memory? (16 Marks)
Virtual Memory

 entire process need not be in memory before it can execute

 major advantage: programs larger than main memory can run (Fig. 9.1)

 frees programmers from memory limitations

 allows processes to share files easily and implement shared memory (Fig. 9.3)

 easy mechanism for process creation (copy-on-write)

 motivation

o declaration of 100x100 array when typically only a 10x10 portion of it is used

o in cases where entire program is needed, it is generally not needed all at the same time

 benefits:

o programmers no longer constrained by amount of main memory

o higher degree of multiprogramming → higher CPU utilization and throughput, with no


increase in response time or turnaround time

o less I/O required to load or swap programs into memory → each program runs faster

o more pages required only if the heap or stack grow (Fig. 9.2)

Demand Paging

 same idea as pure paging, but now you only load a page on demand

 this gives a higher degree of multiprogramming with only a little more overhead
 use a lazy swapper (now called a pager) (Fig. 9.4)

 initial load (Fig. 9.5)

 concept of a page fault

 where can a page fault occur (instruction or operand)?

 in pure paging, a page fault represents a fatal error

 in demand paging, a page fault means an additional page must be brought into memory and the
instruction re-started

 why must the instruction be restarted?

 pure demand paging: bring no page(s) in initially; every process will page fault at least once

 concept of locality of reference

Performance of Demand Paging

 effective access time

 probability of a page fault p

 (1-p)*ma + p*page fault time

Virtual Memory That is Larger Than Physical Memory

Virtual memory that is larger than physical memory Virtual-address space


STEPS IN HADLING PAGE FAULTS:

Page fault time

 12 step process; see list on pp. 355-356

 Fig. 9.6

1. service the page-fault interrupt

2. read in the page

3. restart the process

Which is the most time-expensive step?

#2 is the most time-costly; typically 8 milliseconds


AND waiting time in queue for device.

ma = 200ns

pft = 8ms

(1-p)*(200) + p*8,000,000 = 200 + 7,999,800p

effective access time is directly proportional to page-fault rate

if p is 1/1000, effective access time is 8.2 microseconds, a slow-down by a factor of 40 (!!!!)


because of demand paging

if we want the slowdown to be less than 10%, we need p < 0.0000025

that is, fewer than 1 out of 399,990 accesses should fault

Copy-on-Write

 can we do better than pure demand paging?

 recall fork()? seem wasteful? why?

 copy-on-write: both processes (parent and child) share all pages initially, and a shared page is
only copied if and when either process writes to a shared page
 not all shared pages need to be set to copy-on-write (e.g., pages containing the executable code)

 Figs. 9.7 & 9.8

 vfork(): virtual memory fork():

o parent is suspended

o child uses address space of the parent

o vfork is intended to be used when the child calls exec immediately because no copying of
pages takes place

o extremely efficient method of process creation

o sometimes used to implement command shells


14. (a) (i) Explain various file allocation methods in detail. (8 Marks)
(ii) What are the possible structures for directory? Discuss them in detail. (8 Marks)

File Allocation Methods — Contiguous


Of particular interest is the method that the basic file system uses to place the
logical file blocks onto the physical medium (for example, into the disk’s tracks
and sectors).

The simplest policy (akin to memory partitioning in process management) is


the use of a fixed or contiguous allocation. This requires that a file’s maximum
(ever) size be determined when the file is created, and that the file cannot grow
beyond this limit (Figure 12.7).
The file allocation table stores, for each file, its starting block and length.
Like simple memory allocation schemes, this method suffers from both internal
fragmentation (if the initial allocation is too large) and external fragmentation
(as files are deleted over time).
Again, as with memory allocation, a compaction scheme is required to reduce
fragmentation (“defragging” your disk).

File Allocation Methods — Chained:The opposite extreme to contiguous allocation is chained


allocation.
Here, the blocks allocated to a file form a linked list (or chain), and as a file’slength is extended (by
appending to the file), a new block is allocated and linked
to the last block in the file (Figure).

CHAINED ALLOCATION

A small “pointer” of typically 32 or 64 bits is allocated within each file block to


indicate the next block in the chain. Thus seeking within a file requires a read
of each block to follow the pointers.
New blocks may be allocated from any free block on the disk. In particular, a
file’s blocks need no longer be contiguous.

File Allocation Methods — Indexed


The file allocation method of choice in both Unix and Windows is the indexed
allocation method. This method was championed by the Multics operating
system in 1966. The file-allocation table contains a multi-level index for each

file. Indirection blocks are introduced each time the total number of blocks
“overflows” the previous index allocation. Typically, the indices are neither
stored with the file-allocation table nor with the file, and are retained in memory
when the file is opened.

Directory structure:

Directory entry contains file name and identifier


 Linear list of directory entries
 simple to program
 time-consuming to execute
 Hash Table – linear list with hash data structure.
 decreases directory search time
 collisions – situations where two file names
hash to the same location
 fixed size
A collection of nodes containing information about all files
F1F2
F3
F4
Fn
Directory
Files
Both the directory structure and the files reside on disk
Backups of these two structures are kept on tapes
 

A-TYPICAL FILE SYSTEM ORGANIZATION:

Operations Performed on Directory


 Search for a file
 Create a file
 Delete a file -> also delete file data
 List a directory -> file name and attributes
 Move a file from one directory to another one
 Rename a file (“move” a file in the same directory)
 Traverse the file system
 Organize the Directory (Logically) to Obtain
 Efficiency – locating a file quickly
 Naming – convenient to users
 Two users can have same name for different files
 The same file can have several different names
 Grouping – logical grouping of files by properties, (e.g.,
all Java programs, all games, …)
Single-Level Directory
 A single directory for all users (used in simple early
systems)

Naming problem
Grouping problem
Two-Level Directory
 Separate directory for each user (used in early systems)

Path name
n Can have the same file name for different user
n Efficient searching
n No grouping capability
Tree-Structured Directories:
Efficient searching
 Grouping Capability
 Current directory (working directory)
 cd /spell/mail/prog
 type list
 Absolute or relative path name
Absolute or relative path name
 Creating a new file is done in current directory
 Delete a file
rm <file-name>
 Creating a new subdirectory is done in current directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
mail
prog copy prt exp count
Deleting “mail” Þ deleting the entire subtree rooted by “mail”
Acyclic-Graph Directories
 Have shared subdirectories and files
Hard Li
Two different names (aliasing)
 If dict deletes list Þ dangling pointer
Solutions:
 Backpointers, so we can delete all pointers
Variable size records a problem
 Backpointers using a daisy chain organization
 Entry-hold-count solution
 New directory entry type
 Link – another name (pointer) to an existing file
 Resolve the link – follow pointer to locate the file

(b) Explain in detail the free space management with neat diagram. (16 Marks)

 Bit vector (n blocks)



0 1 2 n-1
bit[i] =
1 Þ block[i] free
0 Þ block[i] occupied (allocated)
Block number calculation to find the first free block
(number of bits per word) *
(number of 0-value words) +
offset of first 1 bit
Bit map requires extra space
 Example:
block size = 212 bytes
disk size = 230 bytes (1 gigabyte)
n = 230 /212 = 218 bits (or 32K bytes)
 Easy to get contiguous files
 Linked list (free list)
 Cannot get contiguous space easily
 No waste of space
 Grouping (modified free-list approach)
Need to protect:
 Pointer to free list
 Bit map
Must be kept on disk
Copy in memory and disk may differ
Cannot allow for block[i] to have a situation
where bit[i] = 1 in memory and bit[i] = 0 on
disk
 Solution:
Set bit[i] = 1 in disk
Allocate block[i]
Set bit[i] = 1 in memory
Efficiency dependent on:
 disk allocation and directory algorithms
 types of data kept in file’s directory entry
 Performance
 disk cache – separate section of main memory
for frequently used blocks free-behind and read-ahead – techniques to
optimize sequential access improve PC performance by dedicating section
of memory as virtual disk, or RAM disk

PAGE CACHE:
A page cache caches pages rather than diskblocks using virtual memory techniques
 Memory-mapped I/O uses a page cache
 Routine I/O through the file system uses thebuffer (disk) cache
15. (a) Explain in detail various disk scheduling algorithms with suitable example. (16 Marks)
FCFS
Illustration shows total head movement of 640 cylinders
SSTF
n Selects the request with the minimum seek time from the current head
position
n SSTF scheduling is a form of SJF scheduling; may cause starvation of
some requests
n Illustration shows total head movement of 236 cylinders
SCAN
n The disk arm starts at one end of the disk, and moves toward the other end,
servicing requests until it gets to the other end of the disk, where the head
movement is reversed and servicing continues.
n Direction bit specifies moving direction
n SCAN algorithm Sometimes called the elevator algorithm
n Illustration shows total head movement of 208 cylinders
n Variant of SCAN is LOOK
l Return at final request not at disk boundary
C-SCAN
n Provides a more uniform wait time than SCAN
n The head moves from one end of the disk to the other, servicing requests as
it goes.l When it reaches the other end, however, it immediately returns to the
beginning of the disk, without servicing any requests on the return trip
n Treats the cylinders as a circular list that wraps around from the last cylinder
to the first one
C-LOOK
n Version of C-SCAN
n Arm only goes as far as the last request in each direction, then reverses
direction immediately, without first going all the way to the end of the disk
Selecting a Disk-Scheduling Algorithm:
n SSTF is common and has a natural appeal
n SCAN and C-SCAN perform better for systems that place a heavy load on
the disk. Used on file servers.
n Performance depends on the number and types of requests
n Requests for disk service can be influenced by the file-allocation method
n The disk-scheduling algorithm should be written as a separate module ofthe operating system, allowing
it to be replaced with a different algorithm if necessary
n Either SSTF or LOOK is a reasonable choice for the default algorithm

(b) Write short notes on the following :


(i) I/O Hardware (8 Marks)
(ii) RAID structure. (8 Marks)
I/O HARDWARE:
A Typical PC Bus Structure:
I/O Hardware
 Incredible variety of I/O devices
 Common concepts
 Port
 Bus
daisy chain
shared direct access
 Controller (host adapter)
 I/O instructions control devices
 Devices have addresses, used by
 Direct I/O instructions
 Memory-mapped I/O

Application I/O Interface


 Objective: Treat devices in an standard uniform
way
 I/O system calls encapsulate device behaviors in
generic classes
 Device-driver layer hides differences among I/O
controllers from kernel
 Devices vary in many dimensions
 Character-stream or block
 Sequential or random-access
 Sharable or dedicated
 Speed of operation
 read-write, read only, or write only
Redundant Arrays of Inexpensive Disks (RAID)
RAID is the organisation of multiple disks into a large, high performance logical
disk.
Disk arrays stripe data across multiple disks and access them in parallel to
achieve:
• Higher data transfer rates on large data accesses, and
• Higher I/O rates on small data accesses.
Data striping also results in uniform load balancing across all of the disks,
eliminating hot spots that otherwise saturate a small number of disks, while
the majority of disks sit idle.
However, large disk arrays are highly vulnerable to disk failures:
• A disk array with a hundred disks is a hundred times more likely to fail
than a single disk.
• An MTTF (mean-time-to-failure) of 500,000 hours for a single disk implies
an MTTF of 500,000/100, i.e. 5000 hours for a disk array with a hundred
disks.
The solution to the problem of lower reliability in disk arrays is to improve
the availability of the system, by employing redundancy in the form of errorcorrecting
codes to tolerate disk failures. Do not confuse reliability and availability:
13
Reliability is how well a system can work without any failures in its components.
If there is a failure, the system was not reliable.
Availability is how well a system can work in times of a failure. If a system
is able to work even in the presence of a failure of one or more system
components, the system is said to be available.
Redundancy improves the availability of a system, but cannot improve the
reliability.
Reliability can only be increased by improving manufacturing technologies, or
by using fewer individual components in a system.
Redundancy has costs
Every time there is a write operation, there is a change of data. This change
also has to be reflected in the disks storing redundant information. This worsens
the performance of writes in redundant disk arrays significantly, compared to
the performance of writes in non-redundant disk arrays.
Moreover, keeping the redundant information consistent in the presence of concurrent
I/O operation and the possibility of system crashes can be difficult.
The Need for RAID
The need for RAID can be summarised as:
• An array of multiple disks accessed in parallel will give greater throughput
than a single disk, and
• Redundant data on multiple disks provides fault tolerance.
Provided that the RAID hardware and software perform true parallel accesses
on multiple drives, there will be a performance improvement over a single disk.
With a single hard disk, you cannot protect yourself against the costs of a disk
failure, the time required to obtain and install a replacement disk, reinstall the
operating system, restore files from backup tapes, and repeat all the data entry
performed since the last backup was made.
With multiple disks and a suitable redundancy scheme, your system can stay
up and running when a disk fails, and even while the replacement disk is being
installed and its data restored.
We aim to meet the following goals:
• maximise the number of disks being accessed in parallel,
• minimise the amount of disk space being used for redundant data, and
• minimise the overhead required to achieve the above goals.
Data Striping
Data striping, for improved performance, transparently distributes data over
multiple disks to make them appear as a single fast, large disk. Striping improves
aggregate I/O performance by allowing multiple I/O requests to be
serviced in parallel.
• Multiple independent requests can be serviced in parallel by separate disks.
This decreases the queuing time seen by I/O requests.
• Single multi-block requests can be serviced by multiple disks acting in coordination.
This increases the effective transfer rate seen by a single request.
The performance benefits increase with the number of disks in the array,
but the reliability of the whole array is lowered.
Most RAID designs depend on two features:
• the granularity of data interleaving, and
• the way in which the redundant data is computed and stored across the
disk array.
Fine-grained arrays interleave data in relatively small units so that all I/O
requests, regardless of their size, access all of the disks in the disk array. This
results in very high data transfer rate for all I/O requests but has the disadvantages
that only one logical I/O request can be serviced at once, and that all
disks must waste time positioning for every request.
Coarse-grained disk arrays interleave data in larger units so that small I/O
requests need access only a small number of disks while large requests can
access all the disks in the disk array. This allows multiple small requests to
be serviced simultaneously while still allowing large requests to see the higher
transfer rates from using multiple disks.
Redundancy
Since a larger number of disks lowers the overall reliability of the array of disks,
it is important to incorporate redundancy in the array of disks to tolerate disk
failures and allow for the continuous operation of the system without any loss
of data.
Redundancy brings two problems:
• selecting the method for computing the redundant information. Most redundant
disks arrays today use parity or Hamming encoding, and
• selecting a method for distribution of the redundant information across the
disk array, either concentrating redundant information on a small number
of disks, or distributing redundant information uniformly across all of the
disks.
Such schemes are generally more desirable because they avoid hot spots and
other load balancing problems suffered by schemes that do not uniformly distribute
redundant information.
Non-Redundant (RAID Level 0)
A non-redundant disk array, or RAID level 0, has the lowest cost of any RAID
organisation because it has no redundancy.
Surprisingly, it does not have the best performance. Redundancy schemes that
duplicate data, such as mirroring, can perform better on reads by selectively
scheduling requests on the disk with the shortest expected seek and rotational
delays.
Sequential blocks of data are written across multiple disks in stripes.
Without redundancy, any single disk failure will result in data-loss. Nonredundant
disk arrays are widely used in super-computing environments where
performance and capacity, rather than reliability, are the primary concerns.
The size of a data block, the stripe width, varies with the implementation,
but is always at least as large as a disk’s sector size. When reading back this
sequential data, all disks can be read in parallel.
In a multi-tasking operating system, there is a high probability that even nonsequential
disk accesses will keep all of the disks working in parallel.

Вам также может понравиться