Multi-program

1. Concept

A program is a strictly ordered set of instructions in time. It exclusively uses all the resources in the system, including CPU, memory, peripherals, software, etc., and no other competitors compete and share with it. Therefore, in a single-CPU computer system, only one program is running for a period of time. The program monopolizes all the resources of the computer and is not affected by external influences.

In the early days of computers, multitasking was called multiprogramming. Multi-program means that the CPU reads multiple programs at a time and puts them into memory, and runs the first program until it has an IO operation. Because the IO operation is slow, the CPU needs to wait. In order to improve CPU utilization, run the second program at this time. That is, the condition for the n+1th program to be executed is that the nth program performs an IO operation or has already run. In this way, the time distribution of each program is unequal. It is possible that the first program has been running for several hours without IO operation, so the second program is not running. In the beginning, this situation was acceptable. People specify to run multiple programs at a time, and after a few hours or a day, they can see the results or take the printed files. People do not need to obtain the running status of each program in real time, but only care about the running results.

Multitasking refers to the ability of a computer to run multiple programs at the same time. The general method of multitasking is to run a piece of code of the first program and save the working environment; then run a piece of code of the second program to save the environment; ... restore the working environment of the first program and execute the next program of the first program. A piece of code...modern multitasking, the time distribution of each program is relatively even.

The fundamental purpose of introducing multiprogramming technology is to increase the utilization rate of CPU and give full play to the parallelism of computer system components. Modern computer systems all adopt multiprogramming technology. The emergence of multiprogramming has accelerated the birth of the current operating system.

2. Features

1) Multi-channel: that is, several independent programs are stored in the computer memory at the same time.

2) Macroscopically parallel: Several programs that enter the system at the same time are all in the process of running, that is, they have started their respective operations one after another, but have not been completed.

3) Microscopically serial: From a microscopic point of view, multiple programs in the memory occupy the CPU in turn or time-sharing.

3. Advantages

Improve CPU utilization. In a multi-program environment, multiple programs share computer resources. When a program is waiting for an I/O operation, the CPU can execute other programs, which greatly improves the utilization of the CPU.

Improve equipment utilization. In a multi-program environment, multiple programs share system equipment, which greatly improves the utilization of system equipment.

Improve the throughput of the system. In a multi-program environment, the waiting time of the program is reduced and the throughput of the system is improved.

4. Scheduling

Multi-program processing can load several programs in the memory at the same time. When a program cannot work because of waiting for external transmission, the central processing unit can immediately Execute another program. If the second program cannot be executed for some reason, the central processing unit executes the third program, and so on until the external transmission of the first program is completed before executing the first program. Reasonable collocation of multiple programs can improve resource utilization and enhance the input and output capabilities of the system. Multi-program processing is performed in a pseudo-parallel manner. From a time interval, each program has been executed, but the execution has not been completed. From a certain moment, there is only one program executing in the central processing unit, and each program occupies a time slice, and the central processing unit is used alternately and serially. The programs do not end in the order in which they started.

Multiple programs share the various resources of the processing system, but the system resources are limited, and the number and types of resources required by each program are also different. Therefore, the scheduling of multiple programs depends on the difference of each program. Resource requirements adopt the following strategies: ①First come, first serve, establish a backup queue according to the order of program entry, and the scheduler scans the backup queue from the beginning to find the first program that can be satisfied by the resource, and insert it into the current queue for execution. ② According to the priority number scheduling, the system selects the program with the highest priority number for execution. The priority number of the program can be specified by the user (the system charges a higher fee for the program with the higher priority number), or it can be determined by the system (the system specifies the waiting time of the program, the length of the running time and the amount of system resource requirements). This priority number can be determined when the program enters the system, or it can be calculated every time the program is scheduled. In the same priority number program, the scheduling is still based on the principle of first-come, first-served. ③ Balanced scheduling, which classifies programs according to their own characteristics. For example, Type A is a time-consuming program for input and output, Type B is a program that balances input and output with computing time, and Type C is a time-consuming program for computing. The program scheduler selects and runs programs from these different types of programs in turn, so that resources can be used in a balanced manner, system efficiency can be brought into play and users are satisfied.

As shown in the figure, the execution status of single program and multi-program is listed. It can be seen that multi-program can greatly improve the resource utilization of the system.

Related Articles
TOP