I / O device management

Core technologies:
1.I / O device abstract view of the file
2. The device controller
3. The hardware drivers, interrupt handler
4. The other I / O management: DMA control, channel technology, I / O buffers technology
improved utilization of equipment, improve the degree of parallel operation between the CPU and I / O devices

The core work process:
1.CPU transmission instruction (write, read, open, close ) to the register of a hardware controller
2. The driver will translate electrical command
execution controller 3. The electrical signal instruction, completes the hardware operation
4. Controller returns an interrupt to the CPU, CPU to run the interrupt handler processing interruptions, the exchange of information and memory.

Code Example: mouse moves
the mouse from (2,2) to (3,5)
to obtain the coordinates of the mouse 1. The controller changes an electrical signal
2. mouse driver code is translated into an electrical signal
3. The transmitted to the CPU, the trigger interrupt handler, CPU processing interrupt code (send instructions to the graphics card)
4.CPU code (2,2-3,5) to the display controller (video card)
5. the card code execution instruction to the screen (the cursor 2 , 2-3,5)
6. send interrupt to the CPU card (2,2-3,5), represents finished
7.CPU interrupt process, the new position of the cursor stored in memory 3,5.
Here Insert Picture Description

1. the I / O device controller : a register and a controller for controlling the hardware. It is essentially a chip
speaker - sound card, display - graphics, disk - disk controller, mouse - mouse controller

CPU issues an instruction to the graphics card in the register, the controller will manipulate the actual hardware circuit by calculation according to an instruction register. For programmers, use peripheral controller is actually issued instructions
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
2. The interrupt handler :
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
3. Device Drivers :
device drivers for the hardware itself will function tell the operating system, the electronic device signals the completion of the hardware and operating system translation each other and high-level programming language software. The driver is added to the operating system in a small piece of code that contains information about the hardware, the computer may communicate with the device based on this information

When the operating system requires the use of a piece of hardware, such as: make a sound card to play music, it will first send the appropriate commands to the sound card drivers, sound card drivers have been received, immediately translated into an electrical signal commands a sound card to understand, so let the sound card to play music.
Here Insert Picture Description
Here Insert Picture Description
Device abstraction as file views :
Here Insert Picture Description
Here Insert Picture Description

Other examples of abstract and summary
Printf works
Printf: a string that is output memory buffer to the screen
Fprintf (file write): that is, the memory buffer period character is moved on the disk
operating system is a management hardware layer software, hardware abstraction software, hardware details screen, user-friendly

CPU abstract for the process
I / O device (disk) abstract as a file
memory like virtual memory page abstract

Here Insert Picture Description


Other I / O Control: Solution CPU and I / O device operation processing speed mismatch problems and improve the performance of the CPU with the hardware concurrency process.

DMA control :
without interrupting the program to exchange data with memory. The DMA control disk input and output, but also controls the exchange of data with the memory.
DMA mode, Direct Memory Access, also referred to as a set of data transfer mode, sometimes referred to as direct memory operation. DMA mode during data transfer, there is no saving the site, site restoration work and the like.
Since the CPU does not participate in the transfer operation, thus eliminating the need for CPU instruction fetch, fetch, and so the number of pumping operation. Modifying the memory address, transfer count the number of words, etc., it is not implemented by software, but hardware implementation direct line. It can meet the requirements of high-speed DMA mode I / O devices, the CPU is also conducive to efficient play.
Here Insert Picture Description
Channel program :
channel data is possible through
the CPU issues a command channel, and the channels and peripherals exchange data, then the CPU to do other things, channels and peripherals exchange data after completion report to the CPU, then CPU processing
Here Insert Picture Description
Here Insert Picture Description
I / O buffer : in order to coordinate and cpu io device (keyboard, display) speed uncoordinated proposed IO buffer

getchar () is a blocking function
call to fputs, when in fact the buffer is written, calling fclose when it is actually written to the device
if we do not want the data written to the buffer, but directly into the device, you need to use
fflush immediately flush the buffer immediately buffer data into the target location
Here Insert Picture Description

Published 54 original articles · won praise 1 · views 2737

Guess you like

Origin blog.csdn.net/weixin_44682507/article/details/103747380