I/O Buffering
-Rushabh Shah
Buffering Techniques
 Single Buffer
 Double Buffer
 Circular Buffer
Single Buffer
 When a user process issues an I/O request, the operating system allocates a buffer
in the system portion of main memory to the operation.
 Input transfers are made to the system buffer. When the transfer is complete, the
process moves the block into user space and request another block.
 Thus this approach will generally speedup the I/O operations requested by a
process
Double Buffer
 An improvement over single buffering is by assigning two system buffers to the
operations.
 In this case, moving data from one system buffer to the process and reading data
from the I/O device to the other buffer may be performed simultaneously
Circular Buffer
 Double buffering is when more than two buffers are used and the collection of
these buffers is referred to as a circular buffer.
 It may be inadequate, if the process performs rapid burst of I/O. When two or more
buffers are used.
 In this way, although the I/O device is much slower, there may be enough data in
the system buffers for the process to read.
Disk Scheduling
-Rushabh Shah
Disk Scheduling
 A process needs two type of time, CPU time and IO time. For I/O, it requests the
Operating system to access the disk.
 However, the operating system must be fare enough to satisfy each request and at
the same time, operating system must maintain the efficiency and speed of process
execution.
 The technique that operating system uses to determine the request which is to be
satisfied next is called disk scheduling.
Purpose & Goal
Purpose:
 The main purpose of disk scheduling algorithm is to select a disk request from the
queue of IO requests and decide the schedule when this request will be processed.
Goal:
 Fairness
 High throughout
 Minimal traveling head time
Disk Scheduling Algorithms
 FCFS scheduling algorithm
 SSTF (shortest seek time first) algorithm
 SCAN scheduling
 C-SCAN scheduling
 LOOK Scheduling
 C-LOOK scheduling
FCFS Scheduling Algorithm
 It is the simplest Disk Scheduling algorithm. It services the IO requests in the order
in which they arrive. There is no starvation in this algorithm, every request is
serviced.
Disadvantages
 The scheme does not optimize the seek time.
 The request may come from different processes therefore there is the possibility of
inappropriate movement of the head.
Example
 Consider the following disk request sequence for a disk with 100 tracks 45, 21, 67,
90, 4, 50, 89, 52, 61, 87, 25
 Head pointer starting at 50 and moving in left direction. Find the number of head
movements in cylinders using FCFS scheduling.
Solution
Number of cylinders moved by the head
= (50-45)+(45-21)+(67-21)+
(90-67)+(90-4)+(50-4)+(89-50)+
(61-52)+(87-61)+(87-25)
= 5 + 24 + 46 + 23 + 86 + 46 +
49 + 9 + 26 + 62
= 376
SSTF Scheduling Algorithm
 Shortest seek time first (SSTF) algorithm selects the disk I/O request which requires
the least disk arm movement from its current position regardless of the direction. It
reduces the total seek time as compared to FCFS.
 It allows the head to move to the closest track in the service queue.
Disadvantages
 It may cause starvation for some requests.
 Switching direction on the frequent basis slows the working of algorithm.
 It is not the most optimal algorithm.
Example
 Consider the following disk request sequence for a disk with 100 tracks
 45, 21, 67, 90, 4, 89, 52, 61, 87, 25
 Head pointer starting at 50.
 Find the number of head movements in cylinders using SSTF scheduling.
Solution
• Number of cylinders = 5 + 7 + 9 + 6 + 20 + 2 + 1 + 65 + 4 + 17 =
136
I/O buffering
 The process of temporarily storing data that is passing between a processor and
a peripheral.
 The usual purpose is to smooth out the difference in rates at which the two
devices can handle data
 The zero-capacity case is sometimes referred to as a message system with no
buffering. The other cases are referred to as systems with automatic buffering.
Zero capacity.
 The queue has a maximum length of zero; thus, the link cannot have any messages waiting in it
Bounded capacity.
 The queue has finite length n; thus, at most n messages can reside in it. If the queue is not full
when a new message is sent, the message is placed in the queue.
Unbounded capacity.
 The queue’s length is potentially infinite; thus, any number of messages can wait in it. The sender
never blocks.
I/O buffering & disk scheduling

I/O buffering & disk scheduling

  • 1.
  • 2.
    Buffering Techniques  SingleBuffer  Double Buffer  Circular Buffer
  • 3.
    Single Buffer  Whena user process issues an I/O request, the operating system allocates a buffer in the system portion of main memory to the operation.  Input transfers are made to the system buffer. When the transfer is complete, the process moves the block into user space and request another block.  Thus this approach will generally speedup the I/O operations requested by a process
  • 5.
    Double Buffer  Animprovement over single buffering is by assigning two system buffers to the operations.  In this case, moving data from one system buffer to the process and reading data from the I/O device to the other buffer may be performed simultaneously
  • 7.
    Circular Buffer  Doublebuffering is when more than two buffers are used and the collection of these buffers is referred to as a circular buffer.  It may be inadequate, if the process performs rapid burst of I/O. When two or more buffers are used.  In this way, although the I/O device is much slower, there may be enough data in the system buffers for the process to read.
  • 9.
  • 10.
    Disk Scheduling  Aprocess needs two type of time, CPU time and IO time. For I/O, it requests the Operating system to access the disk.  However, the operating system must be fare enough to satisfy each request and at the same time, operating system must maintain the efficiency and speed of process execution.  The technique that operating system uses to determine the request which is to be satisfied next is called disk scheduling.
  • 11.
    Purpose & Goal Purpose: The main purpose of disk scheduling algorithm is to select a disk request from the queue of IO requests and decide the schedule when this request will be processed. Goal:  Fairness  High throughout  Minimal traveling head time
  • 12.
    Disk Scheduling Algorithms FCFS scheduling algorithm  SSTF (shortest seek time first) algorithm  SCAN scheduling  C-SCAN scheduling  LOOK Scheduling  C-LOOK scheduling
  • 13.
    FCFS Scheduling Algorithm It is the simplest Disk Scheduling algorithm. It services the IO requests in the order in which they arrive. There is no starvation in this algorithm, every request is serviced. Disadvantages  The scheme does not optimize the seek time.  The request may come from different processes therefore there is the possibility of inappropriate movement of the head.
  • 14.
    Example  Consider thefollowing disk request sequence for a disk with 100 tracks 45, 21, 67, 90, 4, 50, 89, 52, 61, 87, 25  Head pointer starting at 50 and moving in left direction. Find the number of head movements in cylinders using FCFS scheduling.
  • 15.
    Solution Number of cylindersmoved by the head = (50-45)+(45-21)+(67-21)+ (90-67)+(90-4)+(50-4)+(89-50)+ (61-52)+(87-61)+(87-25) = 5 + 24 + 46 + 23 + 86 + 46 + 49 + 9 + 26 + 62 = 376
  • 16.
    SSTF Scheduling Algorithm Shortest seek time first (SSTF) algorithm selects the disk I/O request which requires the least disk arm movement from its current position regardless of the direction. It reduces the total seek time as compared to FCFS.  It allows the head to move to the closest track in the service queue. Disadvantages  It may cause starvation for some requests.  Switching direction on the frequent basis slows the working of algorithm.  It is not the most optimal algorithm.
  • 17.
    Example  Consider thefollowing disk request sequence for a disk with 100 tracks  45, 21, 67, 90, 4, 89, 52, 61, 87, 25  Head pointer starting at 50.  Find the number of head movements in cylinders using SSTF scheduling.
  • 18.
    Solution • Number ofcylinders = 5 + 7 + 9 + 6 + 20 + 2 + 1 + 65 + 4 + 17 = 136
  • 19.
    I/O buffering  Theprocess of temporarily storing data that is passing between a processor and a peripheral.  The usual purpose is to smooth out the difference in rates at which the two devices can handle data  The zero-capacity case is sometimes referred to as a message system with no buffering. The other cases are referred to as systems with automatic buffering.
  • 20.
    Zero capacity.  Thequeue has a maximum length of zero; thus, the link cannot have any messages waiting in it Bounded capacity.  The queue has finite length n; thus, at most n messages can reside in it. If the queue is not full when a new message is sent, the message is placed in the queue. Unbounded capacity.  The queue’s length is potentially infinite; thus, any number of messages can wait in it. The sender never blocks.