Download presentation
Presentation is loading. Please wait.
Published byJacob Cooper Modified over 7 years ago
1
Input/Output (I/O) Important OS function – control I/O
Should present device independent interface. Interested in programming aspects, not how it works internally. Block devices – info is in fixed size blocks (i.e. 512 bytes to bytes) each block has an address. Blocks can be read and written independently. Disks are an example.
2
Input/Output (I/O) Character devices – works with streams
of chars, not blocks. Solaris disk example: /dev/dsk/ disk devices are block while /dev/rdsk/ disk devices are character.
3
Input/Output (I/O) I/O controllers have some control
registers the OS can write into. - to make a device perform some operation. - can also read to get status Many devices have a data buffer (i.e. Video RAM)
4
Input/Output (I/O) One way to write or read device port
is to have instructions r/w a control register – separate I/O and memory Another way is to have memory-mapped I/O where the control registers are assigned an address space. Could also have a hybrid approach.
5
Direct Memory Access (DMA)
Having the cpu request data from an I/O controller is a waste of its time. A DMA controller has access to the system bus independent of the cpu. Cycle stealing – DMA competes with cpu for bus and will delay the cpu.
6
I/O methods Programmed I/O – uses polling or
“busy waiting”. Checks the status of device in a loop. Wastes the cpu. OK in an embedded system where the cpu has nothing else to do. Interrupt-driven I/O – Allow cpu to context switch to another job and receive an interrupt when I/O is done.
7
I/O methods I/O with DMA – cpu not involved
DMA controller takes care of things allowing cpu to do other things The DMA controller can write directly to memory w/o the cpu.
8
More I/O Device drivers handle much of the I/O.
Need a driver for each type of device. - present a device independent view. Modules can be loaded dynamically rather than compiled into kernel. Block and character devices major device number locates driver minor device number is parameter to driver for with unit. /dev files protected with permission bits.
9
Buffering More efficient to buffer data than to
interrupt after each character. User buffers and kernel buffers. When kernel buffer fills copy to user buffer Double buffering – have two kernel buffers start filling second while copying full buffer to user space.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.