Tải bản đầy đủ (.pdf) (64 trang)

Lecture Operating systems: A concept-based approach (2/e): Chapter 12 - Dhananjay M. Dhamdhere

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.06 MB, 64 trang )

PROPRIETARY MATERIAL. ©  2007 The McGraw­Hill Companies, Inc. All rights reserved. No part of this PowerPoint slide  may be displayed, reproduced or distributed 
in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw­Hill 
for their individual course preparation. If you are a student using this PowerPoint slide, you are using it without permission. 

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 1
Copyright © 2008


Input Output Control System (IOCS)



The IOCS consists of two layers that provide efficient file
processing and efficient device performance
– Access Methods layer
* Each access method provides efficient processing of files with a
specific file organization, e.g., sequential file organization and direct
file organization

– Physical IOCS layer
* Performs I/O operations on devices
* Ensures efficient device performance

Chapter 12: Implementation 
of File Operations



Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 2
Copyright © 2008


Physical organizations in Access methods and
Physical IOCS

•  The physical IOCS reads data from disk into buffers or disk cache/file cache
   maintained in memory (or writes data), ensuring high device throughput
•  The access method moves the data between buffers or caches and the 
   address space of the process, ensuring efficient file processing
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 3
Copyright © 2008


Policies and Mechanisms



Policy

– A guiding principle for implementing a functionality (e.g., prioritybased scheduling)
* It invokes mechanisms to perform various actions required to
implement the functionality



Mechanism
– Specific action in implementing a functionality

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 4
Copyright © 2008


Layers of File system and IOCS

•  M: Mechanism module, P: Policy module
•  A policy module invokes mechanism modules of the same layer,
   which may invoke policy and mechanism modules of the lower layer
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed


Slide No: 5
Copyright © 2008


Policies and mechanisms in file system
and IOCS layers

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 6
Copyright © 2008


Model of a computer system

•  The I/O subsystem has an independent data path to memory
•  Devices are connected to device controllers, which are connected to the
   DMA; a device is identified by the pair (controller id, device id)
•  The DMA, a device controller, and a device implement an I/O operation
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 7

Copyright © 2008


Access and data transfer time in an I/O operation

The total time required to perform an I/O operation = ta + tx

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 8
Copyright © 2008


Error detection approaches

•  Parity bits
•  Cyclic 
   redundancy
   checksum 
   (CRC)

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed


Slide No: 9
Copyright © 2008


Disk data organization



Data should be organized such that it can be accessed
efficiently
– Notion of a Cylinder
* Consists of identically positioned tracks on all platters of a disk
 All of its tracks can be accessed for the same position of disk
heads
 Its use reduces disk head movement
 Put adjoining data of a file on tracks in the same cylinder

– Data staggering techniques
* A disk rotates a bit while disk heads are being readied or moved to
access a new track. Make sure that data to be accessed passes
under the read / write heads after their movement is completed
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 10
Copyright © 2008



A cylinder in a disk with several platters

Tracks in a cylinder can be accessed by electronically switching to use of
the disk head positioned on a track; it does not involve movement of heads

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 11
Copyright © 2008


Data staggering techniques



Sector interleaving
– Background: Older disks used to contain a buffer to store data
read from the disk or data to be written on it
* In a read operation, the data was first read from a disk sector into the
buffer
* Data from the buffer was then transferred to memory
* Now the disk was ready for a new operation
* But the next sector had already passed under the head!


– Technique: A few sectors are skipped while recording adjoining
file records or file data
* The number of sectors skipped is called the interleaving factor (inf)

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 12
Copyright © 2008


Sector interleaving

(a) No interleaving; adjacent records in a file occupy adjoining disk sectors
(b) Interleaving factor = 2; two sectors exist between adjacent file records

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 13
Copyright © 2008


Variation of throughput

with sector interleaving factor (inf)

•  The disk is assumed to contain 8 sectors on a track
•  inf  = 0: Consecutive file records cannot be read in the same disk revolution
•  inf  = 2: Consecutive file records can be read in the same disk revolution
•  Peak throughput is obtained by reading the same track over and over
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 14
Copyright © 2008


Variation of throughput with interleaving factor

Inf  = 2 provides the best peak throughput

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 15
Copyright © 2008



Data staggering techniques



Head skew
– The disk requires some time to switch from reading data of one
track to data of another track in a cylinder (Head switch time)
* Some sectors/records/blocks pass under the head during this time
* Head skewing: Stagger the data on tracks
 The first sector of a new track should pass under the head only
after its disk head is ready to read



Cylinder skew
– The disk rotates while the disk heads move to tracks of an
adjoining cylinder
* Cylinder skewing: Data is skewed analogous to head skew

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 16
Copyright © 2008


Redundant Array of Inexpensive Disks (RAID)





An array of cheap disks is used instead of a single disk
Different arrangements are used to provide three benefits
– Reliability
* Store data redundantly (remember stable storage?)
* Read / write redundant data records in parallel

– Fast data transfer rates
* Store file data on several disks in the RAID
* Read / write file data in parallel

– Fast access
* Store two or more copies of data
* To read data, access the copy that is accessible most efficiently
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 17
Copyright © 2008


Disk striping





A disk strip contains data (it is like a sector or disk block)
A disk stripe is a collection of identically positioned strips
on different disks in the RAID
– Data written on strips in a disk stripe can be read in parallel
* This arrangement provides high data transfer rates

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 18
Copyright © 2008


RAID levels



Different RAID organizations (called RAID levels) provide
different benefits
– RAID 0: Disk striping
* High data transfer rates

– RAID 1: Disk mirroring
* Identical data is written on two disks
* To read, the copy accessible faster is accessed


– RAID 0+1
* Disk striping as in RAID 0, each stripe is mirrored

– RAID 1+0
* Disks are first mirrored, then striped
* Provides better reliability than RAID 0+1
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 19
Copyright © 2008


RAID levels
– Level 2: Error correction codes
* Data and redundant bits are recorded on different disks
* For example, (12,8) Hamming code

– Level 3: Bit interleaved parity
* Similar to level 2, but uses a single parity disk
* Device controller detects error, parity bit is used to correct it

– Level 4: Block interleaved parity
* Strip contains consecutive bytes; parity strip contains parity bits

– Level 5: Block interleaved distributed parity

* Like level 4, but parity strips are spread on several disks

– Level 6: P+Q redundancy

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 20
Copyright © 2008


Physical IOCS and Device Drivers



The Physical IOCS
– Supports device-level I/O operations
* Provides functionalities for starting an I/O operation, checking its
status, etc. (Note: a device is identified by the pair (cu, d))

– Performs device-level performance optimization
* Schedules I/O operations on a device in such a manner that the
device throughput is maximized
* Reduces disk head movement in a disk




The Physical IOCS provides this support for all classes of
I/O devices
– A device driver in a modern OS provides such support for a
specific class of I/O devices; e.g., a disk driver

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 21
Copyright © 2008


Overview of device-level I/O



I/O instructions and I/O commands
– I/O instruction
* An I/O instruction initiates an I/O operation; it involves the CPU, DMA, device
controller and device
* An I/O operation may consist of several distinct tasks
 e.g., reading from a disk involves positioning disk heads, locating a
sector and performing data transfer
* Individual tasks in I/O are performed through ‘I/O commands’
* An I/O instruction indicates the (cu, d) pair identifying a device and specifies
the commands that describe the tasks to be performed


– I/O command
* Performs a specific task in an I/O operation
 e.g., positioning disk heads, reading data, etc.
 Does not involve the CPU
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 22
Copyright © 2008


Computer features supporting device-level I/O



The following features in a computer are used for I/O
– Initiating an I/O operation
* Instruction ‘I/O-init (cu, d), command address’ initiates an I/O opn
* I/O commands are assumed to occupy consecutive memory locations

– Checking device status
* Instruction ‘I/O-status (cu, d)’ provides status information regarding
the device (cu, d)

– Performing I/O operations
* Device-specific commands may be used to perform I/O


– Handling interrupts
* Interrupt hardware performs switching of PSWs

Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 23
Copyright © 2008


Device-level I/O without OS support



We consider a program that is executing in a raw
machine, i.e., without OS support
– When the program initiates an I/O operation, it should execute the
next instruction only after the I/O operation completes
* CPU and the I/O channel operate in parallel
* Hence the CPU should do nothing until the I/O operation completes.
It is achieved as follows
 An IO_FLAG is associated with the I/O operation
 It is set by the interrupt servicing routine when the I/O operation
completes
 The CPU loops until IO_FLAG is set to the value ‘I/O complete’

Chapter 12: Implementation 

of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 24
Copyright © 2008


Device level I/O

•  Before initiating an I/O operation, the IO_FLAG is set to ‘I/O in progress’
•  The IO_init instruction sets a condition code regarding its outcome
•  If the I/O device is busy, the IO_init instruction is attempted repeatedly
•  The CPU loops at PROCEED until the I/O operation completes
Chapter 12: Implementation 
of File Operations

Dhamdhere: Operating Systems—
A Concept­Based Approach, 2 ed

Slide No: 25
Copyright © 2008


×