i/o buffering operating system

Upload: nadhrah-nini

Post on 03-Apr-2018

243 views

Category:

Documents


4 download

TRANSCRIPT

  • 7/28/2019 I/O Buffering Operating System

    1/11

    PERATING SYSTEM

  • 7/28/2019 I/O Buffering Operating System

    2/11

    a) To cope with the speed mismatch between producer (or sender) and

    consumer (or receiver) of a data stream.

    b) To adapt between the devices having different data-transfer size.

    c) To support copy semantics for application I/O.

    A process of storing data in memory area calledBuffers

    while data is being transferred between two devices or

    between a device and an application.

    I/O BUFFERING

  • 7/28/2019 I/O Buffering Operating System

    3/11

    NO BUFFERING

    Process must read/write a device a byte/word a time.

    Each individual system call adds significant overhead. Process must what until each I/O is complete.

    i) Blocking/waking adds to overhead

    ii) Many short run of a process is inefficient.

    What happens if buffer is paged out to disk

    i) Could lose data while buffer is paged in

    ii) Could lock buffer in memory (needed for DMA), however many processes doing

    I/O reduce RAM available for paging.

    iii) Can cause deadlock as RAM is limited

    resource.

  • 7/28/2019 I/O Buffering Operating System

    4/11

    USER LEVEL BUFFERING

    User process can process one block of data while next block is read in.

    Swapping can occur since input is taking place in system memory, not user

    memory.

    Operating system keeps track of assignment of system buffers to user processes.

    Assume:

    T is transfer time for a block from device

    C is computation time to process incoming block

    M is time to copy kernel buffer to user buffer

    Computation and transfer can be done in parallel.

  • 7/28/2019 I/O Buffering Operating System

    5/11

    USER LEVEL BUFFERING

    Process specifies a memory buffer that incoming data is placed in until it fills.

    Filling can be done by interrupt service routine.

    Only a single system call, and block/wakeup per data buffer.

    Much more efficient.

    When is buffer available for re-use?

    Either process must block until potential slow device drains buffer

    OR deal with asynchronous signals indicating buffer drained

  • 7/28/2019 I/O Buffering Operating System

    6/11

    SINGLE BUFFERING

    ~ The simplest type of buffering ~

    Operating system assigns a buffer in Kernels memory for an I/O request .

    Stream Oriented

    i) Used a line at time.

    ii) User input from a terminal with carriage return signaling the end of the line.

    iii) Output to the terminal is one line at a time.

    Block-oriented

    i) Input transfers made to buffer

    ii) Block moved to user space when needed.

    iii) Another block is moved into the buffer. (Read ahead)

  • 7/28/2019 I/O Buffering Operating System

    7/11

    DOUBLE BUFFERING

    Use two system buffers instead of one.

    A process can transfer data to or from one buffer while the operating

    system empties or fills the other buffer.

    Computation and Memory copy can be done in parallel with transfer.

    May be insufficient for really burst traffic

    Lots of application writes between long periods of computation

    Long periods of application computation while receiving data

    Might want to read-ahead more than a single block for disk

  • 7/28/2019 I/O Buffering Operating System

    8/11

    CIRCULAR BUFFERING

    More than two buffers are used.

    Each individual buffer is one unit in a circular buffer.

    Used when I/O operation must keep up with process.

    Double buffering may be inadequate if the process performs rapid bursts of I/O.

    The problem can often be alleviated by using more than two buffers.

    When more than two buffers are used, the collection of buffers is itself referred

    to as a circular buffer with each individual buffer being one unit in the circular

    buffer.

  • 7/28/2019 I/O Buffering Operating System

    9/11

    UTILITY BUFFERING

    Buffering is a technique that smoothest out peaks in I/O demand. However, no

    amount of buffering will allow an I/O device to keep pace with a process

    indefinitely when the average demand of the process is greater than the I/O

    device can service. If offline operation after the data has been read and the

    CPU is operated on it the magnetic tapes are instructed to store the next input

    into some reserve memory area called buffer.

  • 7/28/2019 I/O Buffering Operating System

    10/11

    UTILITY BUFFERING Buffering is done for 3 reasons

    - To cope with the speed mismatch between producer (or sender) and consumer (or

    receiver) of a data stream

    - To adapt between devices having different data-transfer size

    - To support copy semantics for application I/O

    The time taken to complete a job is faster but the CPU is more utilized as the

    access time from memory to the CPU is faster than the access time from any I/O

    device to the CPU.

    Buffering overlaps I/O of a job with jobs computations. In a multiple

    programming environment, when there is a variety of I/O activity and a variety

    of process activity to service, buffering is one tool that can increase the efficiency

    the OS and the performance of individual processes.

  • 7/28/2019 I/O Buffering Operating System

    11/11