0% found this document useful (0 votes)
16 views

Unit5 Complete

The document discusses input/output (I/O) systems and hardware. It describes how I/O devices connect to computers through ports, buses, and device controllers. Device drivers interface with specific devices to provide a uniform access interface. The document outlines different I/O techniques like polling, interrupts, and direct memory access (DMA) that improve efficiency when transferring data to and from I/O devices. It also categorizes I/O devices and discusses characteristics that operating systems use to group similar devices.

Uploaded by

Aman Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Unit5 Complete

The document discusses input/output (I/O) systems and hardware. It describes how I/O devices connect to computers through ports, buses, and device controllers. Device drivers interface with specific devices to provide a uniform access interface. The document outlines different I/O techniques like polling, interrupts, and direct memory access (DMA) that improve efficiency when transferring data to and from I/O devices. It also categorizes I/O devices and discusses characteristics that operating systems use to group similar devices.

Uploaded by

Aman Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 99

Introduction

• I/O devices are very important in the computer systems. They provide users the means of
interacting with the system. So there is a separate I/O system devoted to handling the I/O
devices.
• I/O Hardware
• There are many I/O devices handled by the operating system such as mouse, keyboard, disk
drive etc.
• There are different device drivers that can be connected to the operating system to handle a
specific device.
• The device controller is an interface between the device and the device driver.

6 August 2023 1
I/O Systems(CO5)
• I/O management is a major component of operating system
design and operation
• Important aspect of computer operation
• I/O devices vary greatly
• Various methods to control them
• Performance management
• New types of devices frequent
• Ports, busses, device controllers connect to various devices

• Device drivers encapsulate device details

• Present uniform device-access interface to I/O


subsystem

6 August 2023 2
A Typical PC Bus Structure(CO5)

6 August 2023 3
I/O Hardware(CO5)
• Incredible variety of I/O devices
• Storage
• Transmission
• Human-interface
• Common concepts – signals from I/O devices interface with computer
• Port – connection point for device
• Bus - daisy chain or shared direct access
• PCI bus common in PCs and servers, PCI Express (PCIe)
• expansion bus connects relatively slow devices
Controller (host adapter) – electronics that operate port, bus, device
• Sometimes integrated
• Sometimes separate circuit board (host adapter)
• Contains processor, microcode, private memory, bus controller, etc
• –6Some talk to per-device controller with bus controller, microcode, memory, etc
August 2023 4
I/O Hardware (CO5)
• I/O instructions control devices

• Devices usually have registers where device driver places commands, addresses,
and data to write, or read data from registers after command execution
• Data-in register, data-out register, status register, control register
• Typically 1-4 bytes, or FIFO buffer
• Devices have addresses, used by

• Direct I/O instructions

• Memory-mapped I/O
• Device data and command registers mapped to processor address space
• Especially for large address spaces (graphics)

6 August 2023 5
I/0 Buffering(CO5)

• The buffer is an area in the main memory used to store or hold the data temporarily.


• The act of storing data temporarily in the buffer is called buffering.
• A buffer may be used when moving data between processes within a computer. Buffers can
be implemented in a fixed memory location in hardware or by using a virtual data buffer in
software, pointing at a location in the physical memory.
• In all cases, the data in a data buffer are stored on a physical storage medium.

6 August 2023 6
Types of Buffering (CO5)

Single Buffer
In Single Buffering, only one buffer is used to transfer the data between two devices. The producer
produces one block of data into the buffer. After that, the consumer consumes the buffer. Only
when the buffer is empty, the processor again produces the data.

6 August 2023 7
Double Buffering (CO5)

In Double Buffering, two schemes or two buffers are used in the place of one. In this buffering, the
producer produces one buffer while the consumer consumes another buffer simultaneously. So,
the producer not needs to wait for filling the buffer. Double buffering is also known as buffer
swapping.

6 August 2023 8
Circular Buffer (CO5)
Circular Buffering

circular Buffering

When more than two buffers are used, the buffers' collection is called a circular buffer. Each
buffer is being one unit in the circular buffer. The data transfer rate will increase using the
circular buffer rather than the double buffering.

6 August 2023 9
 I/O port
I/O port (CO5)

• An I/O port usually consists of four different registers. These are (1) status, (2) control,
(3) data-in, and (4) data-out registers.
• The data-in register is read by the host for getting input.
• The data-out register is written by the host for sending output.
• The status register holds bits which can be read by the host.
• The control register is written by the host for starting a command or for changing the
mode of any device.
• The data registers are usually 1 to 4 bytes in size. Some of the controllers have FIFO
chips which hold several bytes of input or output data for expanding the capacity of the
controller beyond the size of the data register.

6 August 2023 10
Polling(CO5)
• For each byte of I/O
1. Read busy bit from status register until 0
2. Host sets read or write bit and if write copies data into data-out
register
3. Host sets command-ready bit
4. Controller sets busy bit, executes transfer
5. Controller clears busy bit, error bit, command-ready bit when transfer
done
• Step 1 is busy-wait cycle to wait for I/O from device
• Reasonable if device is fast
• But inefficient if device slow
• CPU switches to other tasks?
• But if miss a cycle data overwritten / lost

6 August 2023 11
Interrupts(CO5)
• Polling can happen in 3 instruction cycles
• Read status, logical-and to extract status bit, branch if not zero
• How to be more efficient if non-zero infrequently?
• CPU Interrupt-request line triggered by I/O device
• Checked by processor after each instruction
• Interrupt handler receives interrupts
• Maskable to ignore or delay some interrupts
• Interrupt vector to dispatch interrupt to correct handler
• Context switch at start and end
• Based on priority
• Some nonmaskable
• Interrupt chaining if more than one device at same interrupt number

6 August 2023 12
Direct Memory Access(CO5)
• Used to avoid programmed I/O (one byte at a time) for large data
movement

• Requires DMA controller

• Bypasses CPU to transfer data directly between I/O device and


memory

• OS writes DMA command block into memory


• Source and destination addresses
• Read or write mode
• Count of bytes
• Writes location of command block to DMA controller
• Bus mastering of DMA controller – grabs bus from CPU
• Cycle stealing from CPU but still much more efficient
• When done, interrupts to signal completion
6 August 2023 13
Characteristics of I/O Devices(CO5)

6 August 2023 14
Characteristics of I/O Devices(CO5)
• Subtleties of devices handled by device drivers

• Broadly I/O devices can be grouped by the OS into

• Block I/O

• Character I/O (Stream)

• Memory-mapped file access

• Network sockets

• For direct manipulation of I/O device specific characteristics, usually


an escape / back door

• Unix ioctl() call to send arbitrary bits to a device control register


and data to device data register

6 August 2023 15
Block and Character Devices(CO5)
• Block devices include disk drives

• Commands include read, write, seek

• Raw I/O, direct I/O, or file-system access

• Memory-mapped file access possible

File mapped to virtual memory and clusters brought via demand


paging
• DMA

• Character devices include keyboards, mice, serial ports

• Commands include get(), put()

• Libraries layered on top allow line editing


6 August 2023 16
Network Devices(CO5)
• Subtleties of devices handled by device drivers

• Broadly I/O devices can be grouped by the OS into


• Block I/O
• Character I/O (Stream)
• Memory-mapped file access
• Network sockets

• For direct manipulation of I/O device specific


characteristics, usually an escape / back door
• Unix ioctl() call to send arbitrary bits to a device control
register and data to device data register

6 August 2023 17
I/O Protection(CO5)

• User process may accidentally or purposefully attempt to disrupt


normal operation via illegal I/O instructions

• All I/O instructions defined to be privileged

• I/O must be performed via system calls

• Memory-mapped and I/O port memory locations must be protected


too

6 August 2023 18
Disk Storage(CO 5)
Disk storage (also sometimes called drive storage) is a general category of storage mechanisms
where data is recorded by various electronic, magnetic, optical, or mechanical changes to a surface
layer of one or more rotating disks.
A disk drive is a device implementing such a storage mechanism.

6 August 2023 19
Disk structure(CO5)

6 August 2023 20
Disk structure(CO5)

• Disk drives are addressed as large 1-dimensional arrays of logical blocks,


where the logical block is the smallest unit of transfer.
• The 1-dimensional array of logical blocks is mapped onto the sectors of the
disk sequentially.
–Sector 0 is the first sector of the first track on the outermost cylinder.
–Mapping proceeds in order through that track, then the rest of the tracks in
that cylinder, and then through the rest of the cylinders from outermost to
innermost.

6 August 2023 21
Disk Access Time(CO5)

• seek time: time to position heads on cylinder (a fixed head disk does not require seek
time but is more expensive than a moving-head disk)
• rotational latency: delay in accessing material once seek accomplished (time required
to wait for data to rotate around under head)
• Transmission time: time to transfer information once it is under the head.

• access time = seek time + rotational latency


+read/write transmission time
seek time >> read/write time

6 August 2023 22
Disk Scheduling(CO5)
• The operating system is responsible for using hardware efficiently — for the disk
drives, this means having a fast access time and disk bandwidth.
–Disk bandwidth is the total number of bytes transferred, divided by the total time
between the first request for service and the completion of the last transfer.
• Accomplish this by minimizing seek time
–Seek time approximates seek distance

6 August 2023 23
Disk I/O Request(CO5)
Disk I/O request specifies
• whether the operation is input or output
• disk address (block number, which is translated into drive, cylinder, surface, and sector
coordinates)
• memory address to copy to or from
• byte count giving the amount of information to be transferred

6 August 2023 24
Disk Scheduling(CO5)

• Many requests may be pending at once. Which should be handled first?


• Head moving strategy developed
• Attempting to manage the overall disk seek time. Latency is not controllable and transfer
time depends on the size of the transfer request
• Different strategies:
–FCFS
–SSTF
–SCAN
–LOOK

6 August 2023 25
FCFS Scheduling(CO5)

• Simplest form
• First-come, first-served scheduling
• Requests served in order of arrival
• Advantage: simple queueing
• Disadvantage: does not provide the “best” seek time

6 August 2023 26
FCFS(CO5)
Illustration shows total head movement of 640 cylinders

6 August 2023 27
SSTF(CO5)
•Shortest Seek Time First selects the request with the minimum seek time from the
current head position
•SSTF scheduling is a form of SJF scheduling; may cause starvation of some requests.
•Illustration shows total head movement of 236 cylinders

6 August 2023 28
SSTF(CO5)

6 August 2023 29
SCAN(CO5)
•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

•SCAN algorithm sometimes called the elevator algorithm

•Illustration shows total head movement of 208 cylinders

6 August 2023 30
SCAN(CO5)

6 August 2023 31
C-SCAN(CO5)
•Provides a more uniform wait time than SCAN
•The head moves from one end of the disk to the other, servicing requests as it goes
when it reaches the other end, however, it immediately returns to the beginning of the
disk, without servicing any requests on the return trip
•Treats the cylinders as a circular list that wraps around from the last cylinder to the first
one

6 August 2023 32
C-SCAN(CO5)

6 August 2023 33
LOOK & C-LOOK(CO5)
•LOOK a version of SCAN, C-LOOK a version of C-SCAN

•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

6 August 2023 34
C-LOOK(CO5)

6 August 2023 35
Selecting a Disk-Scheduling Algorithm(CO5)

•SSTF is common and has a natural appeal for low load disks (quickly go to next request)
•LOOK, C-LOOK, SCAN and C-SCAN perform better for systems that place a heavy load on
the disk (no starvation, more predictable delays)
•Performance depends on the number and types of requests
•Requests for disk service can be influenced by the
file-allocation method

6 August 2023 36
Disk Management(CO5)

•Low-level formatting, or physical formatting — Dividing a disk into sectors that the disk
controller can read and write
•Each sector can hold header information, plus data, plus error correction code (ECC)
•Usually 512 bytes of data but can be selectable
•To use a disk to hold files, the operating system still needs to record its own data structures
on the disk
•Partition the disk into one or more groups of cylinders, each treated as a logical disk
•Logical formatting or “making a file system”
•To increase efficiency most file systems group blocks into clusters
•Disk I/O done in blocks
•File I/O done in clusters of blocks

6 August 2023 37
Disk Management(CO5)

•Raw disk access for apps that want to do their own block management, keep OS out
of the way (databases for example)
•Boot block initializes system
•The bootstrap is stored in ROM
•Bootstrap loader program stored in boot blocks of boot partition
•Methods such as sector sparing used to handle bad blocks

6 August 2023 38
Booting from a Disk in Windows(CO5)

6 August 2023 39
Directory Structure(CO5)

• Directory can be defined as the listing of the related files on the disk. The directory
may store some or the entire file attributes.
• To get the benefit of different file systems on the different operating systems, A
hard disk can be divided into the number of partitions of different sizes. The
partitions are also called volumes or mini disks.
• Each partition must have at least one directory in which, all the files of the partition
can be listed. A directory entry is maintained for each file in the directory which
stores all the information related to that file.

6 August 2023 40
Directory Structure
Directory Structure(CO5)

6 August 2023 41
Single Level Directory(CO5)

The simplest method is to have one big list of all the files on the disk. The entire system
will contain only one directory which is supposed to mention all the files present in the
file system. The directory contains one entry per each file present on the file system.

6 August 2023 42
Single Level Directory(CO5)

Characteristics :
If the sizes of the files are very small then the searching becomes faster.
•File creation, searching, deletion is very simple since we have only one directory.
•We cannot have two files with the same name.
•The directory may be very big therefore searching for a file may take so much time.
•Protection cannot be implemented for multiple users.
•There are no ways to group same kind of files.
•Choosing the unique name for every file is a bit complex and limits the number of files in the
system because most of the Operating System limits the number of characters used to
construct the file name.

6 August 2023 43
Two Level Directory(CO5)

In two level directory systems, we can create a separate directory for each user. There is one
master directory which contains separate directories dedicated to each user. For each user,
there is a different directory present at the second level, containing group of user's file. The
system doesn't let a user to enter in the other user's directory without permission.

6 August 2023 44
CharacteristicsTwo
of two
wo level
Level
Level directory system
Directory(CO5)
Directory(CO5)

Characteristics :
•Each files has a path name as /User-name/directory-name/
•Different users can have the same file name.
•Searching becomes more efficient as only one user's list needs to be traversed.
•The same kind of files cannot be grouped into a single directory for a particular
use

6 August 2023 45
system
Tree structured directory

• In Tree structured directory system, any directory entry can either be a file or sub
directory. Tree structured directory system overcomes the drawbacks of two level
directory system. The similar kind of files can now be grouped in one directory.

• Each user has its own directory and it cannot enter in the other user's directory.
However, the user has the permission to read the root's data but he cannot write or
modify this. Only administrator of the system has the complete access of root
directory.

• Searching is more efficient in this directory structure. The concept of current


working directory is used. A file can be accessed by two types of path, either relative
or absolute.

6 August 2023 46
system
Tree structured directory

6 August 2023 47
File Concept(CO5)
•Contiguous logical address space
•File = collection of related information recorded on
secondary storage

•Types: File “interpretation” is up to user/program


•Data
•Numeric (text, ASCII; “LINE_MAX” bytes)
•Character (text, ASCII; “LINE_MAX” bytes)
•Binary (executable, readable by computer)
•Program

6 August 2023 48
File Concept(CO5)
•Contiguous logical address space
•File = collection of related information recorded on secondary storage

•Types:
•Data
File “interpretation” is up to user/program
•Numeric (text, ASCII; “LINE_MAX” bytes)
•Character (text, ASCII; “LINE_MAX” bytes)
•Binary (executable, readable by computer)
•Program

6 August 2023 49
File Concept(CO5)
File
A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical disks. In general, a file is a sequence of bits, bytes, lines
or records whose meaning is defined by the files creator and user.

File Structure
•A File Structure should be according to a required format that the operating system can understand.
•A file has a certain defined structure according to its type. File “interpretation” i
•A text file is a sequence of characters organized into lines. program
•A source file is a sequence of procedures and functions.
•An object file is a sequence of bytes organized into blocks that are understandable by the machine.
•When operating system defines different file structures, it also contains the code to support these
file structure. Unix, MS-DOS support minimum number of file

6 August 2023 50
File Attributes(CO5)

• Name – only information kept in human-readable form

• Identifier – unique tag (number) identifies file within file system

• Type – needed for systems that support different types

• Location – pointer to file location on device

• Size – current file size

• Protection (ACL) – controls who can do reading, writing, executing

• Time, date, and user identification – data for protection, security, and usage monitoring

• Information about files are kept in the directory structure, which is maintained on the disk

6 August 2023 51
File Operations(CO5)
• File is an abstract data type

• Basic operations on files:


– Create
– Write
– Read
– Reposition within file
– Delete
– Truncate
• Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry

to memory

• Close (Fi) – move the content of entry Fi in memory back to directory structure on disk

• Opening files: “remember” used files; efficiency; convenience

6 August 2023 52
File Types – Name, Extension(CO5)

6 August 2023 53
Access Methods(CO5)
• Sequential Access
read next
write next
reset
skip forward
• Direct Access
read n
write n
position to n
read next
write next
rewrite n
n = relative block number

6 August 2023 54
Sequential-Access File(CO5)

6 August 2023 55
Simulation of Sequential Access on
Direct-Access File(CO5)

6 August 2023 56
Indexed Access

• If a file can be sorted on any of the filed then an index can be assigned to a group of certain
records. However, A particular record can be accessed by its index. The index is nothing but
the address of a record in the file.
• In index accessing, searching in a large database became very quick and easy but we need
to have some extra space in the memory to store the index value.

6 August 2023 57
Allocation Methods(CO5)
An allocation method refers to how disk blocks are allocated for files.
•Allocation Methods:
•Contiguous allocation
•Linked allocation
•Indexed allocation

6 August 2023 58
Contiguous allocation(CO5)

Contiguous allocation :
•each file occupies set of contiguous blocks
•Provides efficient direct access.
•Simple – only starting location (block #) and length (number of blocks) are required
•Both sequential and direct access can be supported
•First fit and best fit are the most common used strategies.
•External fragmentation can be a problem
•Best performance in most cases
•Problems include finding space for file, knowing file size, external fragmentation, need
for compaction off-line (downtime) or on-line.

6 August 2023 59
Contiguous allocation(CO5)

6 August 2023 60
Linked Allocation(CO5)

• Each file is a linked list of fixed-size disk blocks.

• Blocks may be scattered anywhere on the disk.

• Allocate blocks as needed as the file grows, wherever they are available on the disk

• The directory contains a pointer to the first and last blocks of the file.

• Each block contains a pointer to the next block (not accessible by users)

6 August 2023 61
Linked Allocation(CO5)
• Simple – only need to keep the starting address of each file.

• No external fragmentation. Any free block can be used to satisfy a request for more
space.
• Creating a file is easy, declared of size zero (null pointer to the first block) then grow
easily as long as free blocks are available
• No efficient direct access.

• Effective for sequential access.

• Pointers saved in the blocks consume some space

6 August 2023 62
Linked Allocation(CO5)

• Use of clusters (a set of blocks which the system deals with as a unit)

• Decreases overhead of pointers (4 blocks = 1 cluster needs 1 ptr)


• Increases throughput (fewer head seeks).
• Increases internal fragmentation.
• Reliability: if a pointer is lost, blocks (clusters) can’t be traversed

6 August 2023 63
Linked Allocation(CO5)

6 August 2023 64
Indexed Allocation(CO5)

• Each file has its own index block, which is an array of disk-block addresses

• The directory contains the address of the index block, from which the ith block can be

accessed directly

6 August 2023 65
Indexed Allocation(CO5)

6 August 2023 66
Indexed Allocation(CO5)

• More efficient direct access than linked allocation.

• No external fragmentation. Any free block can be used to satisfy a request for more

space.
• Suffers from a wasted space due to the use of index block. (pointer overhead is larger)

• How large the index block should be? What if a file is too large for one index block?

• Linked scheme: use one block. To allow larger files, link several index blocks

• Multilevel index: use a first-level index block to point to a second-level index blocks

• Combined scheme: used in UNIX.

6 August 2023 67
Free-Space Management(CO5)
• File system maintains free-space list to track available blocks/
clusters
– (Using term “block” for simplicity)
• Bit vector or bit map (n blocks)

Block number calculation


0 1 2 n-1
(number of bits per word) *

(number of 0-value words) +
offset of first 1 bit


1  block[i] free
bit[i] = CPUs have instructions
0  block[i] occupied to return offset
within word of first
“1” bit

6 August 2023 68
Free-Space Management(CO5)
• Bit map requires extra space
– Example:
block size = 4KB = 212 bytes
disk size = 240 bytes (1 terabyte)
n = 240/212 = 228 bits (or 256 MB)
if clusters of 4 blocks -> 64MB of memory
• Easy to get contiguous files
• Linked list (free list)
– Cannot get contiguous space easily
– No waste of space
– No need to traverse the entire list (if # free blocks
recorded)

6 August 2023 69
Linked Free Space List on Disk(CO5)

• Linked list (free list)


• Cannot get
contiguous space
easily
• No waste of space
• No need to traverse
the entire list (if #
free blocks recorded)

6 August 2023 70
Free-Space Management(CO5)

• Grouping
– Modify linked list to store address of next n-1 free blocks in first free
block, plus a pointer to next block that contains free-block-pointers
(like this one)
• Counting
– Because space is frequently contiguously used and freed, with
contiguous-allocation allocation, extents, or clustering.
– Keep address of first free block and count of following free blocks.
– Free space list then has entries containing addresses and counts

6 August 2023 71
Bit Vector

• In this approach, the free space list is implemented as a bit map vector. It
contains the number of bits where each bit represents each block.
• If the block is empty then the bit is 1 otherwise it is 0. Initially all the blocks
are empty therefore each bit in the bit map vector contains 1.
• LAs the space allocation proceeds, the file system starts allocating blocks to
the files and setting the respective bit to 0.

6 August 2023 72
Linked List

• It is another approach for free space management. This approach suggests


linking together all the free blocks and keeping a pointer in the cache which
points to the first free block.
• Therefore, all the free blocks on the disks will be linked together with a
pointer. Whenever a block gets allocated, its previous free block will be
linked to its next free block.

6 August 2023 73
Threats to Protection and Security
• Protection and security requires that computer resources such as CPU, software's, memory
etc. are protected. This extends to the operating system as well as the data in the system.
This can be done by ensuring integrity, confidentiality and availability in the operating
system. The system must be protect against unauthorized access, viruses, worms etc.

• Threats to Protection and Security


A threat is a program that is malicious in nature and leads to harmful effects for the
system. Some of the common threats that occur in a system are −
Virus
Viruses are generally small snippets of code embedded in a system. They are very
dangerous and can corrupt files, destroy data, crash systems etc. They can also spread
further by replicating themselves as required.
Trojan Horse
A trojan horse can secretly access the login details of a system. Then a malicious user can
use these to enter the system as a harmless being and wreak havoc.

6 August 2023 74
Threats to Protection and Security

• Trap Door
A trap door is a security breach that may be present in a system without
the knowledge of the users. It can be exploited to harm the data or files in
a system by malicious people.
• Worm
A worm can destroy a system by using its resources to extreme levels. It
can generate multiple copies which claim all the resources and don't
allow any other processes to access them. A worm can shut down a
whole network in this way.
• Denial of Service
These type of attacks do not allow the legitimate users to access a
system. It overwhelms the system with requests so it is overwhelmed
and cannot work properly for other user

6 August 2023 75
Protection and Security Methods

• The different methods that may provide protect and security for different computer
systems are −
• Authentication
This deals with identifying each user in the system and making sure they are who they
claim to be. The operating system makes sure that all the users are authenticated
before they access the system. The different ways to make sure that the users are
authentic are:
• Username/ PasswordEach user has a distinct username and password combination and
they need to enter it correctly before they can access the system.
• User Key/ User CardThe users need to punch a card into the card slot or use they
individual key on a keypad to access the system.
• User Attribute IdentificationDifferent user attribute identifications that can be used are
fingerprint, eye retina etc.

6 August 2023 76
Protection and Security Methods

One Time Password


These passwords provide a lot of security for authentication purposes. A one time
password can be generated exclusively for a login every time a user wants to enter the
system. It cannot be used more than once. The various ways a one time password can
be implemented are −
Random Numbers
The system can ask for numbers that correspond to alphabets that are pre arranged.
This combination can be changed each time a login is required.
Secret Key
A hardware device can create a secret key related to the user id for login. This key can
change each time.

6 August 2023 77
RAID Structure(CO5)

•RAID – redundant array of inexpensive/independent disks


•Multiple disk drives provides reliability via redundancy
•Increases the mean time to failure
•Mean time to repair – exposure time when another failure could cause data loss
•Mean time to data loss based on above factors
•If mirrored disks fail independently, consider disk with 100,000 mean time to failure and 10
hour mean time to repair
•Mean time to data loss is 100,0002 / (2 ∗ 10) = 500 ∗ 106 hours, or 57,000 years!
•Frequently combined with NVRAM to improve write performance
•RAID is arranged into six different levels

6 August 2023 78
RAID(CO5)
•Several improvements in disk-use techniques involve the use of multiple disks
working cooperatively
•Disk striping uses a group of disks as one storage unit
•RAID schemes improve performance and improve the reliability of the storage
system by storing redundant data
•Mirroring or shadowing (RAID 1) keeps duplicate of each disk
•Striped mirrors (RAID 1+0) or mirrored stripes (RAID 0+1) provides high
performance and high reliability
•Block interleaved parity (RAID 4, 5, 6) uses much less redundancy.

6 August 2023 79
RAID(CO5)

•RAID within a storage array can still fail if the array fails, so automatic replication of the
data between arrays is common
•Frequently, a small number of hot-spare disks are left unallocated, automatically
replacing a failed disk and having data rebuilt onto them

6 August 2023 80
RAID 0: Block Level Striping

data: in blocks; adjacent blocks go into different disks


one block can be k sectors

file system considers all disks as a single large disk

Block 0 Block 1 Block 2 Block 3


Block 4 Block 5 Block 6 Block 7

Block 8 Block 9 Block10 Block11

Disk 1 Disk 2 Disk 3 Disk 4

No redundancy;
parallel read for large data transfers (larger than block size)

81
RAID 1: Mirroring

No striping

Disk 1
Mirror

Mirrored copy

Disk 2
82
RAID 1

• We are just mirroring the disks (copying one disk to another one).

• Without striping: no performance gain, except for reads (doubled read-rate)

• Reliability provided. If one disk fails, data can be recovered from the other disk.

• If there are originally N (N >= 1) disks; we need N more disks to mirror


– Quite costly in terms of disks required. This cost is for reliability. We can express the cost as:

overhead/data = 1/1

83
RAID 2

• Bit level striping.


• Error correcting codes (ECC) used.
– For example every 4 data bit is protected with 3 redundant bits. If one of these 4 bits is in error, we can
understand which one it is and correct it using 3 other code bits.
– Hamming codes can be used.

data bits error correction bits

bit bit bit bit bit bit bit

bit bit bit bit bit bit bit

can be bits of one byte overhead/data = 3/4


84
RAID 2 organization

b0 b1 b2 b3 c0 c1 c2

b4 b5 b6 b7 c0 c0 c0

…. …. …. ….

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5 Disk 6 Disk 7

bx: data bits


cx: control bits
85
RAID 2

dddddddd dddddddd dddddddd dddddddd cccccccc cccccccc cccccccc


dddddddd dddddddd dddddddd dddddddd cccccccc cccccccc cccccccc
dddddddd dddddddd dddddddd dddddddd cccccccc cccccccc cccccccc

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5 Disk 6 Disk 7

d: data bit
c: control bit

86
RAID 3

• Improved on RAID 2 in terms of space efficiency


• Only one control bit is used for k data bits
– That control bit is a parity bit
– compute the parity of k bits and store it in the parity bit.
– k can be 4, 8, …
• This is enough to detect and correct one bit errors
even parity
P

b b b b p 1 0 1 1 1
example
b b b b p 0 1 0 1 0

overhead/data = 1/4
87
RAID 3: example

b0 b1 b2 b3 p

b4 b5 b6 b7 p

… …. …. … ….

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5

88
RAID 3: example

1 0 1 1 1

0 1 0 1 0

… …. …. … ….

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5

Even parity is used here

89
RAID 3: example

Let one disk fail! How can we recover its data

1 0 1 1 1

0 1 0 1 0

… …. …. … ….

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5

Look to disks 1, 2, 4, and 5. compute the parity and according to that


generate the content of disk 3.

90
RAID 3: example

1 0 11 1 1

0 1 00 1 0

… …. …. … ….

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5

91
RAID 4

• Uses block level striping (like RAID 0)


• But uses an additional disk to store the parity block
– Error recovery as in RAID 3

Parity
Block 0 Block 1 Block 2 Block 3
Block
Parity
Block 4 Block 5 Block 6 Block 7
Block
Parity
Block 8 Block 9 Block 10 Block 11
Block
….

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5

92
RAID 5

• Parity blocks are distributed on other disks. Similar to RAID 4.

• Load on parity disk is distributed in this way

Parity
Block 0 Block 1 Block 2 Block 3
Block

Parity
Block 4 Block 5 Block 6 Block 7
Block
Parity
Block 8 Block 9 Block 10 Block 11
Block
….

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5

93
RAID 6

• Similar to RAID level 5 but uses not only a single parity bit, but multiple ECC bits to guards against multiple
disk failures

• Called also as: P+Q scheme.

• Reed-Solomon codes are used as ECC code.

• Example: 2-bits ECC code can be used for every 4-bits data.

94
RAID Levels (0 through 6) Summary

95
RAID Levels 0+1 and 1+0

First stripe, then mirror


RAID 0+1

RAID 1+1 First mirror, then stripe

96
RAID (0 + 1) and (1 + 0)(CO5)

6 August 2023 97
References

Books :
1.Silberschatz, Galvin and Gagne, “Operating Systems Concepts”, Wiley
2. SibsankarHalder and Alex A Aravind, “Operating Systems”, Pearson Education
3. Harvey M Dietel, “ An Introduction to Operating System”, Pearson Education
4. D M Dhamdhere, “Operating Systems : A Concept basedApproach”, McGraw Hill.
5.Charles Crowley, “Operating Systems: A Design-Oriented Approach”, Tata McGraw Hill
Education”.
6. Stuart E. Madnick & John J. Donovan, “ Operating Systems”, Tata McGraw

6 August 2023 98
6 August 2023 99

You might also like