42
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 a b c d a b c d a b c d 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

Model Questions

  • Upload
    prkshjs

  • View
    146

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Model Questions

Answer ALL questionsPART A - (10 X 2 = 20 Marks)1. List down the functions of operating systems2. 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 Availablea b c d a b c d a b c dp0 0 0 1 2 0 0 1 2 1 5 2 0p1 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

Page 2: Model Questions

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 systems1.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?

Page 3: Model Questions

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/faultset user mode_ Privileged instructions can be issued only in monitor mode

I/O Protection

Page 4: Model Questions

_ 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 ProtectionMust 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 memoryaddress. 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.

Page 5: Model Questions

(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.  

Page 6: Model Questions

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.

Page 7: Model Questions

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) {}

Page 8: Model Questions

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

Page 9: Model Questions

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 {

Page 10: Model Questions

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

P

critical-section

V

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 a b c d a b c d a b c dp0 0 0 1 2 0 0 1 2 1 5 2 0p1 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

NEED= MAX-ALLOCATION

A b c dP0 0 0 0 0

Page 11: Model Questions

P1 0 7 5 0P2 1 0 0 2P3 0 0 2 0P4 0 6 4 2

Resources allocated from allocation matrixA(0+1+1+0+0=)2+1=3B(0+0+3+6+0=)9+5=14C(1+0+5+3+1=)10+2=12D(2+0+4+2+4=)12+0=12Therefore 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

a b c d a b c d a b c dp0 0 0 0 0 0 0 1 2 3 14 12 12p1 0 7 5 0 1 0 0 0 Resource vectorp2 1 0 0 2 1 3 5 4 p3 0 0 2 0 0 6 3 2 A B C Dp4 0 6 4 2 0 0 1 4 1 5 3 2

P0 runs to completion

Allocation Maximum Available a b c d a b c d a b c dp0 0 0 0 0 0 0 1 2 3 14 12 12p1 0 7 0 1 1 0 0 0 Resource vectorp2 1 0 0 2 1 3 5 4 p3 0 0 2 0 0 6 3 2 A B C Dp4 0 6 4 2 0 0 1 4 1 5 3 2

P2 runs to completion

Allocation Maximum Available a b c d a b c d a b c dp0 0 0 0 0 0 0 1 2 3 14 12 12p1 0 7 5 0 1 0 0 0 Resource vectorp2 0 0 0 0 1 3 5 4 p3 0 0 2 0 0 6 3 2 A B C Dp4 0 6 4 2 0 0 1 4 2 8 8 6

P1 runs to completion

Page 12: Model Questions

Allocation Maximum Available a b c d a b c d a b c dp0 0 0 0 0 0 0 1 2 3 14 12 12p1 0 0 0 0 1 0 0 0 Resource vectorp2 0 0 0 0 1 3 5 4 p3 0 0 2 0 0 6 3 2 A B C Dp4 0 6 4 2 0 0 1 4 3 11 13 10The intial state after P0 exits(as it has all the resources needed)

Allocation Maximum Available a b c d a b c d a b c dp0 0 0 0 0 0 0 1 2 3 14 12 12p1 0 7 5 0 1 0 0 0 Resource vectorp2 1 0 0 2 1 3 5 4 p3 0 0 2 0 0 6 3 2 A B C Dp4 0 6 4 2 0 0 1 4 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 a b c d a b c d a b c dp0 0 0 0 0 0 0 1 2 3 14 12 12p1 0 3 3 0 1 4 2 0 Resource vectorp2 1 0 0 2 1 3 5 4 p3 0 0 2 0 0 6 3 2 A B C Dp4 0 6 4 2 0 0 1 4 1 1 1 2P2 exits available vector will be (1,1,1,1)+(1,3,5,4)=2,4,6,6P3 available 2,4,6,6P3 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 Partitionc. 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 Partitionh. 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 Partitionm. 417 K is put in 500k Partition n.112k Is put in 388k partition e. 426K must wait.

Page 13: Model Questions

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)

Page 14: Model Questions

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

STEPS IN HADLING PAGE FAULTS:

Page 15: Model Questions

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 millisecondsAND 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

Page 16: Model Questions

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

Page 17: Model Questions

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 — ContiguousOf particular interest is the method that the basic file system uses to place thelogical file blocks onto the physical medium (for example, into the disk’s tracksand sectors).

The simplest policy (akin to memory partitioning in process management) isthe 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 growbeyond 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 internalfragmentation (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 reducefragmentation (“defragging” your disk).

Page 18: Model Questions

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 linkedto the last block in the file (Figure).

CHAINED ALLOCATION

A small “pointer” of typically 32 or 64 bits is allocated within each file block toindicate the next block in the chain. Thus seeking within a file requires a readof each block to follow the pointers.New blocks may be allocated from any free block on the disk. In particular, afile’s blocks need no longer be contiguous.

File Allocation Methods — IndexedThe file allocation method of choice in both Unix and Windows is the indexedallocation method. This method was championed by the Multics operatingsystem in 1966. The file-allocation table contains a multi-level index for each

Page 19: Model Questions

file. Indirection blocks are introduced each time the total number of blocks“overflows” the previous index allocation. Typically, the indices are neitherstored with the file-allocation table nor with the file, and are retained in memorywhen 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 nameshash to the same location fixed sizeA collection of nodes containing information about all filesF 1 F 2F 3F 4F nDirectoryFilesBoth the directory structure and the files reside on diskBackups of these two structures are kept on tapes

Page 20: Model Questions

 

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

Page 21: Model Questions

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 earlysystems)

Naming problemGrouping problem

Two-Level Directory Separate directory for each user (used in early systems)

Path namen Can have the same file name for different usern Efficient searchingn No grouping capability

Tree-Structured Directories:

Page 22: Model Questions

Efficient searching Grouping Capability Current directory (working directory) cd /spell/mail/prog type list Absolute or relative path nameAbsolute or relative path name Creating a new file is done in current directory Delete a filerm <file-name> Creating a new subdirectory is done in current directorymkdir <dir-name>Example: if in current directory /mailmkdir countmailprog copy prt exp countDeleting “mail” Þ deleting the entire subtree rooted by “mail”

Acyclic-Graph Directories Have shared subdirectories and filesHard Li

Page 23: Model Questions

Two different names (aliasing) If dict deletes list Þ dangling pointerSolutions: Backpointers, so we can delete all pointersVariable 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-1bit[i] =1 Þ block[i] free0 Þ block[i] occupied (allocated)Block number calculation to find the first free block(number of bits per word) *(number of 0-value words) +

Page 24: Model Questions

offset of first 1 bitBit map requires extra space Example:block size = 212 bytesdisk 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 mapMust be kept on diskCopy in memory and disk may differCannot allow for block[i] to have a situationwhere bit[i] = 1 in memory and bit[i] = 0 ondisk Solution:Set bit[i] = 1 in diskAllocate block[i]Set bit[i] = 1 in memoryEfficiency dependent on: disk allocation and directory algorithms types of data kept in file’s directory entry Performance disk cache – separate section of main memoryfor frequently used blocks free-behind and read-ahead – techniques tooptimize sequential access improve PC performance by dedicating sectionof 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

Page 25: Model Questions

15. (a) Explain in detail various disk scheduling algorithms with suitable example. (16 Marks)FCFSIllustration shows total head movement of 640 cylinders

Page 26: Model Questions

SSTFn Selects the request with the minimum seek time from the current headpositionn SSTF scheduling is a form of SJF scheduling; may cause starvation ofsome requestsn Illustration shows total head movement of 236 cylinders

Page 27: Model Questions

SCANn 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 headmovement is reversed and servicing continues.n Direction bit specifies moving directionn SCAN algorithm Sometimes called the elevator algorithmn Illustration shows total head movement of 208 cylindersn Variant of SCAN is LOOKl Return at final request not at disk boundary

Page 28: Model Questions

C-SCANn Provides a more uniform wait time than SCANn The head moves from one end of the disk to the other, servicing requests asit goes.l When it reaches the other end, however, it immediately returns to thebeginning of the disk, without servicing any requests on the return tripn Treats the cylinders as a circular list that wraps around from the last cylinderto the first one

Page 29: Model Questions

C-LOOKn Version of C-SCANn Arm only goes as far as the last request in each direction, then reversesdirection immediately, without first going all the way to the end of the disk

Page 30: Model Questions

Selecting a Disk-Scheduling Algorithm:n SSTF is common and has a natural appealn SCAN and C-SCAN perform better for systems that place a heavy load onthe disk. Used on file servers.n Performance depends on the number and types of requestsn Requests for disk service can be influenced by the file-allocation methodn The disk-scheduling algorithm should be written as a separate module ofthe operating system, allowing it to be replaced with a different algorithm if necessaryn 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:

Page 31: Model Questions

I/O Hardware Incredible variety of I/O devices Common concepts Port Busdaisy chainshared 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 uniformway I/O system calls encapsulate device behaviors ingeneric classes Device-driver layer hides differences among I/Ocontrollers from kernel Devices vary in many dimensions

Page 32: Model Questions

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 logicaldisk.Disk arrays stripe data across multiple disks and access them in parallel toachieve:• 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, whilethe 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 failthan a single disk.• An MTTF (mean-time-to-failure) of 500,000 hours for a single disk impliesan MTTF of 500,000/100, i.e. 5000 hours for a disk array with a hundreddisks.The solution to the problem of lower reliability in disk arrays is to improvethe availability of the system, by employing redundancy in the form of errorcorrectingcodes to tolerate disk failures. Do not confuse reliability and availability:13Reliability 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 systemis able to work even in the presence of a failure of one or more systemcomponents, the system is said to be available.Redundancy improves the availability of a system, but cannot improve thereliability.Reliability can only be increased by improving manufacturing technologies, orby using fewer individual components in a system.Redundancy has costsEvery time there is a write operation, there is a change of data. This changealso has to be reflected in the disks storing redundant information. This worsensthe performance of writes in redundant disk arrays significantly, compared tothe performance of writes in non-redundant disk arrays.Moreover, keeping the redundant information consistent in the presence of concurrentI/O operation and the possibility of system crashes can be difficult.The Need for RAIDThe need for RAID can be summarised as:• An array of multiple disks accessed in parallel will give greater throughputthan a single disk, and• Redundant data on multiple disks provides fault tolerance.Provided that the RAID hardware and software perform true parallel accesseson 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 diskfailure, the time required to obtain and install a replacement disk, reinstall the

Page 33: Model Questions

operating system, restore files from backup tapes, and repeat all the data entryperformed since the last backup was made.With multiple disks and a suitable redundancy scheme, your system can stayup and running when a disk fails, and even while the replacement disk is beinginstalled 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 StripingData striping, for improved performance, transparently distributes data overmultiple disks to make them appear as a single fast, large disk. Striping improvesaggregate I/O performance by allowing multiple I/O requests to beserviced 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 thedisk array.Fine-grained arrays interleave data in relatively small units so that all I/Orequests, regardless of their size, access all of the disks in the disk array. Thisresults in very high data transfer rate for all I/O requests but has the disadvantagesthat only one logical I/O request can be serviced at once, and that alldisks must waste time positioning for every request.Coarse-grained disk arrays interleave data in larger units so that small I/Orequests need access only a small number of disks while large requests canaccess all the disks in the disk array. This allows multiple small requests tobe serviced simultaneously while still allowing large requests to see the highertransfer rates from using multiple disks.RedundancySince 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 diskfailures and allow for the continuous operation of the system without any lossof data.Redundancy brings two problems:• selecting the method for computing the redundant information. Most redundantdisks arrays today use parity or Hamming encoding, and• selecting a method for distribution of the redundant information across thedisk array, either concentrating redundant information on a small numberof disks, or distributing redundant information uniformly across all of thedisks.Such schemes are generally more desirable because they avoid hot spots andother load balancing problems suffered by schemes that do not uniformly distributeredundant information.

Non-Redundant (RAID Level 0)

Page 34: Model Questions

A non-redundant disk array, or RAID level 0, has the lowest cost of any RAIDorganisation because it has no redundancy.Surprisingly, it does not have the best performance. Redundancy schemes thatduplicate data, such as mirroring, can perform better on reads by selectivelyscheduling requests on the disk with the shortest expected seek and rotationaldelays.Sequential blocks of data are written across multiple disks in stripes.Without redundancy, any single disk failure will result in data-loss. Nonredundantdisk arrays are widely used in super-computing environments whereperformance 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 thissequential data, all disks can be read in parallel.In a multi-tasking operating system, there is a high probability that even nonsequentialdisk accesses will keep all of the disks working in parallel.