DJ5-1/2 I/O System (Lesson 1)

Table of contents

5.1 Functions, models and interfaces of the I/O system

5.1.1 Basic functions of the I/O system

5.1.2 Hierarchy and model of the I/O system

5.1.3 I/O system interface

5.2 I/O devices and device controllers

5.2.1 I/O equipment

5.2.2 Device controller

5.2.3 I/O paths

5.2.4 Bus system


 

5.1 Functions, models and interfaces of the I/O system

5.1.1 Basic functions of the I/O system

1. Hide the details of the physical device

2. Independence with equipment

3. Improve the utilization of processors and I/O devices (parallel operation)

4. Control the I/O equipment (four control methods)

  • Program I/O method
  • interrupt mode
  • direct memory access mode
  • channel mode

5. Ensure correct sharing of devices (device sharing attributes)

6. Error handling

5.1.2 Hierarchy and model of the I/O system

The overall design goals are: high efficiency and versatility.

  1. I/O device and CPU concurrency
  2. Simple abstraction, clear and unified interface

1. Hierarchy of I/O software

1) User layer software: realize the interface for interacting with the user, and the user can directly call the library functions related to I/O operation provided in the user layer to operate the device.

2) Device independence software: responsible for realizing the unified interface with the device driver, device naming, device protection, device allocation and release, etc., and providing necessary storage space for device management and data transmission.

3) Device driver: It is directly related to the hardware and is responsible for implementing the operation instructions issued by the system to the device and driving the I/O device to work.

4) Interrupt processing program: used to save the CPU environment of the interrupted process, transfer to the corresponding interrupt processing program for processing, and then restore the scene of the interrupted process and return to the interrupted process.

2. Hierarchical view between various modules in the I/O system

5.1.3 I/O system interface

1. Block device interface

Typical representative: Disk

  • Data access and transmission is a device in units of data blocks.
  • The basic feature is a high transfer rate, usually several megabytes per second.
  • Addressable: It can specify the input source address of the data and the output target address.
  • The I/O of the block device adopts the DMA method.

2. Stream device interface (character device interface)

Typical representatives: keyboard, printer

  • Data access and transmission are devices in units of characters.
  • The basic characteristic is that the transfer rate is extremely low, usually a few bytes to thousands of bytes per second.
  • Unaddressable: The input source address and output destination address of the data cannot be specified.
  • The I/O of stream devices is interrupt-driven.

3. Network communication interface

The OS must provide corresponding network software and network communication interface, so that the computer can communicate with other computers on the network or browse the Internet through the network.


///dev目录下存放的都是设备文件
int fd = open("/dev/something");

for (int i = 0; i < 10; i++) {		
    fprintf(fd, "Count %d\n", i);	
}

close(fd);

1. The operating system provides users with a unified interface, no matter what device is open, read, write and close.

2. Different devices correspond to different device files, and the device attributes are stored in the device files.

5.2 I/O devices and device controllers

I/O system: refers to the system used to realize data input and output and data storage.

5.2.1 I/O equipment

1. Types of I/O devices

2. The interface between the device and the controller

CPU -- controller -- device

Devices do not communicate directly with the CPU, but with the device controller. Therefore, an interface with the device controller should be included in the I/O device.

1) Data signal line: transmit data signals between the device and the controller.

2) Status signal line: transmits a signal indicating the current status of the device. Such as: reading/writing, or preparing for new data transmission.

3) Control signal line: the path through which the device controller sends control signals to I/O. Such as: read, write control, etc.

5.2.2 Device controller

① The main function of the device controller: to control one or more I/O devices to realize data exchange between the I/O devices and the computer. It is the interface between the CPU and I/O devices.

  • The controllers in microcomputers and minicomputers are often made in the form of printed circuit cards, that is, interface cards

② The device controller is an addressable device. When it controls only one device, it has only one unique device address; when it controls multiple devices, it contains multiple device addresses, and each device address corresponds to a device .

③ Device controllers can be divided into two categories:

  • The controller that controls the block device
  • A controller that controls character devices

Features of device memory:

① Receiving and identifying commands: The controller has corresponding command registers , which are used to store received commands and parameters, and decode the received commands.

② Data exchange: Realize data exchange between CPU - data bus - controller's data register - equipment .

③ Understanding and reporting of equipment status: The controller has a corresponding status register , each of which reflects a certain status of the equipment. When the CPU reads the contents of the register, it can know the state of the device.

④ Address identification: The device controller should be able to identify the addresses of the devices it controls and the addresses of its own registers.

⑤ Data buffering: solve the mismatch between the host and the I/O device in terms of speed.

⑥ Error control: The controller will perform error detection on the data. If the data sent by the I/O device is wrong, it will report to the CPU. The CPU will invalidate the data and the I/O device will resend the data.

Q: Why doesn't the device controller directly intercept the data?

5.2.3 I/O paths

1. Introduction of I/O channel devices

The I/O channel is a special processor that is responsible for input/output and has the ability to execute I/O instructions. The main purpose is to establish independent I/O operations, so that the organization, management and end processing of I/O operations are also independent of the CPU.

CPUs are processors, and I/O channels are special processors. The CPU sends I/O commands to the I/O channel, and the I/O channel executes the corresponding channel (I/O) program. An interrupt signal is sent to the CPU only after the execution of the I/O channel is completed.

The difference between I/O channels and general processors:

  • The instruction type is single, and it is only limited to the instructions related to I/O operation.
  • There is no independent memory, and the I/O channels share memory with the CPU.

2. Channel type    

1) byte multiplexing channel

A main channel connects multiple sub-channels, and these sub-channels share the main channel in a round-robin time slice manner.

Each sub-channel only transmits one byte at a time, so only medium and low speed devices can be connected.

As long as the byte multiplexer scans each sub-channel fast enough, the rate at which the devices connected to the sub-channels is not so high that information is lost.

2) Array selection channel

  • Work in an array to transfer data at high speed.
  • Multiple high-speed devices can be connected.
  • Only one device transmits data at a time, forming an exclusive.
  • Channel utilization is low.

Since it is monopolized, if it does not transmit data, other devices cannot either.

3) Array multi-channel

It is a new channel formed by combining the advantages of high transmission rate of array selection channel and time-sharing parallel operation of byte multiplex channel.

  • Its data transmission is in the form of an array.
  • Exclusive.
  • Multiple non-distributed sub-channels are transmitted in parallel by time sharing.

Therefore, this channel not only has a high data transmission rate, but also can obtain satisfactory channel utilization. 

3. Channel "bottleneck" problem

As long as any one of devices 1 to 4 starts using channel 1, other devices cannot be started. For example, in the figure below, if you want to start device 2, it will fail to start because controller 1 and channel 1 are occupied.

Solution: Increase the path between the device and the host instead of increasing the channel. In other words, connect one device to multiple controllers, which in turn are connected to multiple channels.

5.2.4 Bus system

1. Microcomputer I/O system

Device controller: It has a one-to-many relationship with I/O devices, and the system communicates with devices through it. 

System -- Device Controller -- Device

Cons: Bus bottleneck, CPU bottleneck.

2. Host I/O system (four-level structure)

computer -- I/O channel -- I/O controller -- device

The I/O channel is equivalent to the expansion of the bus, that is, the multi-bus mode, and the channel has certain intelligence, which can be paralleled with the CPU to solve its burden.

3. Common buses

  • ONE (8bit)
  • EISA(16bit)
  • LocalBUS
  • VESA(32bit)
  • PCI(64bit)

Guess you like

Origin blog.csdn.net/m0_64140451/article/details/130487965