MindMap Gallery 6. Input and output system
408 Postgraduate Entrance Examination Collection (Operating System 6), the input and output system is an indispensable part of the computer system. It ensures smooth communication and data exchange between the computer and external devices.
Edited at 2024-03-07 14:45:04This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
Chapter 6: Input and Output Systems
I/O system functions, models and interfaces
The objects managed by the I/O system are I/O devices and corresponding device controllers.
Basic functions of the I/O system
Hide physical device details
Device independence
Improve processor and I/O device utilization
Control I/O devices
Ensure proper sharing of devices
Error handling
Hierarchy of I/O software
User level I/O software
device independence software
Device driver (manufacturer developed)
Interrupt handler
hardware
I/O system layering
Interrupt handler
device driver
device independence software
I/O system interface
block device interface
Refers to a device that organizes and transmits data information in data blocks.
Typical block devices are disks and optical disks
Basic characteristics of block devices
①The transmission rate is high, usually several megabits per second;
② It is addressable, which means you can read/write any block randomly;
③The I/O of the disk device adopts DMA method.
Streaming device interface
Also known as character device, it refers to a device that transmits data information in single character units.
This type of equipment is generally used for data input and output, including interactive terminals and printers.
Basic characteristics of character devices
①The transmission rate is low;
② Not addressable, that is, the source address during input or the destination address during output cannot be specified;
③The I/O of character devices often adopts interrupt-driven mode.
Network communication interface
Provides network access function, allowing the computer to communicate with other computers or browse the Internet through the network.
I/O devices and device controllers
Classification
Use characteristics
storage device
I/O devices
Transmission rate points
Low speed devices (a few bytes - a few hundred bytes)
Typical devices include keyboard, mouse, and voice input
Medium speed devices (thousands - tens of terabytes)
Typical equipment includes line printers and laser printers
High-speed devices (hundreds of thousands – gigabytes)
Typical devices include tape drives, disk drives, and optical disk drives
The device does not communicate directly with the CPU, but with the device controller. There should be an interface between the device and the device controller.
Data signal: controller ← device ← controller
Transmit data signals, input and output bits
Control signal: controller → device
Signals for performing read and write operations
Status signal: current usage status of the device
device controller
Main function: Control one or more I/O devices to realize data exchange between I/O devices and computers
basic skills
Receive and recognize commands
Control register, command decoder
data exchange
Realize data exchange between CPU and controller, controller and device
Identify and report device status
address recognition
Configure the address decoder to identify different devices
data buffer
error control
Device controller components
Interface between device controller and processor (CPU)
Implement communication between CPU and device controller
Interface between device controller and device
The controller can connect to multiple devices
I/O logic
Realize control of equipment
The CPU uses this logic to send I/O commands to the controller
Command and address decoding
Memory mapped I/O
The driver loads a series of specific commands, parameters and other data converted from abstract I/O commands into the corresponding registers of the device controller. The controller executes these commands and implements the specific operations on the I/O device.
I/O channel
Purpose: To establish independent I/O operations (organization, management and termination), so that the I/O work processed by the CPU is transferred to the channel (liberating the CPU and achieving parallelism)
What are I/O channels?
It is a special processor that has instructions to complete I/O operations by executing channel programs.
Features: Single instruction (limited to instructions related to I/O operations), shared memory with the CPU
Basic process:
The CPU issues I/O instructions to the channel -> the channel receives the instructions -> retrieves the channel program from the memory to process the I/O -> issues an interrupt to the CPU
Channel type
byte multiplex channel
Low and medium speed connection sub-channel time slice rotation mode shares the main channel
Byte multiplex channels are not suitable for connecting high-speed devices, which promotes the formation of array-select channels for data transfer in arrays.
Array selection channel
This kind of channel can connect multiple high-speed devices, but it only contains one distribution sub-channel. Only one channel program can be executed within a period of time to control one device to transmit data until the device completes the transmission and releases the channel. The utilization rate of this channel is very low.
array multichannel
Contains multiple non-distribution sub-channels. The combination of the first two channels has better channel utilization.
Bottleneck problem
Reason: Insufficient channels
Solution: Increase the path between the device and the host without adding channels (the result is similar to an RS flip-flop)
Interrupt mechanism and interrupt handler
interrupt
Classification
Interrupt (external trigger)
Response to interrupt signals from external I/O devices
fell into (internal reason: divide by 0)
Interrupts caused by internal CPU events
Interrupt vector table (analog 51 microcontroller)
Entry address table of interrupt program
Interrupt priority
Interrupt handling methods with different degrees of urgency
How to handle multiple interrupt sources
Mask interrupt
Nested interrupts
Interrupt handler
Determine whether there is an unresponsive interrupt signal
Protect the CPU environment of the interrupted process
Transfer to the corresponding device handler
Interrupt handling
Resume the CPU context and exit the interrupt
device driver
It is the communication program between the I/O process and the device controller. Since it often exists in the form of a process, it will be referred to as the device driver process from now on.
The main task is to accept abstract requests from device-independent software in the layer above it and execute this request.
Function
1) Receive commands and parameters sent by the I/O process, and convert abstract requirements in the commands into specific requirements. For example, convert the disk block number into the disk surface, track number and sector number.
2) Check the legality of the user's I/O request, understand the status of the I/O device, pass relevant parameters, and set the working mode of the device.
3) Issue an I/O command. If the device is idle, immediately start the I/O device to complete the specified I/O operation; if the device is busy, hang the requester's request block on the device queue and wait.
4) Respond promptly to interrupt requests sent by the controller or channel, and call the corresponding interrupt handler for processing according to the interrupt type.
5) For computer systems with channels, the driver should also be able to automatically form a channel program based on the user's I/O request.
Device driver processing
Convert the abstract requirements for device control by users and upper-layer software into specific requirements for the device, such as converting the abstract requirements for disk block numbers into disk surfaces, tracks, and sectors.
Check the plausibility of I/O requests.
Read and check the status of the device to ensure that the device is ready.
Transfer necessary parameters, such as the number of bytes transferred, the first address of the data in main memory, etc.
Work mode settings.
Start the I/O device and check whether the startup is successful. If successful, control will be returned to the I/O control system. When the I/O device is busy transmitting data, the user process blocks itself and does not wake it up until the interrupt arrives. The CPU can do other things.
How to control I/O devices
The purpose of I/O control
Reduce CPU intervention in I/O control
Make full use of the CPU to complete data processing work
I/O control mode
Polled programmable I/O mode
Interrupt driven I/O mode
DMA control method
I/O channel control mode
DMA controller composition
Interface between host and DMA controller
Interface between DMA controller and block device
I/O control logic
Device-independent I/O software
basic concept
Meaning: The application is independent of the specific physical device used.
A driver is a piece of software closely related to the hardware (or device). To achieve device independence, a layer of software must be installed on the driver, called device independence software.
Advantages of Device Independence
Use the device by its physical device name
Logical device names introduced
Conversion of logical device name to physical device name (easy to implement I/O redirection)
device-independent software
Unified interface for device drivers
Cache management
error control
Allocation and recycling of independent equipment
Device-independent logical data blocks
Data structures in device allocation
Device Control Table DCT
Controller control table COCT
Channel control table CHCT
Obviously, in a system with channels, a process only has the physical conditions to perform I/O operations after obtaining the channel, controller and required equipment.
System Device Table SDT
Logical device table LUT
The allocation process, from those with many resources to those with tight resources: LUT->SDT->DCT->COCT->CHCT
In the process of applying for a device, search the mapping table between the logical device and the physical device according to the logical name of the I/O device requested by the user; use the physical device as an index to search for the SDT and find the DCT connected to the device; continue to search for the connection with the device. The COCT and CHCT connected by the device find a path.
User level I/O software
System calls and library functions
All functions provided by the OS to users must be obtained by the user process through system calls.
In C language and UNIX systems, there is almost a one-to-one correspondence between system calls (such as read) and the library functions (such as read) used by each system call. Microsoft's is called Win32API
Spooling system (spooling)
Spooling technology is a simulation of offline input/output systems
Main components
input/output well
input/output buffer
input/output process
well management program
Features (reflecting the virtuality of the operating system)
Improved I/O speed
I/O operations on data have evolved from low-speed devices to accessing data in input wells or output wells.
Convert exclusive devices to shared devices
What is actually assigned to the user process is not the printing device, but the storage area in the shared output well
Implemented virtual device functionality
Turn an exclusive device into multiple exclusive virtual devices.
Buffer management
Introduction of buffering (reason)
Ease the speed mismatch between CPU and I/O devices
Reduce the frequency of interrupts to the CPU and relax restrictions on the CPU interrupt response time
Improve parallelism between CPU and I/O devices
Solve the problem of data granularity mismatch
single buffer
That is, when the CPU calculates, the data is input into the buffer (the size depends on the size of T and C)
double buffer
That is, the CPU is allowed to work continuously (T continuously)
Ring buffer (designed for producers and consumers)
composition
multiple buffers
multiple pointers
use
Getbuf process
Releasebuf process
Sync issues
Buffer pool (understood as a larger buffer)
composition
Empty buffer queue (emq)
F(emq) is linked by empty buffers, and L(emq) points to the first and last buffers of the queue respectively.
input queue (inq)
F(inq) is linked by buffers filled with input data, and L(inq) points to the first and last buffers of the queue respectively.
Output queue (outq)
F(outq) is linked by buffers filled with output data, and L(outq) points to the first and last buffers of the queue respectively.
Getbuf and Putbuf processes
Containment: The buffer pool receives external data
Extraction: The outside world obtains data from the buffer pool
How buffers work (from the buffer's perspective)
Containment input
Extract input
Containment output
Extract output
Disk storage performance and scheduling
Data organization and format
Disk type
Fixed head disk (expensive)
moving head disk
Disk access time (critical)
Seek time Ts=m*n s
Rotation delay time Tr
Transmission time Tt=b/rN
Total time Ta=Ts 1/2r b/rN
Disk scheduling algorithm (master chart)
First come, first served (FCFS)
Pros: Fair, simple
Disadvantages: It may cause the requests of some processes to not be satisfied for a long time
Shortest seek time first (SSTF)
Description: The track required to be accessed is closest to the track where the current head is located, so as to minimize each seek time.
Scan algorithm (SCAN)
The scanning algorithm not only takes into account the distance between the track to be accessed and the current track, but also gives priority to the current moving direction of the track.
Lenovo elevator operation
Prevents "starvation" of low-priority processes
Circular Scan Algorithm (CSCAN)
The algorithm stipulates that the magnetic head moves in one direction, for example, it only moves from the inside out. When the magnetic head moves to the outermost track and accesses it, the magnetic head immediately returns to the innermost track to be accessed, that is, the smallest track number is followed by the largest track number. Loop, perform loop scan
NStepScan algorithm
The N-step SCAN algorithm divides the disk request queue into several sub-queues with a length of N, and the disk scheduling will sequence these sub-queues according to the FCFS algorithm.
FSCAN algorithm
It is a simplification of the Nstepscan algorithm, which divides the disk request queue into two sub-queues.