A kind of power adaptive method for scheduling task and system
Technical field
The present invention relates to task schedule fields, more particularly to a kind of power adaptive method for scheduling task and system.
Background technique
In recent years, the development that technology of Internet of things is advanced by leaps and bounds, high-performance, low-power consumption have become internet of things equipment
Important trend.High performance demand means the promotion of system energy consumption, and the development speed of current battery is much fallen
Afterwards in the growth of energy requirements, and battery power supply still remains the problem that volume weight is big and maintenance cost is high.Using novel
The various environmental energy (such as sunlight, wind, tide and vibration etc.) that nature is widely present are converted electricity by energy collection technology
It can and store and utilize a kind of effective way for being solution energy problem.However, due to external environment resource have it is intermittent, with
The features such as machine and uncertainty, energy collecting system output-power fluctuation, therefore, Internet of things node are needed by rationally utilizing
Output power, and reasonable task schedule is carried out according to the power demand of different loads, so that power usage efficiency optimizes.
The method of existing combination task schedule research energy collecting system, main focus utilization power conditioning technology is in energy
Amount constrains lower maximum system performance, or minimizes system energy consumption under the constraint of energy collection unit output power.For example,
Using dynamic frequency pressure regulation, to reduce processor energy consumption.Currently, there are many power regulations in managing power consumption hardware view
Technology, as dynamic voltage frequency adjustment (DVFS) can reduce system power dissipation by adjusting voltage and clock frequency;CPU hot plug
(CPU Hotplug) technology adjusts system processor power consumption by increasing or decreasing processor nucleus number online.Opposite hardware view
Fast development to managing power consumption, managing power consumption software technology research relatively lag behind, these technical applications are in energy collecting system
In need software and hardware mutual cooperation competence exertion maximal efficiency, and task is basic in the case where no enough output powers
It cannot execute.Therefore, energy collecting system allows for dynamically according to processor operating power requirements and energy collection unit
Output power manages and scheduler task.
Summary of the invention
The object of the present invention is to provide a kind of power adaptive method for scheduling task and systems, receive to solve current energy
Collecting system do not accounted in task scheduling process processor operating power requirements and energy collection unit output power not really
The problems such as task execution caused by qualitative is interrupted and efficiency is low.
To achieve the above object, the present invention provides following schemes:
A kind of power adaptive method for scheduling task, which comprises
Obtain current mission bit stream;
The mission bit stream is divided and is counted according to big data programming model MapReduce, obtain it is multiple can be simultaneously
The subtask of row operation;
The upset condition and task load state for obtaining output power, obtain status information;
The nucleus number and type of processor are adjusted according to the state information;
According to the processor after adjustment nucleus number and type, by the subtask scheduling to each worker thread.
Optionally, described that the mission bit stream is divided and counted according to big data programming model MapReduce, it obtains
To multiple subtasks that can be run parallel, specifically include:
The mission bit stream is divided by Map function;
The mission bit stream after division is counted by Reduce function, obtains multiple subtasks that can be run parallel.
Optionally, the nucleus number and type for adjusting processor according to the state information, specifically includes:
Obtain the operating power requirements of processor;
According to the operating power requirements and the status information, the core of CPU hot plug technology adjustment processor is utilized
Several and type.
Optionally, the nucleus number and type according to processor adjusted, by the subtask scheduling to each worker
Thread specifically includes:
The state of processor after obtaining adjustment nucleus number and type, the state includes presence and off-line state;
Obtain adjustment nucleus number and type after processor change conditions, the change conditions include processor heat remove with
And processor heat insertion;
According to the state and change conditions of the processor, by the subtask scheduling to each worker thread.
Optionally, successively by the subtask scheduling to each worker thread in a manner of first in, first out.
A kind of power adaptive task scheduling system, the system comprises:
Mission bit stream obtains module, for obtaining current mission bit stream;
Division and statistical module, for being divided according to big data programming model MapReduce to the mission bit stream
And statistics, obtain multiple subtasks that can be run parallel;
State information acquisition module obtains state for obtaining the upset condition and task load state of output power
Information;
Module is adjusted, for adjusting the nucleus number and type of processor according to the state information;
Scheduler module, for according to adjustment nucleus number and type after processor, by the subtask scheduling to each worker
Thread.
Optionally, the division and statistical module specifically include:
Division unit, for being divided the mission bit stream by Map function;
Statistic unit, for the mission bit stream after division to be counted by Reduce function, obtain it is multiple can be parallel
The subtask of operation.
Optionally, the adjustment module specifically includes:
Operating power requirements acquiring unit, for obtaining the operating power requirements of processor;
Adjustment unit, for utilizing CPU hot plug technology tune according to the operating power requirements and the status information
The nucleus number and type of whole processor.
Optionally, the scheduler module specifically includes:
State acquiring unit, for obtaining the state of the processor after adjusting nucleus number and type, the state includes online
State and off-line state;
Change conditions acquiring unit, for obtaining the change conditions of the processor after adjusting nucleus number and type, the variation
Situation includes the removal of processor heat and the insertion of processor heat;
Scheduling unit, for the state and change conditions according to the processor, by the subtask scheduling to each work
Author's thread.
Optionally, the scheduler module is in a manner of first in, first out successively by the subtask scheduling to each worker's line
Journey.
Compared with prior art, the present invention has following technical effect that the present invention in the case where output power changes, is led to
On-line tuning system processor nucleus number and type are crossed, system processor operating power requirements is made to adapt to energy collection unit output work
The dynamic change of rate, and the migration of binding operation system task and thread affinity managing and serving system thread, are dispatched using phoenix
Strategy by task schedule to worker thread, thus avoid output power insufficient and output power surplus to system effectiveness not
Benefit influences.This method is suitable for the occasion of energy collecting system collection of energy output-power fluctuation, and efficiency is substantially better than biography
System dispatching method.
Detailed description of the invention
It in order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, below will be to institute in embodiment
Attached drawing to be used is needed to be briefly described, it should be apparent that, the accompanying drawings in the following description is only some implementations of the invention
Example, for those of ordinary skill in the art, without any creative labor, can also be according to these attached drawings
Obtain other attached drawings.
Fig. 1 is the flow chart of power adaptive of embodiment of the present invention method for scheduling task;
Fig. 2 is managing and serving system thread schematic diagram;
Fig. 3 is the structural block diagram of self-adapting task scheduling of embodiment of the present invention system.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, with reference to the accompanying drawing and specific real
Applying mode, the present invention is described in further detail.
As shown in Figure 1, a kind of power adaptive method for scheduling task the following steps are included:
Step 101: obtaining current mission bit stream.
Step 102: the mission bit stream being divided and counted according to big data programming model MapReduce, is obtained
Multiple subtasks that can be run parallel.Entire data handling procedure is attributed to two functions: Map and Reduce.Map be responsible for by
Data processing load be divided into it is multiple can Parallel Scheduling task, and by all task piecemeals processing.Reduce is responsible for will be each
Task processing result carries out data aggregate.
Step 103: obtaining the upset condition and task load state of output power, obtain status information.
Step 104: adjusting the nucleus number and type of processor according to the state information.
Core is adjusted automatically according to the change conditions of energy collection unit power output.Automatic tune core strategy is according to Optimum Matching
The processor nucleus number and type that algorithms selection and energy collection unit output power most match finally provide CPU heat by OS and insert
Technology (CPU Hotplug) is pulled out to realize.Current system is worked using CPU hot plug technology processor nucleus number and type into
Row adjustment, and system processor operating power under different situations is tested respectively, come analysis processor operating power requirements and system
Relationship between current processor nucleus number and type.Power adaptive tune core module perceives output according to power monitoring unit
Power, according to the analysis to relationship between processor operating power requirements and system current processor nucleus number and type as a result,
It makes adjustment to system current processor nucleus number and type.
Step 105: according to the processor after adjustment nucleus number and type, by the subtask scheduling to each worker thread.
As shown in Fig. 2, giving full play to the parallel processing capability of multi-core processor system using multithreading task schedule.According to
The change conditions of current processor nucleus number, the migration of binding operation system process and thread affinity managing and serving system thread, and benefit
With Phoenix scheduling strategy by task schedule to worker thread.It, will be in threadiness according to the online situation of current processor core
Thread affinity is arranged in the corresponding worker thread of the processor core of state, is bundled on the core;In addition, being in off-line state
The corresponding worker thread of processor core be not provided with thread affinity, and the suspend mode thread.
According to the change conditions of current processor core, the migration of binding operation system process and thread affinity managing and serving system
Thread, multithreading task schedule are based on following rule and are adjusted: when certain processor core is heat-removed, executing in processor core
Upper worker thread will be migrated by OS to running on other online processing device cores, be carrying out on the worker thread with emptying
Task, then the suspend mode worker thread, makes it that can not continue to obtain task from task queue and executes;When certain processor
When core is inserted by heat, then relevant work person's thread is waken up, and thread affinity is set and is tied on the processor core.
Task dispatcher is in a manner of first in first out successively by task schedule to each worker thread.Worker thread is appointed
After the completion of business executes, without completing until all working person thread whole task execution, task dispatcher is directly by new task tune
Spend the worker thread.
The specific embodiment provided according to the present invention, the invention discloses following technical effects: the present invention is in output power
In the case where variation, by on-line tuning system processor nucleus number and type, system processor operating power requirements is made to adapt to energy
Measure the dynamic change of collector unit output power, and the migration of binding operation system task and thread affinity managing and serving system line
Journey, using phoenix scheduling strategy by task schedule to worker thread, to avoid output power insufficient and output power
Adverse effect of the surplus to system effectiveness.This method is suitable for the occasion of energy collecting system collection of energy output-power fluctuation,
And efficiency is substantially better than conventional scheduling method.
As shown in figure 3, a kind of power adaptive task scheduling system includes:
Mission bit stream obtains module 301, for obtaining current mission bit stream.
Division and statistical module 302, for being drawn according to big data programming model MapReduce to the mission bit stream
Divide and count, obtains multiple subtasks that can be run parallel.
The division and statistical module 302 specifically include:
Division unit, for being divided the mission bit stream by Map function;
Statistic unit, for the mission bit stream after division to be counted by Reduce function, obtain it is multiple can be parallel
The subtask of operation.
State information acquisition module 303 obtains shape for obtaining the upset condition and task load state of output power
State information.
Module 304 is adjusted, for adjusting the nucleus number and type of processor according to the state information.
The adjustment module 304 specifically includes:
Operating power requirements acquiring unit, for obtaining the operating power requirements of processor;
Adjustment unit, for utilizing CPU hot plug technology tune according to the operating power requirements and the status information
The nucleus number and type of whole processor.
Scheduler module 305, for according to adjustment nucleus number and type after processor, by the subtask scheduling to each work
Person's thread.The scheduler module is in a manner of first in, first out successively by the subtask scheduling to each worker thread.
The scheduler module 305 specifically includes:
State acquiring unit, for obtaining the state of the processor after adjusting nucleus number and type, the state includes online
State and off-line state;
Change conditions acquiring unit, for obtaining the change conditions of the processor after adjusting nucleus number and type, the variation
Situation includes the removal of processor heat and the insertion of processor heat;
Scheduling unit, for the state and change conditions according to the processor, by the subtask scheduling to each work
Author's thread.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with other
The difference of embodiment, the same or similar parts in each embodiment may refer to each other.For system disclosed in embodiment
For, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is said referring to method part
It is bright.
Used herein a specific example illustrates the principle and implementation of the invention, and above embodiments are said
It is bright to be merely used to help understand method and its core concept of the invention;At the same time, for those skilled in the art, foundation
Thought of the invention, there will be changes in the specific implementation manner and application range.In conclusion the content of the present specification is not
It is interpreted as limitation of the present invention.