Академический Документы
Профессиональный Документы
Культура Документы
Group: A set of user who is sharing the file and need similar access is a group, or work group.
1. It is to cope with a speed mismatch between the producer and consumer of a data stream
Example:
A file is being received via modem for storage on the hard disk. The modem is about a thousand
times slower than the hard disk. So a buffer is created in main memory to accumulate the bytes
received form the modem.
When an entire buffer of data has arrived, the buffer can be written to disk in a single operation.
The modem needs the two buffers to store additional incoming data, two buffers are used.
After the modem fills the first buffer, the disk write is requested. When the modem the starts to fill
the second buffer while the first buffer is written to disk. By the time the modem has filled the
second buffer, the disk write from the first one should have completed, so the modem can switch
back to the first buffer while disk writes the second one. This is called double buffering.
2. A second use of buffering is to adapt between devices that have different data transfer sizes.
Buffers are used for fragmentation and reassembly of messages. At the sending side, a large
message is fragmented into small network packets. The packets are sent over the network, and the
receiving side places them in a reassembly buffer to form an image of the source data.
3. A third use of buffering is to support copy semantics for application I/O.
Copy semantics:
• An application has a buffer of data that it wishes to write to disk.
• It calls the write () system call, providing a pointer to the buffer and an integer
specifying the number of bytes to write.
• A write() system call to copy the application data into a kernel buffer before
returning control to the application.
• The disk write is performed from the kernel buffer, so that subsequent changes
to the application buffer have no effect.
6.caching
• A cache us a region of fast memory that holds copies of data.
• Access to the cached copy is more efficient than access to the original.
• The instructions of currently running process are stored on disk, cached in physical memory,
and copied again in the CPU’s secondary and primary caches.
• The difference between a buffer and cache is that buffer may hold the only existing copy of
data item, whereas a cache holds a copy on faster storage of an item that resides elsewhere.
• To enable efficient scheduling of disk I/O, the operating system uses buffers in main
memory to hold disk data.
• These buffers are also used as a cache, to improve the I/O efficiency for files that are shared
by applications or that are being written and reread.
6.spooling:
• A spool is a buffer that holds output for device, such as printer, that cannot accept
interleaved data streams.
• Although a printer can serve only one job at a time, several applications may wish to print
their output concurrently, without having their output mixed together.
• The operating system solves this problem by intercepting all output to the printer.
• Each application’s output is spooled to separate disk file.
• When an application finishes printing, the spooling system queues the corresponding spool
file for output to the printer.
• The spooling system copies the queued spool files to the printer one at a time.
• The operating system provides a control interface that enables user and system administrator
to display the queue to remove unwanted jobs before those jobs print, to suspend printing
while the printer is serviced.
7.I/O scheduling:
• To schedule a set of I/O requests means to determine a good order in which to execute
them.
• Scheduling can improve overall system performance; can share device access fairly
among process.
• It can reduce the average waiting time for I/O to complete.
Example:
Application 2 requests one near the beginning, and application 3 requests one in the middle of the
disk.
The operating system can reduce the distance that the disk arm travels by servicing the applications
in order 2,3,1.
8.Error Handling:
• An operating system protected the memory from the hardware failure and application errors.
• Devices and I/O transfers can fail in many ways, either for transient reasons, such as
network becoming overloaded, or for the permanent reasons, such as disk controller
becoming defective.
• Operating system can compensate for transient failure. For example, a disk read () failure
results in a read () retry (), and a network send () error results in a resend ().
• I/O system call will return 1 bit of information about the status of the call.
In UNIX operating system an additional integer variable named errno is used to return an
error code-one of about 100 values –indicating the general failure of the failure.
• For example a failure of a SCSI device is reported by the SCSI such as hardware error or an
illegal request and additional sense code that states the category of failure such as bad
command parameter or self test failure and additional sense code qualifier that gives even
more details.
UNIX I/O Kernel Structure
• The kernel needs to keep state information about the use of I/O components. It does so
through a variety of in Kernel data structures, such as the Open-file table structure.
• The kernel uses many similar data structures to track network connections, character
communications and other I/O activities.
• UNIX provides file-system to a variety of entities, such as user files raw devices, and the
address spaces of processes.
• Although each of these entities supports a read () operation, the semantics differ.
• For instance, to read a user file, the kernel needs to provide the buffer cache before deciding
whether to perform a disk I/O.
• To read a raw disk, the kernel needs to ensure that the request size is multiple of the disk
sector size, and is aligned on a sector boundary.
• Some operating systems use object oriented methods even more extensively.
• In Windows NT uses a message-passing implementation for I/O.
• An I/O request is converted into a message that is sent through the kernel to the I/O manager
and the to the device driver, each of which may change the message contents.
• The message passing simplifies the structure and designs the I/O system and adds flexibility.
16 marks questions
Mass-Storage Systems
• Disk structure
• Disk scheduling
• Disk management
• Swap-space management
Disk structure
• 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 into the sectors of the disk
sequentially.
o Sector 0 is the first sector of the first track on the outermost cylinder.
o 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.
Disk Scheduling
The operating system is responsible for using hardware efficiently — for the disk drives, this
means having a fast access time and disk bandwidth.
Access time has two major components
Seek time is the time for the disk are to move the heads to the cylinder containing the
desired sector.
Rotational latency is the additional time waiting for the disk to rotate the desired sector
to the disk head.
Minimize seek time
Seek time ≈ seek distance
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.
Several algorithms exist to schedule the servicing of disk I/O requests.
We illustrate them with a request queue (0-199).
Head pointer 53
FCFS
Illustration shows total head movement of 640 cylinders.
SSTF
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.
SCAN
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.
Sometimes called the elevator algorithm.
Illustration shows total head movement of 208 cylinders.
C-SCAN
Disk Management
1. Disk initialization
2. Booting from disk
3. Bad –block recovery
Disk formatting:
A new magnetic disk is a blank slate. Before a disk can store data; it must be divided into
sectors that the controller can read and write.
This process is called low-level formatting (or physical formatting)
It fills the disk with special data structure for each sector.
The data structure for a sector typically consists of a header, a data area and a trailer (512 bytes)
The header and trailer contain information used by the disk controller, such as a sector number and
an error code (ECC)
When the controller writes a sector of data during normal I/O, The ECC is updated with value
calculated from all the bytes in the data area. When the sector is read, the ECC is recalculated and is
compared with the stored value .If the stored and calculated numbers are different, this mismatch
indicates that the data area of the sector has become corrupted and the disk sector may be bad.
Logical formatting:
To use a disk to hold files, the operating system needs to record its own data structures on
the disk.
It does so in two steps
1. It partitioned the disk into one or more groups of cylinders. The operating
system can treat each partition as though it were a separate disk.
One partition can hold a copy of the operating system executable code.
Another holds user files.
2. The second step is logical formatting the operating system stores the
initial file
BOOT BLOCK
system data
structures onto
FAT
the disk
• The controller can be told to replace each bad sector logically with one of the spare sectors.
This scheme is known as sector sparing or forwarding.
Example
• A typical bad-sector transaction might be as follows .The Operating system tries to read
logical block 87
• The controlled calculates the ECC and finds that the sector is bad .It reports this finding
the operating system
• The next time that the system is rebooted, a special command is run to tell the SCSI
controller to replace the bad sector with a spare.
• After that whenever the system requests logical block 87, the request is translated into
the replacement sectors address by the controller.
Some controllers can be instructed to replace a bad block by sector slipping.
Logical block 17 becomes defective and the first available spare follows sector 202, then
sector slipping would remap all the sectors form 17 to 202.
Swap-space management:
Low levels task operating system
• How swap space is used
• Where swap space is located on disk
• How swap space is managed
Swap space use:
Implementing swapping may use swap space to hold the entire process image including the
code and data segments.
Swap space location:
Two places
• Out of the normal system
• It can be in separate disk partition
Swap space Management:
Enough space is aside to hold the program known as the text pages or the text segment and the
data segment of the process.
Swap Maps:
Two process swap maps are used by the kernel to track swap space use .The test segment is a fixed
size.
The text segment is a fixed size, so its swap space is allocated in 512 kB chunks, except for the final
chunk, which holds the remainder of the page
16 marks questions
1. Explain disk scheduling algorithms
2. Suppose that disk drive has 5,000 cylinders, numbers to 0 to 4000.The drive is currently serving a
request at cylinder 143 and the previous request was at cylinders 125.The queue of pending requests
in FIFO order is
86,1470,913,1774,1509,1022,1750,130.
Starting from the current head position what is the total distance that the disk arm moves to satisfy
all the pending requests for each of the following disk-scheduling algorithms?
• FCFS,SSTF
• SCAN
• LOOK
• C-SCAN ,C-LOOK
3. Explain disk structure with diagram
4. Explain swap space management
5. Explain disk management