In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What is the parallel algorithm of task scheduling in programming language? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
If you are given a batch of tasks, say 500 tasks, you need to finish them as quickly as possible.
If the serial is definitely not good. We can consider the parallel strategy, but with parallelism, how can we make full use of resources?
When I was doing data migration many years ago, I couldn't help it. I wrote an algorithm in shell at that time. You can refer to this article.
Massive data migration using shell to enable multiple dynamic parallelism (R2 notes 81 days)
But in the automated operation and maintenance platform, I hope this operation can be more general, so the implementation on the program side is excellent.
I first intend to use Java to achieve, and then escape to the Python version, has written most of the part, has not been debugged, will not be released, I will talk about my ideas.
Suppose there are some of the following tasks, the first is the serial number, and the second is the time it takes for the task.
Suppose it is divided into four parallel, that is, four groups of execution tasks, how should each group of execution tasks be assigned?
(1, 10)
(2, 30)
(3, 20)
(4, 50)
(5, 60)
(6, 30)
(7, 20)
(8, 10)
(9, 20)
(10pr 50)
So looking at the direction of task scheduling, we all want to be parallel, but in most cases, the effect of parallel is actually not good. One of the most reconstructed situations is that the first half is in parallel and the second half is basically waiting.
Suppose we do this as follows: the first four elements are one element in each group, and then each group looks at the minimum cumulative value, and then adds subsequent elements in turn. According to this method, the resulting tasks are arranged as follows:
1 10 60 70
2 30 20 20 70
3 20 30 50 100
4 50 10 60
Obviously this approach has drawbacks, because we cannot predict the size of the subsequent elements, so the task distribution is very uneven.
So we need to sort, sort by maximum and minimum.
In this way, the largest four elements are listed as the first element of each group. Then the minimum value of each set of cumulative values is obtained in turn, and subsequent elements are added.
The distribution is as follows:
1 50 20 70
2 60 20 80
3 50 20 10 80
4 30 30 10 70
It's obviously much better.
This is the answer to the question about what is the parallel algorithm for task scheduling in the programming language. I hope the above content can be of some help to you, if you still have a lot of doubts to be solved. You can follow the industry information channel for more related knowledge.
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.