CN103699437A - Resource scheduling method and device - Google Patents

Resource scheduling method and device Download PDF

Info

Publication number
CN103699437A
CN103699437A CN201310712166.1A CN201310712166A CN103699437A CN 103699437 A CN103699437 A CN 103699437A CN 201310712166 A CN201310712166 A CN 201310712166A CN 103699437 A CN103699437 A CN 103699437A
Authority
CN
China
Prior art keywords
task
critical
priority
resource
critical section
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201310712166.1A
Other languages
Chinese (zh)
Other versions
CN103699437B (en
Inventor
胡振勇
刘相斌
罗站城
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201310712166.1A priority Critical patent/CN103699437B/en
Publication of CN103699437A publication Critical patent/CN103699437A/en
Application granted granted Critical
Publication of CN103699437B publication Critical patent/CN103699437B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The embodiment of the invention discloses a resource scheduling method, comprising: judging whether the access of a first task to critical resource clashes with a second task which now accesses the critical resource at a critical region, wherein the priority of the first task is higher than that of the second task; if clash appears, providing the critical resource at the critical region to the first task for accessing; the task with higher priority can access the critical resource in a seizing manner and does not need to wait for the completion of the task with lower priority, so that the improvement on system instantaneity is achieved. In addition, the embodiment of the invention further discloses a resource scheduling device.

Description

A kind of resource regulating method and equipment
Technical field
The present invention relates to computer application field, particularly a kind of resource regulating method and equipment.
Background technology
Critical resource, refers to the resource that at every turn only allows a task access.Operating system needs reasonably scheduling critical resource, if dispatch badly, just easily makes system in unsafe condition, even occurs the phenomenon of Priority Inversion.Priority Inversion, refer to when the task of a high priority is accessed critical resource, this critical resource is occupied by the task of a low priority, and this low priority task may be tried to be the first by some other high medium priority task when other critical resources of access, therefore cause high-priority task to be there is lower priority task and block by many, occur Priority Inversion phenomenon.
At present, conventionally can adopt low priority task to carry out as early as possible finishes to prevent Priority Inversion phenomenon to discharge the strategy of critical resource.For example, two kinds of scheduling strategies of priority inheritance or Priority Ceiling.Priority inheritance, when finding that the task of high priority is blocked because low priority task takies critical resource, just by the priority of the limit priority task of the priority promotion of the low priority task critical resource that it occupies to wait, thereby this low priority task can not tried to be the first by other high medium priority tasks, carry out and finish as early as possible, discharge critical resource; Priority Ceiling: be to the priority that may access limit priority task in all tasks of this critical resource by the priority promotion of the task of certain critical resource of application, thereby this low priority task can not tried to be the first by other high medium priority tasks, carry out and finish as early as possible, discharge critical resource.
But this strategy of prior art still needs the task of high priority to wait for, therefore, cause in prior art system real time poor.
Summary of the invention
In view of this, the fundamental purpose of the embodiment of the present invention is to provide a kind of resource regulating method and equipment to realize the object that improves system real time.
In order to solve above technical matters, the technical scheme that the embodiment of the present invention is taked is:
First aspect, the embodiment of the present invention provides a kind of resource regulating method, and described method comprises:
Judge whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, and wherein, the priority of priority ratio second task of first task is high;
If conflict, accesses the critical resource of described critical section to first task.
In the possible implementation of the first of first aspect, describedly judge that whether with just first task clashes and comprise in the second task of critical section access critical resource the access of critical resource:
In the process of carrying out with the second tasks in parallel after first task enters critical section, judge first task to the access of described critical resource whether with the access conflict of the second task to described critical resource;
Or,
Judgement first task attempts entering critical section when to critical resource access, whether there is second task of just accessing described critical resource in critical section, if existed, determine that first task clashes the access of critical resource and second task of just accessing critical resource in critical section.
In conjunction with the possible implementation of the first of first aspect, in the possible implementation of the second, in the process of carrying out with the second tasks in parallel after first task enters critical section, if judge first task access conflict to described critical resource to the access of described critical resource and the second task, also comprise:
Control the rollback of first task generation task, re-execute first task;
And,
Control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In conjunction with the possible implementation of the first of first aspect, in the third possible implementation, in first task, attempt entering critical section when to critical resource access, if determine that first task clashes the access of critical resource and second task of just accessing critical resource in critical section, also comprises:
Control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In conjunction with the possible implementation of the first of first aspect, in the 4th kind of possible implementation, before first task enters critical section and the execution of the second tasks in parallel, also comprise:
When first task attempts entering critical section, if there is the second task of described critical resource of just accessing in critical section, the priority of the priority of more described first task and described the second task, if the priority of the second task is high described in the priority ratio of first task, allow first task to enter critical section and described the second tasks in parallel execution, if the priority of described first task equals the priority of described the second task or lower than the priority of described the second task, first task is placed in and waits for the state of retry or cancel first task taking CPU;
Or,
When first task attempts entering critical section, while if there is no just accessing the task of described critical resource in critical section, allow described first task to enter critical section and carry out;
Or,
When first task and the 3rd task attempt entering critical section simultaneously, compare the priority of first task and the priority of the 3rd task, if the priority of the priority ratio of first task the 3rd task is high, allowing described first task to enter described critical section carries out, if the priority of described first task equals the priority of described the 3rd task or lower than the priority of described the 3rd task, first task is placed in and waits for the state of retry or cancel first task taking CPU.
Second aspect, the embodiment of the present invention provides a kind of scheduling of resource equipment, and described equipment comprises:
Conflict judging unit, for judging whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, and wherein, the priority of priority ratio second task of first task is high;
Preempting resources unit, if for conflict, accessed the critical resource of described critical section to first task.
In the possible implementation of the first of second aspect, described conflict judging unit: in the process of carrying out with the second tasks in parallel after first task enters critical section, judge first task to the access of described critical resource whether with the access conflict of the second task to described critical resource;
Or,
Described conflict judging unit, specifically for judgement first task, attempt entering critical section when to critical resource access, whether there is second task of just accessing described critical resource in critical section, if existed, determine that first task clashes the access of critical resource and second task of just accessing critical resource in critical section.
In conjunction with the possible implementation of the first of second aspect, in the possible implementation of the second, also comprise: the first rollback unit, for the process of carrying out with the second tasks in parallel after first task enters critical section, if conflict judging unit is judged first task access conflict to described critical resource to the access of described critical resource and the second task, control the rollback of first task generation task, re-execute first task, and, control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In conjunction with the possible implementation of the first of second aspect, in the third possible implementation, also comprise: the second rollback unit, for attempting entering critical section in first task when to critical resource access, if conflict judging unit is determined first task the access of critical resource and second task of just accessing critical resource in critical section is clashed, control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In conjunction with the possible implementation of the first of second aspect, in the 4th kind of possible implementation, also comprise:
The first comparing unit, for when first task attempts entering critical section, is just accessing the second task of described critical resource, the priority of the priority of more described first task and described the second task if existed in critical section; The first access unit, if it is high to compare described in the priority ratio of first task the priority of the second task for the first comparing unit, allow first task to enter critical section and described the second tasks in parallel execution, if the first comparing unit compares the priority of first task, equal the priority of described the second task or lower than the priority of described the second task, first task is placed in and waits for the state of retry or cancel first task taking CPU;
Or,
The second access unit, for when first task attempts entering critical section, while if there is no just accessing the task of described critical resource in critical section, allows described first task to enter critical section and carries out;
Or,
The second comparing unit, for when first task and the 3rd task attempt entering critical section simultaneously, the relatively priority of first task and the priority of the 3rd task; The 3rd access unit, if compare the priority of priority ratio the 3rd task of first task for the second comparing unit high, allowing described first task to enter described critical section carries out, if the second comparing unit compares the priority of first task, equal the priority of described the 3rd task or lower than the priority of described the 3rd task, first task is placed in and waits for the state of retry or cancel first task taking CPU.
The visible embodiment of the present invention has following beneficial effect:
Because the embodiment of the present invention judges whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, wherein, the priority of priority ratio second task of first task is high, if conflict, the critical resource of described critical section is accessed to first task, and therefore, the task of high priority can be accessed critical resource with preempt-mode, without waiting for that low priority task is carried out, finish, thereby can realize the object that improves system real time.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, to the accompanying drawing of required use in embodiment or description of the Prior Art be briefly described below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the schematic diagram of embodiment of the present invention illustrative application scene;
Fig. 2 is one of schematic flow sheet of the resource regulating method that provides of the embodiment of the present invention;
Fig. 3 be the resource regulating method that provides of the embodiment of the present invention schematic flow sheet two;
Fig. 4 be the resource regulating method that provides of the embodiment of the present invention schematic flow sheet three;
Fig. 5 be the resource regulating method that provides of the embodiment of the present invention schematic flow sheet four;
Fig. 6 is one of structural representation of the scheduling of resource equipment that provides of the embodiment of the present invention;
Fig. 7 be the scheduling of resource equipment that provides of the embodiment of the present invention structural representation two;
Fig. 8 is another structural representation of scheduling of resource equipment in the embodiment of the present invention.
Embodiment
For above-mentioned purpose, the feature and advantage of the embodiment of the present invention can be become apparent more, below in conjunction with the drawings and specific embodiments, the embodiment of the present invention is described in further detail.
In order to improve system real time, for example, as shown in Figure 1, can in operating system nucleus, apply the following resource regulating method that the embodiment of the present invention provides, access in response to task to critical resource, realization is dispatched critical resource, or when task attempts entering critical section, the functional module that makes task that the following resource regulating method that provides of the application embodiment of the present invention is provided is carried out, the scheduling of realization to critical resource, or, other possible implementations can also be had, to this, in the application, do not limit.
Referring to Fig. 2, show one of schematic flow sheet of the resource regulating method that the embodiment of the present invention provides, comprising:
S210, judge whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, and wherein, the priority of priority ratio second task of first task is high;
Critical section refers to the code area that described critical resource is conducted interviews.
It should be noted that, first task can comprise that to the access of critical resource first task enters the access to described critical resource in the process of carrying out with the second tasks in parallel after critical section, also can comprise the access to critical resource when first task attempts entering critical section, not limit in the present invention.Therefore, judge whether that conflict can judge when first task attempts entering critical section, also can judge after first task enters critical section.For example, according to implementing needs, if allow low priority task and high-priority task executed in parallel, can in executed in parallel process, judge whether to occur the access conflict to boundary's resource, or, if do not allow low priority task and high-priority task executed in parallel, can, when the higher first task of priority attempts entering critical section, determine that first task clashes the second lower task of the access of critical section and the priority of just accessing critical resource in critical section.
Be understandable that, for the task in critical section executed in parallel, if the read access to critical resource, the executed in parallel between task can not clash conventionally, if the write access to critical resource, the executed in parallel between task can clash.Therefore, after first task enters critical section with the second task in the process of critical section executed in parallel, in the time of can working as at least one task in first task or the second task and send the write access to critical resource, determine first task access conflict to described critical resource to the access of critical resource and the second task in critical section.Certainly, do not limit in embodiments of the present invention this kind of implementation that judges conflict, can also have other implementations, specifically can need to judge according to application scenarios.
In the present embodiment, can for accessing each task of critical resource, corresponding priority be set in advance, or, also can be when needs compare priority, according to the type of task or carry out the priority that content sets the tasks, wherein, the type of task or priority corresponding to execution content can set in advance.
Be understandable that, wherein, the high judgement of the priority of priority ratio second task of first task, according to implementing needs, can be carried out after judging conflict, also can execution before judging conflict, do not limit in the present invention.
If S220 conflict, accesses the critical resource of described critical section to first task.
Visible, the method that the application embodiment of the present invention provides, can the access to critical resource in response to first task, judge whether first task clashes with second task of just accessing critical resource in critical section the access of critical resource, wherein, the priority of priority ratio second task of first task is high, if conflict, the critical resource of described critical section is accessed to first task, therefore, the task of high priority can be accessed critical resource with preempt-mode, without waiting for that low priority task is carried out, finish, thereby can realize the object that improves system real time.
Below, then in conjunction with an application scenarios, the embodiment of the present invention is described in detail.For example, in train scheduling management system, there are a plurality of tasks, such as " train Real-Time Scheduling task ", " log recording task " etc.Priority lower " log recording task " accessing critical resource (as, database) time, if there is emergency condition, " train Real-Time Scheduling task " need to access critical resource, the method that the application embodiment of the present invention provides, can make " train Real-Time Scheduling task " that priority is higher mode priority access critical resource to seize, guarantee that real-time task obtains Real-Time Scheduling, improve the real-time of train scheduling management system.
In a kind of possible implementation of the embodiment of the present invention, at access critical resource do not conflict in the situation that, a plurality of tasks can walk abreast and in critical section, carry out with to described critical resource concurrent access.Two of the schematic flow sheet of the resource regulating method that the embodiment of the present invention shown in Figure 3 provides, the step S210 of the embodiment of the present invention can comprise: in the process of carrying out with the second tasks in parallel after first task enters critical section, judge first task to the access of described critical resource whether with the access conflict of the second task to described critical resource, wherein, the priority of priority ratio second task of first task is high.
For example, in this implementation, can use atom variable mark critical section, when task attempts entering critical section, can be divided into following several situation and by atom variable, critical section be protected:
If this critical section of value representation of the atom variable of mark critical section is occupied, and the priority of task that the priority ratio that takies the task of critical section attempts entering critical section is high, task of not allowing described trial to enter critical section enters critical section, thereby can prevent that the task of low priority from interrupting the tasks carrying of high priority;
If this critical section of value representation of the atom variable of mark critical section is unoccupied (if the value of atom variable is original state, for " 0 "), the task of attempting entering critical section can directly enter critical section and carry out, and by the value of atom variable be revised as occupied (as, the value of atom variable is added to 1 in current state);
If this critical section of value representation of the atom variable of mark critical section is occupied, and the priority that the priority ratio trial that takies the task of critical section enters the task of accessing critical section is low, the task of attempting entering critical section can directly enter critical section and carry out, and by the value of atom variable carry out corresponding modify (as, the value of atom variable is added to 1 in current state).
In order to prevent that mistake is appearred in the modification of the value of atom variable, can protect atom variable by the mode of transaction internal memory or lock.For example, if protect atom variable by the mode of transaction internal memory, can work as while conflicting between the execution instruction that the value of atom variable is modified, again sequentially the value of atom variable be modified, guarantee correct to the modification of the value of atom variable.
In addition, in this implementation, because first task can be carried out in critical section with the second tasks in parallel, therefore, when access critical resource clashes, need all carrying out in critical section of tasks that task rollback all occurs, thereby guarantee the consistance of data.For example, three of the schematic flow sheet of the resource regulating method that the embodiment of the present invention shown in Figure 4 provides, in the present embodiment, in the process of carrying out with the second tasks in parallel after first task enters critical section, if judge first task access conflict to described critical resource to the access of described critical resource and the second task, can also comprise:
S230, the rollback of control first task generation task, re-execute first task; And, control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In this implementation, owing to cancelling the second task to the taking of CPU, therefore, can reduce unnecessary CPU time consumption.Be understandable that, cancel in the present embodiment the second task to the taking of CPU, can be the second task occurs after the message of described conflict obtaining, and initiatively cancels taking CPU.
In a kind of possible implementation of the present embodiment, in order to improve the executed in parallel of the task that priority is high as far as possible, reduce task that priority is low to the taking of critical resource, before first task enters critical section and the execution of the second tasks in parallel, can also comprise the following steps:
When first task attempts entering critical section, if there is second task of just accessing critical resource in critical section, the priority of the priority of more described first task and described the second task;
If the priority of the second task is high described in the priority ratio of first task, allow first task to enter critical section and described the second tasks in parallel execution;
If the priority of described first task equals the priority of described the second task or lower than the priority of described the second task, first task is placed in and waits for the state of retry or cancel first task taking CPU;
Or,
When first task attempts entering critical section, while if there is no just accessing the task of critical resource in critical section, allow described first task to enter critical section and carry out;
Or,
When first task and the 3rd task attempt entering critical section simultaneously, the relatively priority of first task and the priority of the 3rd task;
If the priority of the priority ratio of first task the 3rd task is high, allows described first task to enter described critical section and carry out;
If the priority of described first task equals the priority of described the 3rd task or lower than the priority of described the 3rd task, first task is placed in and waits for the state of retry or cancel first task taking CPU.
In this implementation, owing to only having than the task that in critical section, already present task priority is high, can enter critical section execution, therefore, improve the executed in parallel of the task that priority is high, reduce task that priority is low to the taking of critical resource, thereby further improved the real-time of system.
In the another kind of possible implementation of the embodiment of the present invention, if do not allow low priority task and high-priority task executed in parallel in critical section, five of the schematic flow sheet of the resource regulating method that the embodiment of the present invention shown in Figure 5 provides, the step S210 of the embodiment of the present invention can comprise: judgement first task attempts entering critical section when to critical resource access, whether there is second task of just accessing described critical resource in critical section, if existed, determine that first task clashes the access of critical resource and second task of just accessing critical resource in critical section, wherein, the priority of priority ratio second task of first task is high.
Be understandable that, in order to guarantee the consistance of data, in first task, attempt entering critical section when to critical resource access, if determine that first task clashes the access of critical resource and second task of just accessing critical resource in critical section, as shown in Figure 6, can also comprise S240: control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
For example, in this implementation, can use atom variable mark critical section, by to the access of atom variable and be a same atomic transaction to the access flag of critical resource in critical section, and then work as the first task that priority is higher and attempt entering critical section, when atom variable is conducted interviews, because first task clashes the access of atom variable and second task of just accessing critical resource in critical section, make to access the second task generation task rollback of critical resource in critical section.
Visible, in this implementation, due to when first task attempts entering critical section, the judgement just conflicting, , if there is the second task of described critical section access critical resource, and first task is higher than the second task priority, determine conflict, first task enters critical section and carries out, the critical resource of described critical section is accessed to first task, and, control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU, thereby only need the second task generation task rollback, without the rollback of first task generation task, avoided expense extra time that in first task implementation, task rollback produces again, system real time is better.
Corresponding with resource regulating method, the embodiment of the present invention also provides a kind of scheduling of resource equipment.Referring to Fig. 6, show one of structural representation of the scheduling of resource equipment that the embodiment of the present invention provides, as shown in the figure, the equipment that the present embodiment provides can comprise:
Conflict judging unit 610, can be for judging whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, and wherein, the priority of priority ratio second task of first task is high;
In the embodiment of the present invention, judge that whether first task do not limit with the specific implementation just clashing in the second task of critical section access critical resource the access of critical resource.For example, according to implementing needs, if allow low priority task and high-priority task executed in parallel, can in executed in parallel process, judge whether to occur the access conflict to boundary's resource, or, if do not allow low priority task and high-priority task executed in parallel, can, when the higher first task of priority attempts entering critical section, determine that first task clashes the second lower task of the access of critical section and the priority of just accessing critical resource in critical section.
Be understandable that, for the task in critical section executed in parallel, if the read access to critical resource, the executed in parallel between task can not clash conventionally, if the write access to critical resource, the executed in parallel between task can clash.Therefore, after first task enters critical section with the second task in the process of critical section executed in parallel, in the time of can working as at least one task in first task or the second task and send the write access to critical resource, determine first task access conflict to described critical resource to the access of critical resource and the second task in critical section.Certainly, do not limit in embodiments of the present invention this kind of implementation that judges conflict, can also have other implementations, specifically can need to judge according to application scenarios.
In the present embodiment, can for accessing each task of critical resource, corresponding priority be set in advance, or, also can be when needs compare priority, according to the type of task or carry out the priority that content sets the tasks, wherein, the type of task or priority corresponding to execution content can set in advance.
Be understandable that, wherein, the high judgement of the priority of priority ratio second task of first task, according to implementing needs, can be carried out after judging conflict, also can execution before judging conflict, do not limit in the present invention.
Preempting resources unit 620, if can, for conflict, access the critical resource of described critical section to first task.
Visible, the equipment that the application embodiment of the present invention provides, because conflict judging unit 610 judges whether first task clashes with second task of just accessing critical resource in critical section the access of critical resource, wherein, the priority of priority ratio second task of first task is high, preempting resources unit 620 is when conflict judging unit 610 is judged as conflict, the critical resource of described critical section is accessed to first task, therefore, the task of high priority can be accessed critical resource with preempt-mode, without waiting for that low priority task is carried out, finish, thereby can realize the object that improves system real time.
In a kind of possible implementation of the embodiment of the present invention, at access critical resource do not conflict in the situation that, a plurality of tasks can walk abreast and in critical section, carry out with to described critical resource concurrent access.Two of the result schematic diagram of the scheduling of resource equipment that the embodiment of the present invention shown in Figure 7 provides, described conflict judging unit 610: specifically can be in the process of carrying out with the second tasks in parallel after first task enters critical section, judge first task to the access of described critical resource whether with the access conflict of the second task to described critical resource.
For example, in this implementation, can use atom variable mark critical section, when task attempts entering critical section, can be divided into following several situation and by atom variable, critical section be protected:
If this critical section of value representation of the atom variable of mark critical section is occupied, and the priority ratio that takies the task of critical section is attempted the priority of the task of critical section access high, task of not allowing described trial to enter critical section enters critical section, thereby can prevent that the task of low priority from interrupting the tasks carrying of high priority;
If this critical section of value representation of the atom variable of mark critical section is unoccupied (if the value of atom variable is original state, for " 0 "), the task of attempting entering critical section can directly enter critical section and carry out, and by the value of atom variable be revised as occupied (as, the value of atom variable is added to 1 in current state);
If this critical section of value representation of the atom variable of mark critical section is occupied, and the priority ratio that takies the task of critical section is attempted the priority of the task of critical section access low, the task of attempting entering critical section can directly enter critical section and carry out, and by the value of atom variable carry out corresponding modify (as, the value of atom variable is added to 1 in current state).
In order to prevent that mistake is appearred in the modification of the value of atom variable, can protect atom variable by the mode of transaction internal memory or lock.For example, if protect atom variable by the mode of transaction internal memory, can work as while conflicting between the execution instruction that the value of atom variable is modified, again sequentially the value of atom variable be modified, guarantee correct to the modification of the value of atom variable.
In addition, in this implementation, because first task can be carried out in critical section and the second tasks in parallel, therefore, when access critical resource clashes, need all carrying out in critical section of tasks that task rollback all occurs, thereby guarantee the consistance of data.For example, two of the structural representation of the scheduling of resource equipment that the embodiment of the present invention shown in Figure 7 provides, in the present embodiment, can also comprise: the first rollback unit 730, can be in the process of carrying out with the second tasks in parallel after first task enters critical section, if conflict judging unit 610 is judged first task access conflict to described critical resource to the access of described critical resource and the second task, control the rollback of first task generation task, re-execute first task, and, control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In this implementation, owing to cancelling the second task to the taking of CPU, therefore, can reduce unnecessary CPU time consumption.Be understandable that, cancel in the present embodiment the second task to the taking of CPU, can be the second task occurs after the message of described conflict obtaining, and initiatively cancels taking CPU.
In a kind of possible implementation of the present embodiment, in order to improve the executed in parallel of the task that priority is high as far as possible, reduce task that priority is low to the taking of critical resource, before first task enters critical section and the execution of the second tasks in parallel, can also comprise:
The first comparing unit 701, can, for when first task attempts entering critical section, just access the second task of described critical resource, the priority of the priority of more described first task and described the second task if existed in critical section;
The first access unit 702, if it is high to compare described in the priority ratio of first task the priority of the second task for the first comparing unit, allow first task to enter critical section and described the second tasks in parallel execution, if the first comparing unit compares the priority of first task, equal the priority of described the second task or lower than the priority of described the second task, first task is placed in and waits for the state of retry or cancel first task taking CPU;
Or,
The second access unit 703, can, for when first task attempts entering critical section, while if there is no just accessing the task of described critical resource in critical section, allow described first task to enter critical section and carry out;
Or,
The second comparing unit 704, can be for when first task and the 3rd task attempt entering critical section simultaneously, relatively the priority of first task and the priority of the 3rd task;
The 3rd access unit 705, if it is high to compare the priority of priority ratio the 3rd task of first task for the second comparing unit, allowing described first task to enter described critical section carries out, if the second comparing unit compares the priority of first task, equal the priority of described the 3rd task or lower than the priority of described the 3rd task, first task is placed in and waits for the state of retry or cancel first task taking CPU.
In this implementation, owing to only having than the task that in critical section, already present task priority is high, can enter critical section execution, therefore, improve the executed in parallel of the task that priority is high, reduce task that priority is low to the taking of critical resource, thereby further improved the real-time of system.
In a kind of possible implementation of the present embodiment, if do not allow low priority task and high-priority task executed in parallel in critical section.Two of the structural representation of the scheduling of resource equipment that the embodiment of the present invention shown in Figure 7 provides, conflict judging unit 610, can attempt entering critical section when to critical resource access for judgement first task, whether there is second task of just accessing described critical resource in critical section, if existed, determine that first task clashes the access of critical resource and second task of just accessing critical resource in critical section, wherein, the priority of priority ratio second task of first task is high;
Be understandable that, in order to guarantee the consistance of data, the equipment that the present embodiment provides can also comprise, the second rollback unit 740, can be for attempting entering critical section in first task when to critical resource access, if conflict judging unit is determined first task the access of critical resource and second task of just accessing critical resource in critical section is clashed, control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
Visible, in this implementation, due to when first task attempts entering critical section, the judgement just conflicting, , conflict judging unit 610 is judged the second task of described critical section access critical resource that exists, and first task is higher than the second task priority, determine conflict, by preempting resources unit 620, the critical resource of described critical section is accessed to first task, by the second rollback unit 740, making first task enter critical section carries out, and, control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU, thereby only need the second task generation task rollback, without the rollback of first task generation task, avoided expense extra time that in first task implementation, task rollback produces again, system real time is better.
It should be noted that, as shown in Figure 7, described the first rollback unit 730, the second rollback unit 740, the first comparing unit 701, the first access unit 702, the second access unit 703, the second comparing unit 704, the 3rd access unit 705 are used dotted lines in Fig. 7, to represent that these unit are not the necessary unit of present device.
From the angle of modular functionality entity, the scheduling of resource equipment the embodiment of the present invention is described above, from the angle of hardware handles, the scheduling of resource equipment the embodiment of the present invention is described below, refer to Fig. 8, scheduling of resource equipment 800 another embodiment in the embodiment of the present invention comprise:
Wherein the quantity of the processor 803 in scheduling of resource equipment 800 can be for one or more for input media 801, output unit 802, processor 803 and storer 804(, and the processor 803 of take in Fig. 8 is example).In some embodiments of the invention, input media 801, output unit 802, processor 803 and storer 804 can be connected by bus or alternate manner, wherein, in Fig. 8 to be connected to example by bus.
Wherein, by calling the operational order of storer 804 storages, processor 803, for carrying out following steps:
Judge whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, and wherein, the priority of priority ratio second task of first task is high;
If conflict, accesses the critical resource of described critical section to first task.
In some embodiments of the invention, processor 803 is carried out describedly judges that whether first task comprises with the step just clashing in the second task of critical section access critical resource the access of critical resource:
In the process of carrying out with the second tasks in parallel after first task enters critical section, judge first task to the access of described critical resource whether with the access conflict of the second task to described critical resource;
Or,
Judgement first task attempts entering critical section when to critical resource access, whether there is second task of just accessing described critical resource in critical section, if existed, determine that first task clashes the access of critical resource and second task of just accessing critical resource in critical section.
In some embodiments of the present invention, in the process that processor 803 is carried out with the second tasks in parallel after first task enters critical section, if judge first task access conflict to described critical resource to the access of described critical resource and the second task, can also be for carrying out following steps:
Control the rollback of first task generation task, re-execute first task;
And,
Control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In some embodiments of the present invention, processor 803 attempts entering critical section when to critical resource access in first task, if determine that first task clashes the access of critical resource and the second task at critical section access critical resource just, can also be for carrying out following steps:
Control the second task generation task rollback, the second task is placed in and waits for the state of retry or cancel the second task taking CPU.
In some embodiments of the present invention, processor 803 enters before critical section and the second tasks in parallel carry out in first task, can also be for carrying out following steps:
When first task attempts entering critical section, if there is the second task of described critical resource of just accessing in critical section, the priority of the priority of more described first task and described the second task, if the priority of the second task is high described in the priority ratio of first task, allow first task to enter critical section and described the second tasks in parallel execution, if the priority of described first task equals the priority of described the second task or lower than the priority of described the second task, first task is placed in and waits for the state of retry or cancel first task taking CPU;
Or,
When first task attempts entering critical section, while if there is no just accessing the task of described critical resource in critical section, allow described first task to enter critical section and carry out;
Or,
When first task and the 3rd task attempt entering critical section simultaneously, compare the priority of first task and the priority of the 3rd task, if the priority of the priority ratio of first task the 3rd task is high, allowing described first task to enter described critical section carries out, if the priority of described first task equals the priority of described the 3rd task or lower than the priority of described the 3rd task, first task is placed in and waits for the state of retry or cancel first task taking CPU.
In the present embodiment, when processor 803 judges whether first task clashes with second task of just accessing critical resource in critical section the access of critical section, wherein, the priority of priority ratio second task of first task is high, if while conflicting, the critical resource of described critical section is accessed to first task, therefore, the task of high priority can be accessed critical resource with preempt-mode, finishes, thereby can realize the object that improves system real time without waiting for that low priority task is carried out.
Those skilled in the art can be well understood to, for convenience and simplicity of description, the system of foregoing description, the specific works process of device and unit, can, with reference to the corresponding process in preceding method embodiment, not repeat them here.
In the several embodiment that provide in the application, should be understood that, disclosed system, apparatus and method, can realize by another way.For example, device embodiment described above is only schematic, for example, the division of described unit, be only that a kind of logic function is divided, during actual realization, can have other dividing mode, for example a plurality of unit or assembly can in conjunction with or can be integrated into another system, or some features can ignore, or do not carry out.Another point, shown or discussed coupling each other or direct-coupling or communication connection can be by some interfaces, indirect coupling or the communication connection of device or unit can be electrically, machinery or other form.
The described unit as separating component explanation can or can not be also physically to separate, and the parts that show as unit can be or can not be also physical locations, can be positioned at a place, or also can be distributed in a plurality of network element.Can select according to the actual needs some or all of unit wherein to realize the object of the present embodiment scheme.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, can be also that the independent physics of unit exists, and also can be integrated in a unit two or more unit.Above-mentioned integrated unit both can adopt the form of hardware to realize, and also can adopt the form of SFU software functional unit to realize.
If the form of SFU software functional unit of usining described integrated unit realizes and during as production marketing independently or use, can be stored in a computer read/write memory medium.Understanding based on such, the all or part of of the part that technical scheme of the present invention contributes to prior art in essence in other words or this technical scheme can embody with the form of software product, this computer software product is stored in a storage medium, comprise that some instructions are with so that a computer equipment (can be personal computer, server, or the network equipment etc.) carry out all or part of step of method described in each embodiment of the present invention.And aforesaid storage medium comprises: various media that can be program code stored such as USB flash disk, portable hard drive, ROM (read-only memory) (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disc or CDs.
And, in this article, relational terms such as the first and second grades is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply and between these entities or operation, have the relation of any this reality or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby the process, method, article or the equipment that make to comprise a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or be also included as the intrinsic key element of this process, method, article or equipment.The in the situation that of more restrictions not, the key element being limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment that comprises described key element and also have other identical element.
The above, above embodiment only, in order to technical scheme of the present invention to be described, is not intended to limit; Although the present invention is had been described in detail with reference to previous embodiment, those of ordinary skill in the art is to be understood that: its technical scheme that still can record aforementioned each embodiment is modified, or part technical characterictic is wherein equal to replacement; And these modifications or replacement do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (10)

1. a resource regulating method, is characterized in that, comprising:
Judge whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, and wherein, the priority of priority ratio second task of first task is high;
If conflict, accesses the critical resource of described critical section to first task.
2. method according to claim 1, is characterized in that, describedly judges that whether with just first task clashes and comprise in the second task of critical section access critical resource the access of critical resource:
In the process of carrying out with the second tasks in parallel after first task enters critical section, judge described first task to the access of described critical resource whether with the access conflict of described the second task to described critical resource;
Or,
Judge that described first task attempts entering critical section when to critical resource access, whether there is second task of just accessing described critical resource in critical section, if existed, determine that described first task clashes the access of critical resource and described second task of just accessing critical resource in critical section.
3. method according to claim 2, it is characterized in that, in the process of carrying out with the second tasks in parallel after first task enters critical section, if judge the access conflict to described critical resource to the access of described critical resource and described the second task of described first task, also comprise:
Control the rollback of described first task generation task, re-execute described first task;
And,
Control described the second task generation task rollback, described the second task is placed in and waits for the state of retry or cancel described the second task taking CPU.
4. method according to claim 2, it is characterized in that, in described first task, attempt entering critical section when to critical resource access, if determine that described first task clashes the access of critical resource and the second task at critical section access critical resource just, also comprises:
Control described the second task generation task rollback, described the second task is placed in and waits for the state of retry or cancel described the second task taking CPU.
5. method according to claim 2, is characterized in that, before described first task enters critical section and the execution of the second tasks in parallel, also comprises:
When described first task attempts entering critical section, if there is the second task of described critical resource of just accessing in critical section, the priority of the priority of more described first task and described the second task, if the priority of the second task is high described in the priority ratio of described first task, allow described first task to enter critical section and described the second tasks in parallel execution, if the priority of described first task equals the priority of described the second task or lower than the priority of described the second task, described first task is placed in and waits for the state of retry or cancel described first task taking CPU,
Or,
When described first task attempts entering critical section, while if there is no just accessing the task of described critical resource in critical section, allow described first task to enter critical section and carry out;
Or,
When described first task and the 3rd task attempt entering critical section simultaneously, the priority of the priority of more described first task and described the 3rd task, if the priority of the 3rd task is high described in the priority ratio of described first task, allowing described first task to enter described critical section carries out, if the priority of described first task equals the priority of described the 3rd task or lower than the priority of described the 3rd task, described first task is placed in and waits for the state of retry or cancel described first task taking CPU.
6. a scheduling of resource equipment, is characterized in that, comprising:
Conflict judging unit, for judging whether first task clashes with second task of just accessing described critical resource in critical section the access of critical resource, and wherein, the priority of priority ratio second task of first task is high;
Preempting resources unit, if for conflict, accessed the critical resource of described critical section to first task.
7. equipment according to claim 1, it is characterized in that, described conflict judging unit: in the process of carrying out with the second tasks in parallel after first task enters critical section, judge described first task to the access of described critical resource whether with the access conflict of described the second task to described critical resource;
Or,
Described conflict judging unit, specifically for judging described first task, attempt entering critical section when to critical resource access, whether there is second task of just accessing described critical resource in critical section, if existed, determine that described first task clashes the access of critical resource and described second task of just accessing critical resource in critical section.
8. equipment according to claim 7, it is characterized in that, also comprise: the first rollback unit, for the process of carrying out with the second tasks in parallel after first task enters critical section, if conflict judging unit is judged the access conflict to described critical resource to the access of described critical resource and described the second task of described first task, control the rollback of described first task generation task, re-execute described first task, and, control described the second task generation task rollback, described the second task is placed in and waits for the state of retry or cancel described the second task taking CPU.
9. equipment according to claim 7, it is characterized in that, also comprise: the second rollback unit, for attempting entering critical section in described first task when to critical resource access, if conflict judging unit is determined described first task the access of critical resource and second task of just accessing critical resource in critical section is clashed, control described the second task generation task rollback, described the second task is placed in and waits for the state of retry or cancel described the second task taking CPU.
10. equipment according to claim 7, is characterized in that, also comprises:
The first comparing unit, for when described first task attempts entering critical section, is just accessing the second task of described critical resource, the priority of the priority of more described first task and described the second task if existed in critical section; The first access unit, if it is high to compare described in the priority ratio of described first task the priority of the second task for the first comparing unit, allow described first task to enter critical section and described the second tasks in parallel execution, if the first comparing unit compares the priority of described first task, equal the priority of described the second task or lower than the priority of described the second task, described first task is placed in and waits for the state of retry or cancel described first task taking CPU;
Or,
The second access unit, for when described first task attempts entering critical section, while if there is no just accessing the task of described critical resource in critical section, allows described first task to enter critical section and carries out;
Or,
The second comparing unit, for when described first task and the 3rd task attempt entering critical section simultaneously, the priority of the priority of more described first task and described the 3rd task; The 3rd access unit, if it is high to compare described in the priority ratio of described first task the priority of the 3rd task for the second comparing unit, allowing described first task to enter described critical section carries out, if the second comparing unit compares the priority of described first task, equal the priority of described the 3rd task or lower than the priority of described the 3rd task, described first task is placed in and waits for the state of retry or cancel described first task taking CPU.
CN201310712166.1A 2013-12-20 2013-12-20 A kind of resource regulating method and equipment Expired - Fee Related CN103699437B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310712166.1A CN103699437B (en) 2013-12-20 2013-12-20 A kind of resource regulating method and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310712166.1A CN103699437B (en) 2013-12-20 2013-12-20 A kind of resource regulating method and equipment

Publications (2)

Publication Number Publication Date
CN103699437A true CN103699437A (en) 2014-04-02
CN103699437B CN103699437B (en) 2017-06-06

Family

ID=50360976

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310712166.1A Expired - Fee Related CN103699437B (en) 2013-12-20 2013-12-20 A kind of resource regulating method and equipment

Country Status (1)

Country Link
CN (1) CN103699437B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104636205A (en) * 2014-12-26 2015-05-20 北京奇艺世纪科技有限公司 Task seizing method and device
CN107193647A (en) * 2017-05-25 2017-09-22 深信服科技股份有限公司 Sandbox environment task processing method and system under a kind of NUMA architecture
CN107743621A (en) * 2015-06-16 2018-02-27 北欧半导体公司 Integrated circuit inputs and output
CN107870779A (en) * 2016-09-28 2018-04-03 北京忆芯科技有限公司 Dispatching method and device
CN108153582A (en) * 2016-12-05 2018-06-12 北京忆恒创源科技有限公司 I/O command processing method and Media Interface Connector controller
CN108668331A (en) * 2017-03-30 2018-10-16 展讯通信(上海)有限公司 A kind of method for scheduling task and device of multimode device
CN109086142A (en) * 2018-09-25 2018-12-25 郑州云海信息技术有限公司 A kind of resource regulating method and device based on Openlava
WO2019001332A1 (en) * 2017-06-27 2019-01-03 阿里巴巴集团控股有限公司 Task priority processing method and processing device
CN110737616A (en) * 2018-07-20 2020-01-31 瑞昱半导体股份有限公司 Circuit system for processing interrupt priority
CN111158890A (en) * 2020-01-20 2020-05-15 北京一流科技有限公司 System and method for controlling task parallelism in task set
CN111416780A (en) * 2020-03-10 2020-07-14 延锋伟世通电子科技(上海)有限公司 Real-time priority ceiling optimization method, system, medium and terminal
CN113360256A (en) * 2020-03-06 2021-09-07 烽火通信科技股份有限公司 Thread scheduling method and system based on control plane massive concurrent messages

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005004350A (en) * 2003-06-10 2005-01-06 Sony Ericsson Mobilecommunications Japan Inc Resource management method and device, resource management program, and storage medium
CN1327349C (en) * 2005-06-13 2007-07-18 浙江大学 Task level resource administration method for micro-kernel embedded real-time operation systems
CN1801813B (en) * 2005-09-30 2010-05-05 华为技术有限公司 Dynamic content playing method and apparatus
CN100530111C (en) * 2007-09-10 2009-08-19 中兴通讯股份有限公司 Multi-thread access indirect register scheduling method
CN101883436B (en) * 2010-06-24 2014-08-20 宇龙计算机通信科技(深圳)有限公司 Concurrent processing method and system for resources and mobile terminal
CN101868000A (en) * 2010-06-28 2010-10-20 中兴通讯股份有限公司 Method, device and base station for preempting resources
CN101977442A (en) * 2010-10-11 2011-02-16 中兴通讯股份有限公司 Method and system for allocating circuit resources in call priority accessing
CN102056319A (en) * 2011-01-25 2011-05-11 华为技术有限公司 Resource scheduling method and radio network controller

Cited By (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104636205B (en) * 2014-12-26 2019-02-05 北京奇艺世纪科技有限公司 A kind of method and apparatus that task is seized
CN104636205A (en) * 2014-12-26 2015-05-20 北京奇艺世纪科技有限公司 Task seizing method and device
CN107743621A (en) * 2015-06-16 2018-02-27 北欧半导体公司 Integrated circuit inputs and output
CN107743621B (en) * 2015-06-16 2021-07-27 北欧半导体公司 Integrated circuit input and output
CN107870779A (en) * 2016-09-28 2018-04-03 北京忆芯科技有限公司 Dispatching method and device
CN107870779B (en) * 2016-09-28 2023-12-12 北京忆芯科技有限公司 Scheduling method and device
CN108153582B (en) * 2016-12-05 2024-01-26 北京忆恒创源科技股份有限公司 IO command processing method and medium interface controller
CN108153582A (en) * 2016-12-05 2018-06-12 北京忆恒创源科技有限公司 I/O command processing method and Media Interface Connector controller
CN108668331A (en) * 2017-03-30 2018-10-16 展讯通信(上海)有限公司 A kind of method for scheduling task and device of multimode device
CN108668331B (en) * 2017-03-30 2020-08-07 展讯通信(上海)有限公司 Task scheduling method and device for multimode equipment
CN107193647A (en) * 2017-05-25 2017-09-22 深信服科技股份有限公司 Sandbox environment task processing method and system under a kind of NUMA architecture
CN109144682A (en) * 2017-06-27 2019-01-04 阿里巴巴集团控股有限公司 The priority processing method and processing unit of task
US11321125B2 (en) 2017-06-27 2022-05-03 Alibaba Group Holding Limited Task priority processing method and processing device
WO2019001332A1 (en) * 2017-06-27 2019-01-03 阿里巴巴集团控股有限公司 Task priority processing method and processing device
CN110737616A (en) * 2018-07-20 2020-01-31 瑞昱半导体股份有限公司 Circuit system for processing interrupt priority
CN110737616B (en) * 2018-07-20 2021-03-16 瑞昱半导体股份有限公司 Circuit system for processing interrupt priority
CN109086142B (en) * 2018-09-25 2022-03-25 郑州云海信息技术有限公司 Resource scheduling method and device based on Openlava
CN109086142A (en) * 2018-09-25 2018-12-25 郑州云海信息技术有限公司 A kind of resource regulating method and device based on Openlava
WO2021147878A1 (en) * 2020-01-20 2021-07-29 北京一流科技有限公司 System for controlling parallelism of tasks in task set, and method therefor
CN111158890A (en) * 2020-01-20 2020-05-15 北京一流科技有限公司 System and method for controlling task parallelism in task set
CN113360256A (en) * 2020-03-06 2021-09-07 烽火通信科技股份有限公司 Thread scheduling method and system based on control plane massive concurrent messages
CN111416780A (en) * 2020-03-10 2020-07-14 延锋伟世通电子科技(上海)有限公司 Real-time priority ceiling optimization method, system, medium and terminal

Also Published As

Publication number Publication date
CN103699437B (en) 2017-06-06

Similar Documents

Publication Publication Date Title
CN103699437A (en) Resource scheduling method and device
US10241852B2 (en) Automated qualification of a safety critical system
CN104866762B (en) Security management program function
US9189524B2 (en) Obtaining partial results from a database query
JP6947723B2 (en) A method for efficient task scheduling in the presence of conflicts
CN111045933B (en) Regression strategy updating method and device, storage medium and terminal equipment
Xie et al. Minimizing development cost with reliability goal for automotive functional safety during design phase
US11016805B2 (en) Programmatically applying labels to nodes in cluster orchestration platforms
DE102013104328A1 (en) Assignment of tasks in large and small cores
US11663337B2 (en) Methods and systems for system call reduction
CN108459913B (en) Data parallel processing method and device and server
CN103329102A (en) Multiprocessor system
CN109144685B (en) Architecture and services to support reconfigurable synchronization in a multi-processing system
EP4231138A1 (en) Method and apparatus for fixing weak memory ordering problem
CN112181637B (en) Memory resource allocation method and device
US20060218382A1 (en) Data processing disorder preventing method
US11294729B2 (en) Resource provisioning for multiple invocations to an electronic design automation application
CN108089895B (en) Activity registration method and device in plug-in, electronic equipment and storage medium
CN111880803B (en) Software construction method and device applied to multiple platforms
CN115129449A (en) Resource scheduling method and device for shared GPU
Kienberger et al. Parallelizing highly complex engine management systems
CN113391821A (en) Asymmetric multiprocessor embedded operating system
Khalgui Embedded Computing Systems: Applications, Optimization, and Advanced Design: Applications, Optimization, and Advanced Design
CN114691830B (en) Network security analysis method and system based on big data
US20210240469A1 (en) Method and apparatus for managing modules

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20170606

Termination date: 20181220