Knowledge points in this chapter: 1. Input and Output Operations; 2. Exclusive devices and shared devices; 3. Exclusive devices; 4. disk drivers; 5. startup of peripheral devices; 6. Virtual Devices (SPOOL System)
Self-study requirements: requires understanding of the cooperation between device management and file management. File Management prepares for file access, while physical access to files is implemented by device management. Understand how to allocate exclusive devices and drive scheduling of disks; and How to Implement Virtual Devices.
I. Input and Output operations (requires that the operation level be "memorization)
1. What is an input/output operation? The information transfer operation between the primary storage and the peripheral device is called an input/output operation.
2. For storage devices, the input/output information transmission unit is block ". For input and output devices, the unit of information transmission for input and output operations is "character ".
2. Exclusive devices and shared devices)
An exclusive device is like a toilet in your house. When you sit up, you just want to use it until you're done standing up.
Sharing equipment is like a tap in my house. When I wash my hands, I can move my hands away and ask my mom to fill a basin of water. Then I continued to wash my hands.
1. An exclusive device is a device that can only be used independently during the execution of one job at a time. Such as the input machine, tape drive, and printer.
2. Shared devices are devices that can be used simultaneously during the execution of several jobs.
3. The "use at the same time" of a shared device means that multiple jobs can start the shared device alternately. When a user is using the device, other jobs are unavailable for the moment, that is, only one job is occupied at a time, but other jobs can be used when a job is using a device.
3. Distribution of exclusive devices (understanding)
1. absolute and relative numbers of exclusive Devices
This is similar to the concept of absolute/relative addresses. An absolute number is a device ID (equivalent to an absolute address ). The relative number is set for the convenience of the user program. When the user requests for use, the "device class-Relative Number" is used to propose the requirements for using the device. The system establishes the relationship between the absolute number and the "device class-Relative Number" to enable the device correctly.
2. method specified by the device
The absolute number is like giving a different name to everyone. There is one in the boss's work plan: Ten o'clock asked Michael to buy food. If Michael is free, Michael needs to buy it.
Equipment-the relative number is like a department. There are some staff in the Department, and the boss's work plan is written as: Buy food department to ask a person to buy luobo. In this case, the "System" will be used to check whether there are any people in the food purchasing department who are idle. As long as there are people in the department who can work in their spare time, they can do whatever they want.
In this way, for a boss, there is no need to remember the name of the person who needs to be assigned a department. His employment strategy has nothing to do with the specific person. This is "device independence"
1) Specify the absolute number: in this way, the device corresponding to the absolute number is directly specified by the job. The system can only allocate this device to him. If the device is being used by other jobs, the application cannot be met.
2) Specify the device class and relative number: This method does not specify the specific device when applying for a device. It only specifies the number of devices of a certain type, which can be flexibly allocated by the system.
3) device independence: When devices are used in the "device type and relative number" mode, you do not have to specify a specific device for programming. In the program, the "device type and relative number" define the logical device. During program execution, the system converts the logic device specified by the user to the specific physical device. Therefore, the devices used for programming are independent of the devices actually used"
4) how to allocate dedicated devices: for dedicated devices, the system adopts the "static allocation" policy, that is, when the exclusive devices required for a job can be satisfied, this job can be loaded into the primary storage for execution.
In the operating system, set the "device allocation table" to record the exclusive device type, number of devices, and allocation information configured by the computer system. The device allocation table consists of two parts: Device table and device table. You can use the table query and table modification operations to complete device allocation.
4. Drive scheduling of disks (understanding)
1. Disk structure (animation)
2. Disk access operation time (animation)
3. Disk Drive scheduling: In a multi-channel Programming System, multiple visitors request disk operations. At this time, the system uses a certain scheduling policy to determine the execution order of each visitor waiting for access, therefore, the system decides to wait for the execution order of disk visitors to "drive scheduling" of the disk"
4. Drive scheduling of disks: reduce the total time for multiple visitors to perform input/output operations and increase the number of input/output operations per unit of time, which is conducive to the improvement of system efficiency.
5. disk scheduling is divided into arm-shift scheduling and rotation scheduling. scheduling is called "arm shift scheduling" based on the position of the cylindrical column specified by the visitor. When the mobile arm is located, if multiple visitors are waiting to access the cylindrical column, scheduling that determines the execution order based on the delay time is called "rotation scheduling ".
6. Arm shift scheduling algorithms include the following four types:
1) Service algorithms first;
2) The shortest search time-first scheduling algorithm;
3) elevator scheduling algorithm;
4) One-Way Scan Scheduling Algorithm.
The preceding algorithms must be differentiated. For example, if you are given an access sequence and access conditions, you should be able to make a scheduled access sequence based on various algorithms.
7. optimal distribution of information: knowing that information is arranged on disks is not necessarily the most optimal in order. Optimizing pages for information that can predict processing requirements can shorten the input/output operation time, improve system efficiency.
5. startup of peripheral devices)
To improve efficiency, we must boldly delegate authority, so that subordinates are responsible for the matter rather than the people.
The CPU is very busy. If everything is done by yourself, it may not be good. If someone can help him with some things, he can spare time to do more things. Channels are middle-level cadres, so they can improve efficiency.
1. channel: A hardware device in a computer system that can independently complete input/output operations, also known as an "Input/Output Processor ".
The CPU does not directly operate the peripheral device. It connects to the channel (I/O processor), the channel connects to the device controller, and the device Controller connects to the device. The CPU only needs to start the "I/O" device and provide relevant operation requirements. Then the channel is used to process the input and output, and the CPU is reported after completion.
2. Channel commands and channel programs:
The channel command (CCW) specifies an operation of a device, which is usually composed of the command code, the data Master Address, the number of transmitted bytes, and the flag code.
The operating system uses a group of channel commands to execute the input and output operations. These channel commands form a "channel program ".
There are three types of command codes: data transmission, channel command transfer, and Device Control.
The data primary storage address has different functions for different commands. For example, if the command code is a write operation, the region specified by the primary storage address stores the information output to the peripheral device.
Flag Code: if it is not 0, it indicates that the channel program has not ended. If the value is 0, the channel program ends.
The number of bytes transferred, indicating the number of bytes to be transferred by this command.
3. Channel address (CAW) and channel status (CSW)
The main storage unit used to store the first address of the channel program is called "channel address Word ".
Channel status word: the main storage unit used to record channel and device execution. It usually includes the channel command address, device status, channel status, number of remaining bytes, and other fields.
4. I/O interruption: it refers to a means to coordinate the work of the central processor and channel. The channel uses the I/O interrupt request CPU for intervention. The CPU understands the execution of input and output operations based on the generated I/O interrupt events, the I/O interruption event is caused by the execution of the channel program or other external reasons. For Channel operations, when an operation ends normally or abnormally (for example, a device failure or a device ends abnormally in special circumstances), the I/O is interrupted and the CPU processes the operation separately according to the corresponding situation.
6. SPOOL system of virtual devices (understanding)
1. Virtual Devices: one physical device is used to simulate another type of physical devices, so that each job only uses virtual devices during execution, rather than directly using physical exclusive devices. This technology enables exclusive devices to become shared devices, improving the utilization rate and System Efficiency of devices.
2. Hardware conditions for Virtual Devices: large-capacity disks, interrupt devices and channels, and the ability of the central processor to work in parallel with the channel. (In addition, the software condition for implementing virtual devices requires that the operating system adopt multi-channel programming technology .)
3. Implementation Principle of Virtual Devices: For multi-channel programs, information of a batch of jobs is pre-transmitted to the disk through the input device. When a job is output, all the results generated by the job are temporarily stored on the disk, instead of being output directly until a job gets all the results and the execution ends. (It is to use a disk to simulate the input machine and printer work, save their work content first, and then execute it together)
4. Composition and Implementation of the SPOOL system:
Well: a dedicated storage space allocated by Virtual Devices on disks is used to store the initial information and execution results of jobs.
The SPOOL system consists of three programs:
Pre-input program. This program transfers the initial information of each job in the job flow to the "input well" and saves it for use during job execution.
Well Management Program: This program ensures that the job reads or writes information from the "well" in a correct and timely manner. It makes every user feel that they are using an independent input/output device.
Slow output program. It is responsible for checking whether the output result information is to be output in the "output well". If yes, start the printer to output the job result.
Why can we improve efficiency? To put it simply, there are several things: parallel jobs, replacement operations, and simultaneous operations.
How much efficiency can a technological innovation improve.
5. Why can virtual devices improve system efficiency:
The SPOOL system uses hardware interrupt devices and channel technologies to allow the central processor to work in parallel with various peripheral devices and peripheral devices. The operating system uses multi-channel programming technology and rationally allocates processors to achieve simultaneous operation of online peripheral devices.
When a job is executed, the read/write information from the disk is used to replace the read/write operations on the input machine and the printer. This not only enables multiple jobs to be executed simultaneously, but also speeds up job execution, this improves the processing capability per unit time. During job execution, you can use the input machine to continue the pre-input job information and use the printer to output the results. Therefore, the system can print the execution results of the first batch of jobs and the second batch of jobs are being processed, the third batch of job information is being pre-input to the "input well" of the disk.
This online operation greatly improves the utilization of exclusive devices and makes full use of various resources of computer systems.