A . Purpose
Understand the concurrency of process running
Understand the various states of the process and their transitions
Understand the structure of PCB in process management
Master the priority number process scheduling algorithm
Two . Experimental content
With VC prepared to achieve realization process scheduling simulation process scheduling. The scheduling algorithm uses an algorithm that combines dynamic priority numbers and time slices. The requirements are as follows :
- Process related information such as process identifier and process time are put into PCB ;
- Design three process queues of running, completion and ready;
- The ready queue is arranged in descending order of priority, and each time the ready process with the highest priority is selected to run. The initial priority number is set to a larger number (such as 30 ) minus the process running time, and the priority number is adjusted as the process runs;
- Each time the process is executed, the priority number is reduced by a fixed value (such as 3 ), the CPU time is increased by 1 , and the time required by the process is reduced by 1. If the time required by the process becomes 0 , it means that the process is completed and its status is set to "F" , Insert its PCB into the completion queue, if the ready queue is not empty, then change the first PCB of the ready queue to the running state. If the process is not completed, compare its priority number with the first PCB priority number in the ready queue . If it is small, change it to the ready state, insert it into the appropriate position in the ready queue, and change the first PCB in the ready queue. Is running. Repeat the above process until the ready queue is empty and all processes become complete.
Related data structure:
typedef struct node{
char name [10]; // process identifier
int prio; // Process priority
int cput; // CPU time occupied by the process
int needt; // CPU time required before the process is completed
char state; // Process state struct node * next;
}PCB;
3. Experimental code
Refer to the code in Experiment 2 to complete the algorithm code.
Claim:
Write a flowchart of the algorithm implementation
Programming to achieve the function required by the problem
Experimental results for testing multiple sets of data