what is a buffer in an os?

what is a buffer in an os?


Buffering

 SOFTWARE ORGANIZATION:

The software also plays a very important role in the management of I/O devices. The most important software is system software such as operating systems and device drivers that control different I/O devices. Different I/O  operating are performed through the supervisor calls of the operating system. Similarly, application programs provide interfaces for a user to perform various I/O operating via operating systems.

The operating system is organized into a series of layers. Each layer performs the related subset of function. Ideally, the layer should be defined separately, so that changes in one layer may not require changes in other layers. Mostly, the lower layer is concerned with hiding the peculiarities of the hardware from the upper ones, and the upper layer is concerted with providing an interface to the users. Therefore, some parts of the operating system must interact directly with the computer hardware and the other parts of the operating system to communicates with the user or application programs. The use of a set of layers conforms nicely to this environment.

Some characteristics of devices affect the supervisor's calls. The details are given below:

Device Speed:  

Please recall that the I/O operating of devices are relatively slowing than the speed of the CPU. The CPU may wait until the I/O operating is completed. So the execution of the application or process is suspended. The process is moved from running state to waiting for the state. If the operating system uses the blocking I/O operating.

Some operating system provides the facility of non-blocking I/O operating or calls. A non-blocking call does not suspend the execution of the process. Either the process continues to executive code or another process is selected from the real queue for execution. On the other hand, I/O operating on the I/O device also continues in parallel.

Network I/O:

Some operating systems provide a network I/O interface. These operating systems have built-in protocols used for network communication. Applications are provided with a set of network I/O system calls. The most popular and commonly used network I/O interface is the socket interface. A socket has a double-sided network jack. It is connected to a computer system on one side and to a remote computer system on the other side.

System calls in the socket interface enable an application to create a socket for the following purposes;
  1. To establish a connection to a socket on a remote computer.
  2. To detect if other computers have established a connection with a local socket.
  3. To send and receive a message on established connections etc.

Logical I/O:

The logical I/O level of device management software uses semi-device independent kernel I/O objects. It is concerned with managing general I/O or input and output functions on behalf of user processes of  computer and network , allowing them to deal with the computer system device in terms of services of a device identifier and simple commands such as Read, Write, Open, etc.

Buffering:

A buffer is a temporary memory area that stores any type of data. while it is transferred between an application program and a device. (or between two devices). Buffering is the important service provided by the I/O system.  Buffering is required in a computer system for several reasons.

  • To manage the speed mismatch between the producer and consumer of the data stream. For example, to print a document on a printer, the buffering technique is used. It is because the printing speed of the printer is much lower than the speed of the CPU. Multiple buffers may be used in a system for the same I/O operating.
  • Some devices use DMA to transfer data. Buffers are used as destination or source of transfer in a system.
  • When an application manipulates data then the output is copied into a buffer and the application continues to execute for processing other tasks

The operating system provides the following main kinds of buffering.

Single Buffering:

In single buffering, the operating system assigns a single memory area for transferring data. When a user-program requests an I/O operating, the block of data is transferred to this buffer, and then the whole block of data from the buffer is transferred into the user-program memory. This type of buffering suspends the execution of the program until the whole is transferred. This is the main drawback of this type of buffering.

Double Buffering:

In double buffering, the operating system uses two buffers for transferring data: Data is transferred from the I/O device to the first and then to the second buffer before transferring to the user program. This type of buffering does not suspend the execution of the program as in the case of Single Buffering.

Caching:

A cache is a region of fast memory, where a copy of data is stored for a certain period of time in order to have fast access. Mostly, a process needs the intermediate result of I/O operations for a certain period of time.

Caching and buffering:

Caching and buffering are distinct functions in a computer network system, but sometimes a region of memory can be used for both purposes in a system technology. For example, the operating system uses buffers in the main memory to hold data of files. These buffers can also be used as a cache to prove the I/O performance for file operations. Typically, an operating system creates a buffer in memory to be used as a cache.

 Device Drivers:

Device drivers are system software that controls the functioning of the device controller. The device drive understands the system device controller and presents a uniform interface to the driver in a network technology. Each device driver handles one or more closely related devices. 
The devices driver can be thought of as a translator. It accepts high-level commands such as "retrieve block 106" from disk. Then it translates the high-level commands into low-level that are used by the hardware controller, which interfaces the I/O device to the computer system.

We know that each controller has one or more device register used to give it commands. Device drivers issue these commands and check that they are carried out properly in a system computer. Some controller can handle only one command at a time.






Comments

Popular posts from this blog

Modern scenario of information technology:

Types of Data Access Methods

Output devices Tutorials point