This blog for my own summary of relevant knowledge written, if there is similar, purely coincidental.
The I/O system structure is categorized as follows:
External memory Device controller: CD, tape, disk;
Output device controller: CRT, laser printer, line printer, dot-matrix printer, color printer, speaker;
Process controller: Process Control I/O equipment;
Communication controller: Data communication equipment;
Input device controller: keyboard, mouse, voice input, stylus, scanner, image input device, other.
I/O Features: 1) I/O performance is often the bottleneck of system performance; 2) One of the large and complex operating systems: resources, Miscellaneous, concurrency, all from i/o;3) are closely linked to other functions, especially file systems
Equipment classification: Block equipment (with data blocks for storage, transmission of information, high transmission rate, addressable (random read-write)); Character devices (storing and transmitting information in characters, low transmission rate, non-addressable);
Storage Device Example: disk, tape, etc.; Transmission device: Network card, modem, etc. human-computer interaction device: monitor, keyboard, mouse
Resource Allocation Angle Classification:
Exclusive equipment: low-speed I/O devices, such as printers, tapes, etc.;
Shared devices: such as hard drives, etc.;
Virtual device: The slow exclusive device is changed to multiple users to share the device, improve the utilization of equipment. Spooling Technology
Goals and tasks for I/O management:
1) According to the user's request, control the various operations of the device, complete the data exchange between the I/O device and the memory, and finally complete the user's I/O request;
2) to establish a convenient, unified interface independent of the device;
3) Make full use of various technologies (channel, interrupt, buffer, asynchronous I/O, etc.) to improve the parallel working ability between CPU and equipment, equipment and equipment, make full use of resources and improve the utilization of resources;
4) protection.
The composition of the I/O Device: mechanical and electronic parts.
Device structure--controller function:
The operating system writes commands to the controller's structure register (or interface buffer) to implement input/output and read status information or result information from the interface register.
The task of the controller is to convert the serial bit stream into a byte block, and make the necessary error correction: First, the controller is assembled in bits, and then in the buffer inside the controller to form a block in bytes, and then copy it into memory when the block verification checks and proves that there is no error.
I/O directives are associated with I/O addresses in the main form: Memory image Addressing (memory image I/O mode), I/O stand-alone Addressing (I/O private instructions)
I/O stand-alone addresses are completely independent of the address space assigned to all ports in the system, regardless of the memory address space, and use specialized I/O directives to operate on the ports. Advantage: Peripherals do not occupy the memory of the address space, programming, easy to distinguish between the memory operation or the I/O port operation. Disadvantage: I/O side operation of the instruction type is small, the operation is not flexible.
Memory image I/O mode refers to the same address space assigned to all ports in the system as the address space of the memory, and the I/O port is treated as a storage unit, and the read and write operation of I/O is equivalent to the operation of memory. Advantage: Any instruction that can operate on memory can operate on I/O port, do not need special I/O instruction, and I/O port can occupy large address space. Cons: Takes up memory space.
Advantages of memory-mapped I/O: 1 No special protection mechanism is required to prevent user processes from performing I/O operations; Each instruction that can reference memory can also refer to the control register.
Disadvantages of memory-mapped I/O: 1) A Device control register cannot be cached; 2) the hardware and operating system need to control the cache.
I/O control mode: 1) programmable I/O (polling/query), 2) interrupt driver i/o;3) DMA
I/O Evolution:
1) CPU directly control peripheral equipment;
2) Increased controller or I/O parts, CPU uses non-disruptive programmable I/O;
3) Increase the controller or I/O parts, the CPU uses the interrupt programmable I/O;
4) I/O components directly control the memory via DMA;
5) I/O components are enhanced to a single processor, with instruction sets designed specifically for I/O, and the CPU directs the I/O processor to execute an I/O program in memory.
6) The I/O part has its own local memory (which is itself a computer).
I/O Software design
Layered design Ideas
1) Organize I/O software into multiple layers; 2) Each layer performs an associated subset of the functions required by the operating system, which relies on the more primitive functions performed by the lower layer, which can hide the details of these features, while at the same time providing services to a higher layer, 3) the lower layer considers the features of the hardware, and provide the interface to the higher layer software; 4) The higher layer does not depend on the hardware, and provides the user with a friendly, clear, simple, more powerful interface.
I/O soft layer: User-level I/O software, device-independent OS software, device drivers, interrupt handlers, hardware; Unified interface for drivers, buffering, error reporting, allocating and releasing devices, providing device-independent block sizes.
Device independence: From the user's point of view (when the user is coding, using the logical device name, the system from the logical device to the physical device (actual device) conversion, and implementation of I/O operations); From a system perspective (when designing and implementing I/O software, dealing with the underlying software that deals directly with the device, Other parts of the software are not dependent on the hardware).
The buffer technology solves the problem as follows: 1) solve the problem of the speed mismatch between CPU and I/O device, 2) improve the parallelism between CPU and I/O device, 3) reduce the number of interrupt requests of I/O device to CPU, and relax CPU's requirement of interrupt response time.
Buffer classification: Hard buffering and soft buffering
Buffer Management: Single-buffered, double-buffered, and buffer pools.
Using buffer pooling technology, the transfer of information between memory and disk can be smoothed and accelerated. Buffers, combined with advanced read and deferred write techniques, are useful for repetitive and paroxysmal I/O processes and for increasing I/O speed. You can take full advantage of data that was previously read from disk, although it has been passed into the user area, but still in the buffer (minimizing the number of disk I/OS, increasing the speed of the system).
Device management-related data structures
1) Describe the device, controller and other parts of the table;
2) Establish a queue of similar resources;
3) Dynamic Data structure for process I/O requests;
4) Establish the I/O queue.
Device Assignment:
Static allocation (before the process runs, complete the equipment allocation, the end of the run, recovery equipment, equipment utilization is low);
Dynamic allocation (in the process of running, when the user presents the device requirements, the allocation, once stopped using immediate recovery, good efficiency, the disadvantage is bad allocation strategy, resulting in deadlock)
Timeshare sharing refers to the use of devices at the time of a single I/O, and the I/O operations of different processes require the device to be queued for I/O.
Improve CPU Usage: You should make CPU utilization as low as possible from I/O and make the CPU as free of I/O as possible.
Reduce or mitigate the speed gap: buffer technology;
Make the CPU not wait for I/O: asynchronous I/O;
Let the CPU out of I/O operation: DMA, channel;
Windows provides both synchronous and asynchronous modes of I/O operations. Asynchronous mode: Used to optimize the performance of the application; synchronous I/O: The application is blocked until the I/O operation is complete.