Input and Output system
The process of giving input to computer and giving output from computer is called input/ output. The mechanism almost same for input and output. The operating system is mainly responsible for input output operating interrupt and error handling is important terms related to input/outputs. So, operating system is responsible to handle interrupt and error. It should also provide an interface between the device and rest of system.
Principles of I/O hardware
Different people look at I/O hardware in different ways. Electrical engineer look at in term of chips, wires, power supplies and all other physical components that make up the hardware programmers look at interface presented to the software the commands the hardware accepts, the functions it carries out and the error that can be reported back.
I/O devices are divided into two categories:-
1. Block devices: - A block devices is one that store information in fixed-sized blocks, each one, with its own address common blocked size ranges from 512 bytes to 32768 bytes. The essential property of a block device is that it is possible to read or write each block independently of all the other ones. In other word, at any instant, the program can read or write any of the blocks. The common examples of block device are disk. A disk is block addressable device because no matter where the arm currently is, it is always possible to seek to another cylinder and then wait for another block to rotate the head.
2. Character devices: - A character device is one that delivers or accepts a stream of characters, without regards to any blocks structure. It is not accessible and does not have any such operation. The examples of character devices are printers, paper tapes, network interface card, mice and most other devices that are not disk like can be seen as.
I/O units typically consist of mechanical part and the electronic part. The electronic part is also called the device controller or adapter. On pc, device controller takes the form of printed circuit card that can be inserted into an expansion slots. The controller card actually has a connected on it, into which a cable leading to the device itself can be plugged many controllers can handle more than one identical devices. The standard for interface between controller and device are ANSI, ICE, IDE, SCSI, ISO etc.
The interface between the controller and device is often a very low level interface. The controller job is to convert the serial bit stream into a block of bytes and perform any error. Correction if necessary the block of bytes is typically first assembled, bit by bit in a buffer inside the controller. After its checksum has been verified and block declared to be error free, it can then be copied to main memory.
Each controller has some registers for communicating with CPU and many devices have data buffer, which the CPU can read and write data. The issues that arise of how the CPU communicates with the controller registers and the device data buffer has two alternatives.
- I/o mupped I/o:- in this approach, each control register is assign an i/o port number and 8 bits or 16 bits integer. The scheme uses I/O instruction for I/O such as in OUT PORT, REG (CPU register).
- Memory mupped I/O:- in this approach, all the control register are mapped into the memory space. Each control register is assigned a unique memory address to which no memory is assigned. Usually, the assigned address is at the top of the address space. In this approach memory instruction like mov, stor, load are used.
The general connection of device controller:-
Device controller is interface between I/O device and computer. The computer here indicates CPU and memory. CPU memory controllers all are connected to system bus. The controller takes information and gives information to the operating system from the system memory. Large mainframe computer uses I/O channel for I/O processing where I/O channels are processor.
An interrupt is a special request signal originated from some device to CPU to achieve the CPU time for some job. Interrupt is identified by some special number and is managed by interrupt controller.
Input and output can be done in three different ways. In this simplest method, a user program issues the system call, which the kernel then translates into a procedure call to the appropriate driver. The driver then starts the I/O and sits in the tight loop continuously. Polling the device to see if it is done when the I/O has completed, the driver puts the data where they are needed and returns. The operating system then returns control to the caller. This method is called busy waiting and has the disadvantage of typing up the CPU pooling the device until it is finished.
The second method is for the driver to start the device and ask it to give an interrupt when it is finished. At that print the driver returns. The operating system then blocks the caller if need be and looks for other work to do. When the controller detects the end of transfer, it generates an interrupt to signal completion.
The general goals for I/O software are easy to state. The basic idea is to organize the software as a series of layers, while the lower ones and the upper ones concerned with presenting a nice, clean, regular interface to the user.
Layers of I/O software
The layers of I/O software system are described below:-
a. User level I/O software: - these are application level software which use I/O system calls for the input and output for example, in c programming, printf and scanf functions are used for output and input. Not all user level software consists of library procedures. Another important category is the spooling system. It is the way of dealing with delicate I/O devices in the multiprogramming system. In printer, a special process called a daemon and a special directory called a spooling directory are used to manage the output. To print a file, a process that generates the entire file to be printed and puts it in the spooling directory to use the printer’s special file, to print the file in directory.
b. Device independent i/o software:- The basic function on device independent i/o software or operating system are:-
- To provide uniform interface to the user level software.
- To perform I/O functions those are common to all devices.
- Error reporting.
- Allocating and relating dedicated devices.
- Providing a device independent block size.
- Device naming.
- Device protection.
Different disk may have different sizes. It is up to the devices independent software to hide this fact and provide a uniform block size to higher layers.
c. Device driver: - each and every I/O device attached to computer needs some device specific code for controlling it. This code is called as device driver, written by devices manufacturer and deliver along with the device. Drivers are specific to operating system. A driver in computer science is a software program that expands the capability of computer to control various input and output devices. Many driver programs come as the part of computer’s operating system. The software that schedules task, allocates data storage and co-ordinates data transmission between the computer, connect5ed devices and other computers. When connecting peripherals devices, the user often must load a new driver into the computer for each device. All devices require driver program to function.
In computer a driver serves as a translator between the devices and the program that send commands to the devices. When user selects the print command in word processing program, a program sends the generic comment to print, through operating system. The driver interpret commands and translate it, converting it into specialized command that printer can understand. The driver program then access the hardware registers of the devices.
The command issues from the application program is send to device controller and store the information to device controller’s register and provide for device driver. In case of printer the information cannot perform by storing information in device driver it to provide error reporting to the caller procedure as well as status reporting of device.
d. Interrupt handler: - Many devices have an interrupt handler that notifies user if a device’s functionality is interrupted. The driver software may then supplies the user with information on the device and often error co procedure message in dos driver file has .sys extension. In windows driver file has .read.drv.
- Introduction to operating system Operating System: An operating system is a collection of system...
- supervisor and user mode of operating system supervisor and user mode: The process is executed in the...
- Types of operating systems An operating system can also be divided into many types...
- What is kernel? Kernel: All the operating involving processes are controlled by a...
- Introduction to Processes in operating system Early computer system allowed any one program to be...