In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
There are many adjustment algorithms in the operation, some of which are practical for homework adjustment, some are practical for process adjustment, and some are both practical. Several commonly used dispensing algorithms are introduced below.
First come first served (FCFS) dispensing algorithm
FCFS adjustment algorithm is one of the most complex adjustment algorithm, which can be used for both homework adjustment and process adjustment. In homework scheduling, the algorithm selects one or more tasks from the backup homework queue, transfers them to memory, allocates the required capital, creates the process, and puts them into the parking queue.
In the process adjustment, the FCFS dispatching algorithm chooses the first process to join the queue from the parking queue, and dispatches the disposal machine to it to put it into operation, and does not release the disposal machine until it is completed or congested for some reason.
Here is an example to illustrate the function of the FCFS modulation algorithm. Suppose there are 4 assignments in the odds and ends, their submission time is 8,8.4,8.8,9, and the running time is 2,1,0.5,0.2. the FCFS adjustment algorithm is used in the piecemeal sampling. the uniform waiting time and uniform turnaround time of this set of homework are shown in Table 2-3.
Table 2-3 functions of FCFS dispensing algorithm
The kung fu lesson number submits the working time, starts the time and waits for the time to complete the turnaround time with weight 18280102128.41101.61.62.638.80.5112.211.52.75.4490.211.52.511.72.713.5
Average waiting time t = (0: 1.6: 2.2: 2.5) / 4: 1.575
Uniform turnover time T = (2 / 2. 6 / 2. 7 / 2. 5)
Uniform weighted turnover time W = (1-2.6-5). "13.5) / 4" 5.625
The FCFS adjustment algorithm belongs to the Fu Cheng deprivation algorithm. From the outside, it is fair to all homework, but if a long homework arrives at bits and pieces first, it will make a lot of short homework wait for a long time, so it cannot be used as a secondary strategy of time-sharing and timely piecemeal adjustment. But it is often used in conjunction with other adjustment strategies. For example, in piecemeal processes that use priority as a tuning strategy, multiple processes with opposite priorities are often dealt with according to the FCFS criterion.
The FCFS adjustment algorithm is characterized by its complexity but low effectiveness; it is good for long homework, but it is bad for short homework (absolute SJF and high response ratio); it is good for CPU busy homework, and bad luck for CPU O busy homework.
Short homework first (SJF) adjustment algorithm
The priority adjustment algorithm of short homework (process) refers to the algorithm of priority adjustment of short homework (process). Short homework first (SJF) scheduling algorithm is to select one or more tasks with the shortest estimated running time from the backup queue and transfer them to memory. On the other hand, the short process first (SPF) dispatching algorithm is from the parking queue when a process with the shortest estimated running time is selected, the disposal machine is assigned to it so that it can be performed immediately, and the disposal machine is not released until something is completed or congested.
For example, for a set of homework given in Table 2-3, if you use the short homework priority adjustment algorithm in bits and pieces, its uniform waiting time and uniform turnaround time war all have weighted turnaround time as shown in Table 2-4.
Table 2-4 functions of SJF dispensing algorithm
The kung fu lesson number submits the time to work, the time to start, the time to wait for time to complete, the time to complete, the time to turn around with weight, 18280102128, 4110.72.311.73.33.338.80.510.21.410.71.93.8490.210110.21.26.
Average waiting time t = (0 / 2. 3 / 1. 4 / 1 / 4: 1.175)
Uniform turnover time T = (2-3.3-1.9-1.2) / 4-2.1
Uniform weighted turnover time W = (1 / 4 / 4 / 3 / 3 / 4 / 3 / 3 / 4 / 3 / 3 / 4 / 4 / 3 / 3 / 4 / 4 / 3 / 3 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 3 / 4 / 4 / 3 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4 / 4
The SJF regulation algorithm also has some defects that can not be ignored:
This algorithm is unlucky for long homework. It can be seen from tables 2-3 and 2-4 that the turnover time of long homework will be added in the SJF adjustment algorithm. To make matters worse, if a long homework enters a piecemeal backup queue, because the dispatching program always gives priority to those (even lagging) short homework, it will lead to long homework not being transferred temporarily ("hunger" scene). Pay attention to the identification of "deadlocks". The latter is a piecemeal circular waiting, and the former is a strategic achievement.
The algorithm does not consider the emergency level of homework completely, so there is no guarantee that urgent homework will be dealt with in real time.
Because the length of the homework is only determined according to the estimated time provided by the user, and the user can intentionally or intentionally extend the estimated running time of his homework, the algorithm can really achieve the priority of short homework adjustment.
Note that the uniform waiting time and uniform turnover time of the SJF adjustment algorithm are at least.
Priority adjustment algorithm
Priority adjustment algorithm, also known as priority adjustment algorithm, can be used not only for homework adjustment, but also for process adjustment. The priority in this algorithm is used to describe the emergency level of homework operation.
In homework scheduling, the priority scheduling algorithm selects one or more tasks with the highest priority from the backup homework queue, transfers them to memory, allocates the required capital, creates the process, and puts them into the parking queue. In process tuning, the priority tuning algorithm selects the process with the highest priority from the stop queue each time, and assigns the disposal machine to it to put it into operation.
According to whether the new higher priority process can preempt the process being performed, the tuning algorithm can be divided into:
Non-attainable priority adjustment algorithm. When a process is running on the disposal machine, the running process is kept running even if a more major or urgent process enters the stop queue. The disposal machine is not assigned to a more primary or urgent process until it automatically gives up the disposal machine for its own reasons (obligations are completed or waiting for something to be done).
Deprivation priority adjustment algorithm. When a process is running on the disposal machine, if a more major or urgent process enters the stop queue, immediately suspend the running process and assign the disposal machine to the more primary or urgent process.
According to whether the priority of the process can be changed after it is created, the priority of the process can be divided into the following two categories:
Static priority. The priority is set at the time of the creation of the process and remains the same throughout the operation of the process. The secondary priority of affirming static priority is based on process type, process request for capital, and user request.
Static priority. In the process of process operation, the priority is statically adjusted according to the change of the process condition. The priority of static tuning is mainly based on the amount of CPU time occupied for the process and the amount of time the process waits for CPU.
High call ratio priority dispensing algorithm
The high call ratio priority adjustment algorithm is mainly used for homework adjustment, which is a comprehensive balance of the FCFS adjustment algorithm and the SJF adjustment algorithm, while considering the waiting time and estimated running time of each homework. Every time you stop your homework adjustment, first calculate the echo ratio of each lesson in the backup homework queue, and put it into operation from the homework with the highest echo ratio.
The change discipline of echo ratio can be described as:
According to the formula, we can know:
When the waiting time of the successful industry is on the contrary, the shorter the request time is, the higher the response ratio is, which is conducive to short homework.
When the request for service is on the contrary, the response of the homework is higher than that of waiting for a decision, and the longer the waiting time, the higher the response ratio, so it is done on a first-come-first-served basis.
With regard to long homework, the response ratio of homework can improve with the addition of waiting time. When the waiting time is long enough, the response ratio can rise to a very high level, thus a disposal machine can also be obtained. Restrained the form of hunger and co-ordinated long homework.
An algorithm for rotating dispensing of Gongfu tablets
The Kung Fu tablet rotation adjustment algorithm is mainly used in time-sharing bits and pieces. In this algorithm, all the stop processes are arranged in a queue according to the arrival time, and the process adjustment program always chooses to perform the first process in the queue, that is, the criterion of first-come, first-served service, but can only run one worker tablet, such as 100ms. After using a kungfu tablet, even if the process does not complete its operation, it must release the disposal machine for the next stop process, and the process of deprivation goes to the end of the stop queue to be re-queued at the end of the queue, waiting to run again.
In the rotation adjustment algorithm of Gongfu tablets, the size of Gongfu tablets has a great influence on the piecemeal function. If the Kung Fu slice is large enough that all processes can be performed in a single time slice, then the Kung Fu slice rotation adjustment algorithm will retrogression to the first come, first served adjustment algorithm. If the kung fu film is very small, the processor will switch too frequently between processes, increasing the cost of the processor, and the time really spent on running the user process will increase. Therefore, the size of the time film should be chosen appropriately.
The length of a kung fu film is determined by the following elements: piecemeal response time, the number of processes in the queue, and piecemeal disposal ability.
Multi-level response queue tuning algorithm (aggregates the strengths of the previous algorithms)
The multi-stage response queue adjustment algorithm is the synthesis and development of the Kongfu rotation adjustment algorithm and the priority adjustment algorithm, as shown in figure 2-5. After the static adjustment process priority and time chip size, the multi-stage response queue adjustment algorithm can co-ordinate various piecemeal purposes. For example, take care of short processes to improve piecemeal throughput and extend uniform turnaround time; to take care of I / O processes to achieve better equipment application rates and longer response times; at the same time, there is no need to estimate the implementation time of the process in advance.
Figure 2-5 Multi-stage response queue tuning algorithm
The completion ideas of the multi-stage response queue tuning algorithm are as follows:
Multiple stopping queues should be set up and different priorities should be paid for each queue. The priority of the level 1 queue is the highest, followed by the level 2 queue, and the priority of the other queues decreases one by one.
The size of process performance slices varies from queue to queue, and the higher the priority is, the smaller the running slices of each process are. For example, the time slice of the level 2 queue is twice as long as that of the level 1 queue. The time slice of the level I + 1 queue is twice as long as that of the level I queue.
When a new process enters memory, it is first placed at the end of the level 1 queue and queued according to the FCFS criterion for adjustment. When it is time to perform the process, if it can be completed in the worker's tablet, it can be prepared to evacuate bits and pieces; if it is not finished at the end of a worker's tablet, the dispensing procedure will transfer the process to the end of the level 2 queue and wait for the adjustment to be performed according to the FCFS criterion; if it is not finished after running a kung fu tablet in the level 2 queue, it will be put into the level 3 queue in a different way. In this way, when an interest journey is successively reduced from the first-level queue to the n-level queue, the worker-slice rotation method is used in the n-level queue.
The dispatching program adjusts the process operation in the level 2 queue only when the level 1 queue is empty, and the process operation in the level I queue only if the level 1 ~ (imur1) queue is empty. If the processor is performing a process in the level I queue, and a new process enters the higher priority queue (any of the queues in level 1), the new process will preempt the running process, that is, the tuning program puts the running process back to the end of the level I queue and dispatches the processor to the newly arrived higher priority process.
The advantages of multistage response queues are:
Terminal homework users: short homework is preferred.
Short batch disposal of homework users: the turnaround time is short.
Long batch disposal of homework users: partial performance is lost through the following queues and will not be dealt with temporarily.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.