DISK MANAGEMENT AND I/O Note:Some slides and/or pictures in the following are adapted from slides 02005 Silberschatz,Galvin,and Gagne. Many slides generated from Kubiatowicz
DISK MANAGEMENT AND I/O Note: Some slides and/or pictures in the following are adapted from slides ©2005 Silberschatz, Galvin, and Gagne. Many slides generated from Kubiatowicz
MODERN I/O SYSTEMS disk snq ISOS disk disk monitor disk cache graphics bridge/memory SCSI controller controller controller PCI bus IDE disk controller expansion bus keyboard interface disk disk expansion bus disk disk parallel serial port port
MODERN I/O SYSTEMS
THE GOAL OF THE I/O SUBSYSTEM o Provide Uniform Interfaces,Despite Wide Range of Different Devices This code works on many different devices: int fd open (/dev/something"); for (int i=0;i<10;i++){ fprintf(fd,"Count &dn",i); } close(fd); Why?Because code that controls devices (device driver")implements standard interface. o We will try to get a flavor for what is involved in actually controlling devices in rest of lecture Can only scratch surface!
THE GOAL OF THE I/O SUBSYSTEM Provide Uniform Interfaces, Despite Wide Range of Different Devices This code works on many different devices: int fd = open(“/dev/something”); for (int i = 0; i < 10; i++) { fprintf(fd,”Count %d\n”,i); } close(fd); Why? Because code that controls devices (“device driver”) implements standard interface. We will try to get a flavor for what is involved in actually controlling devices in rest of lecture Can only scratch surface!
WANT STANDARD INTERFACES TO DEVICES o Block Devices:e.g.disk drives,tape drives,Cdrom ·Access blocks of data Commands include open(),read(),write(),seek() Raw I/O or file-system access Memory-mapped file access possible Character Devices:e.g.keyboards,mice,serial ports,some USB devices Single characters at a time Commands include get(),put ( Libraries layered on top allow line editing o Network Devices:e.g.Ethernet,Wireless,Bluetooth Different enough from block/character to have own interface Unix and Windows include socket interface o Separates network protocol from network operation o Includes select (functionality Usage:pipes,FIFOs,streams,queues,mailboxes
WANT STANDARD INTERFACES TO DEVICES Block Devices: e.g. disk drives, tape drives, Cdrom Access blocks of data Commands include open(), read(), write(), seek() Raw I/O or file-system access Memory-mapped file access possible Character Devices: e.g. keyboards, mice, serial ports, some USB devices Single characters at a time Commands include get(), put() Libraries layered on top allow line editing Network Devices: e.g. Ethernet, Wireless, Bluetooth Different enough from block/character to have own interface Unix and Windows include socket interface Separates network protocol from network operation Includes select() functionality Usage: pipes, FIFOs, streams, queues, mailboxes
HOW DOES USER DEAL WITH TIMING? o Blocking Interface:“Wait” When request data (e.g.read()system call),put process to sleep until data is ready When write data (e.g.write (system call),put process to sleep until device is ready for data oNon-blocking Interface:“Don't Wait'” Returns quickly from read or write request with count of bytes successfully transferred Read may return nothing,write may write nothing o Asynchronous Interface:"Tell Me Later" When request data,take pointer to user's buffer,return immediately;later kernel fills buffer and notifies user When send data,take pointer to user's buffer,return immediately;later kernel takes data and notifies user
HOW DOES USER DEAL WITH TIMING? Blocking Interface: “Wait” When request data (e.g. read() system call), put process to sleep until data is ready When write data (e.g. write() system call), put process to sleep until device is ready for data Non-blocking Interface: “Don’t Wait” Returns quickly from read or write request with count of bytes successfully transferred Read may return nothing, write may write nothing Asynchronous Interface: “Tell Me Later” When request data, take pointer to user’s buffer, return immediately; later kernel fills buffer and notifies user When send data, take pointer to user’s buffer, return immediately; later kernel takes data and notifies user