CN103309734A - Embedded task scheduling method based on priority grouping - Google Patents

Embedded task scheduling method based on priority grouping Download PDF

Info

Publication number
CN103309734A
CN103309734A CN2013102503301A CN201310250330A CN103309734A CN 103309734 A CN103309734 A CN 103309734A CN 2013102503301 A CN2013102503301 A CN 2013102503301A CN 201310250330 A CN201310250330 A CN 201310250330A CN 103309734 A CN103309734 A CN 103309734A
Authority
CN
China
Prior art keywords
task
priority
ready
scheduling
switched
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.)
Pending
Application number
CN2013102503301A
Other languages
Chinese (zh)
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.)
Harbin Institute of Technology
Original Assignee
Harbin Institute of Technology
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 Harbin Institute of Technology filed Critical Harbin Institute of Technology
Priority to CN2013102503301A priority Critical patent/CN103309734A/en
Publication of CN103309734A publication Critical patent/CN103309734A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses an embedded task scheduling method based on priority grouping, and relates to the field of task scheduling in embedded systems. The method solves the problems that the existing task scheduling method is complicated to operate, and requires abundant computational processes and storage spaces, so that the resource consumption is great, and inconveniences are brought to understanding and modification of developers. The method comprises the steps that N tasks are grouped according to a priority; retrieval is performed according to the group priority from high to low; the highest group with a ready task is retrieved; the ready task with the highest priority is acquired to serve as a task to be switched; information of the task to be switched is acquired; and task switching is performed. The method can be widely applied to task scheduling of an embedded system.

Description

The built-in tasks dispatching method of Priority-based grouping
Technical field
The present invention relates to the task scheduling field in the embedded system.
Background technology
Along with the fast development of software and hardware, the function of modern embedded device becomes increasingly powerful.The function that realizes along with embedded device becomes increasingly complex, and traditional single task model can't satisfy the demands, so realized operating system in embedded device, unifies resource is managed by operating system, dispatches each task.And for built-in field, the operating system that all requires to adopt satisfies good stability, and fast response time is dealt with the various situations that had strict demand the time.
Task scheduling is as one of core of embedded OS, and major function is the ready task of selecting from a plurality of user tasks, then turns user task and carries out.Task scheduling in the embedded OS generally is based on priority and dispatches, and namely each task can be given a priority according to the difference of its significance level, and the scheduler in the embedded system can be selected the highest ready task operation of priority.But existing method for scheduling task complex operation needs a large amount of computation process and storage space.
Summary of the invention
The present invention needs a large amount of computation process and storage space in order to solve existing method for scheduling task complex operation, causes the problem that consumption of natural resource is large, be not easy to developer's understanding and revise, thereby a kind of method for scheduling task of Priority-based grouping is provided.
The built-in tasks dispatching method of Priority-based grouping, it comprises the steps:
Step 1: N task according to priority divided into groups; A described N task according to priority grade sorts, and is divided into P priority groups, namely every group Individual priority;
The grade that described task sorts according to priority sorts from high in the end or sorts from low to high;
Step 2: retrieve from high to low according to group priority, and will have the highest group of ready task to retrieve, obtain have limit priority ready task as to be switched task;
Described task activates and stops by activate a task and terminated task, wherein:
Activate a task is used for activating priority tasks and makes it become ready task;
Terminated task is used for stopping ready task and makes it become not ready task;
Step 3: obtain to be switched mission bit stream and the switching of executing the task.
The present invention has realized the built-in tasks scheduling of Priority-based grouping.Dispatching efficiency of the present invention is high, storage space is little, simple in structure and be suitable for the method for scheduling task of the embedded real time system of change task trial of strength.Employing the method for the invention can be saved general search time and be searched number of times, and the task quantity that allows to store is unrestricted.
Fig. 1 is the process flow diagram that the present invention is based on the built-in tasks dispatching method of priority packet;
Fig. 2 is the embodiment three described process flow diagrams of executing the task and switching;
Fig. 3 is the process flow diagram of embodiment four described activate a tasks;
Fig. 4 is the process flow diagram of embodiment five described terminated tasks;
Fig. 5 is the scheduling model exemplary plot of specific embodiment.
Embodiment
Embodiment one illustrates this embodiment in conjunction with Fig. 1.The built-in tasks dispatching method of Priority-based grouping, it comprises the steps:
Step 1: N task according to priority divided into groups; A described N task according to priority grade sorts, and is divided into P priority groups, namely every group
Figure BDA00003392439400021
Individual priority;
The grade that described task sorts according to priority sorts from high in the end or sorts from low to high;
Step 2: retrieve from high to low according to group priority, and will have the highest group of ready task to retrieve, obtain have limit priority ready task as to be switched task;
Described task activates and stops by activate a task and terminated task, wherein:
Activate a task is used for activating priority tasks and makes it become ready task;
Terminated task is used for stopping ready task and makes it become not ready task;
Step 3: obtain to be switched mission bit stream and the switching of executing the task.
What embodiment two, this embodiment and embodiment one were different is step 3: obtain to be switched mission bit stream and comprise task status information, task context information and task control information;
Task status information is for the self information of sign task;
Task context information is used for preserving the field data of scheduling process;
Task control information is used for scheduling and the management of task;
Described task status information comprises the priority of task, current state and the task type of task;
Described task context information comprises the content of general-purpose register, content, user stack pointer and the kernel stack pointer of control register;
Described task control information comprises the relevant information of task scheduling, the relevant information of intertask communication and the resource operating position information of task.
Embodiment three, in conjunction with Fig. 2 this embodiment is described, what this embodiment and embodiment two were different is that the described handoff procedure of executing the task of step 3 is:
Steps A 1: be used for the step that the task of obtaining is switched commencing signal;
Steps A 2: be used for closing the step of interrupting;
Steps A 3: be used for preserving the current task contextual information
Steps A 4: be used for arranging the step that to be switched task is current task;
Steps A 5: for the step of the to be switched task context information of packing into;
Steps A 6: be used for opening interruption the step of executing the task and switching.
Embodiment four, in conjunction with Fig. 3 this embodiment is described, what this embodiment was different from embodiment one or three is activate a task, is used for activating priority tasks and makes it become the ready task process to be:
Step B1: for the step of the priority of obtaining task to be activated;
Step B2: be used for judging whether effectively step of task priority; If then enter step B3, then withdraw from if not process;
Step B3: the step that is used for described task status is changed to ready state;
Step B4: be used for described task is put into the step of priority query;
Step B5: whether the numbering that is used for judging described task priority is greater than the limit priority of its place group; If then enter step B6, then enter if not step B7;
Step B6: for the step of the limit priority numbering of upgrading described task place group;
Step B7: the step that is used for judging current interruption status; Interrupt then withdrawing from process if be in to close, then carry out the task switching if be in out interruption.
Embodiment five, in conjunction with Fig. 4 this embodiment is described, what this embodiment and embodiment four were different is described terminated task, be used for stopping ready task make it become not the ready task process is:
Step C1: the step that is used for obtaining the terminated task signal;
Step C2: the step that is used for judging current interruption status; Interrupt then withdrawing from process if be in to close, then enter C3 if be in out interruption.
Step C3: be used for arranging the step that current task is suspended state;
Step C4: for the step that current task is shifted out from ready queue;
Step C5: be used for judging that the numbering of priority of described terminated task is whether greater than the limit priority of its place group; If then enter step C6, otherwise enter step C7;
Step C6: for the step of the limit priority numbering of upgrading described terminated task place group;
Step C7: be used for carrying out the step that task is switched.
The present invention's average cost of switching of executing the task is
Figure BDA00003392439400041
Cost when carrying out an activate a task is a compare operation, and the average cost of carrying out a terminated task is
Figure BDA00003392439400042
As can be known, system carries out total cost that scheduler task spends and is
Figure BDA00003392439400043
And work as The time, the Least-cost of dispatching office cost, and along with the reducing of task quantity in the system, the required cost of task scheduling reduces.
In conjunction with Fig. 5 specific embodiment is described:
Suppose task according to priority is numbered, from 0 to 63, to number greatlyr, priority is higher, will be 8 groups from small to large by number, every group of 8 priority.In a certain moment of system operation, ready task has 56,57,58,59 in the priority groups 7, and wherein ready limit priority is 59, does not have ready priority in the priority groups 6, then determines successively the highest priority in every group the ready task.
When task Interruption in the system occurs, at first judge whether ready task, in the situation that does not have ready task, the operation idle task when having ready task, begins to select to have the task of limit priority.Check successively from priority groups is high to Low whether ready task is arranged the group.So ready limit priority is 59. to select 59 for current ready super objective priority number in the priority groups 7, find the task control module of No. 59 tasks according to the task scheduling associated mechanisms, scheduler carries out task and switches, and begins to carry out the user program of No. 59 task definitions.
When task priority of activation is No. 43 tasks, No. 43 task belongs to priority groups 5, limit priority is No. 42 tasks in original priority groups 5, and this moment, No. 43 tasks were larger than the priority of No. 42 tasks, have higher priority, be updated to No. 43 so upgrade priority groups 5 the highest ready priority tasks numberings.And when task priority of activation was No. 26 tasks, No. 26 tasks belonged to priority groups 3, and limit priority is No. 31 tasks in the former priority groups 3, and this moment, No. 31 task priorities of priority ratio of No. 26 tasks were little, so do not upgrade priority list.
When task priority of termination is 42 task, No. 42 task belongs to priority groups 5, limit priority is No. 42 tasks in original priority groups 5, No. 42 tasks that stop this moment are limit priority task in the priority groups 5, need to find out the task of having limit priority in this group in the residue ready task this moment, so upgrade priority groups 5 the highest ready priority tasks numberings.
The dispatching algorithm of the built-in tasks dispatching method that the present invention is based on priority packet and μ C/OS-II is compared: μ C/OS-II is a outstanding operating system of built-in field, especially spoken approvingly of by the people in dispatching algorithm.Because μ C/OS-II only supports 64 fixed priority numbers, thus in the algorithm of Priority-based grouping, will get N=64, P=8, comparative result is as follows:
Figure BDA00003392439400051
Can find out from contrast, compare μ C/OS-II dispatching algorithm, the Priority-based packet scheduling algorithm has been saved very large space, and has obtained very high dirigibility, and the time cost of paying really seldom.And in the application of reality, the priority number of use generally can not surpass 64, so that the dispatching algorithm performance of Priority-based grouping can be very is good.

Claims (5)

1. the built-in tasks dispatching method of Priority-based grouping is characterized in that it comprises the steps:
Step 1: N task according to priority divided into groups; A described N task according to priority grade sorts, and is divided into P priority groups, namely every group
Figure FDA00003392439300011
Individual priority;
The grade that described task sorts according to priority sorts from high in the end or sorts from low to high;
Step 2: retrieve from high to low according to group priority, and will have the highest group of ready task to retrieve, obtain have limit priority ready task as to be switched task;
Described task activates and stops by activate a task and terminated task, wherein:
Activate a task is used for activating priority tasks and makes it become ready task;
Terminated task is used for stopping ready task and makes it become not ready task;
Step 3: obtain to be switched mission bit stream and the switching of executing the task.
2. the method for scheduling task of Priority-based grouping according to claim 1 is characterized in that step 3: obtain to be switched mission bit stream and comprise task status information, task context information and task control information;
Task status information is for the self information of sign task;
Task context information is used for preserving the field data of scheduling process;
Task control information is used for scheduling and the management of task;
Described task status information comprises the priority of task, current state and the task type of task;
Described task context information comprises the content of general-purpose register, content, user stack pointer and the kernel stack pointer of control register;
Described task control information comprises the relevant information of task scheduling, the relevant information of intertask communication and the resource operating position information of task.
3. the method for scheduling task of Priority-based according to claim 2 grouping is characterized in that the described handoff procedure of executing the task of step 3 is:
Steps A 1: be used for the step that the task of obtaining is switched commencing signal;
Steps A 2: be used for closing the step of interrupting;
Steps A 3: be used for preserving the current task contextual information
Steps A 4: be used for arranging the step that to be switched task is current task;
Steps A 5: for the step of the to be switched task context information of packing into;
Steps A 6: be used for opening interruption the step of executing the task and switching.
4. according to claim 1 or the method for scheduling task of 3 described Priority-baseds grouping, it is characterized in that activate a task, be used for activating priority tasks and make it become the ready task process to be:
Step B1: for the step of the priority of obtaining task to be activated;
Step B2: be used for judging whether effectively step of task priority; If then enter step B3, then withdraw from if not process;
Step B3: the step that is used for described task status is changed to ready state;
Step B4: be used for described task is put into the step of priority query;
Step B5: whether the numbering that is used for judging described task priority is greater than the limit priority of its place group; If then enter step B6, then enter if not step B7;
Step B6: for the step of the limit priority numbering of upgrading described task place group;
Step B7: the step that is used for judging current interruption status; Interrupt then withdrawing from process if be in to close, then carry out the task switching if be in out interruption.
5. the method for scheduling task of Priority-based grouping according to claim 4 is characterized in that described terminated task, and the ready task process is to make it become not for the termination ready task:
Step C1: the step that is used for obtaining the terminated task signal;
Step C2: the step that is used for judging current interruption status; Interrupt then withdrawing from process if be in to close, then enter C3 if be in out interruption.
Step C3: be used for arranging the step that current task is suspended state;
Step C4: for the step that current task is shifted out from ready queue;
Step C5: be used for judging that the numbering of priority of described terminated task is whether greater than the limit priority of its place group; If then enter step C6, otherwise enter step C7;
Step C6: for the step of the limit priority numbering of upgrading described terminated task place group;
Step C7: be used for carrying out the step that task is switched.
CN2013102503301A 2013-06-24 2013-06-24 Embedded task scheduling method based on priority grouping Pending CN103309734A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2013102503301A CN103309734A (en) 2013-06-24 2013-06-24 Embedded task scheduling method based on priority grouping

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2013102503301A CN103309734A (en) 2013-06-24 2013-06-24 Embedded task scheduling method based on priority grouping

Publications (1)

Publication Number Publication Date
CN103309734A true CN103309734A (en) 2013-09-18

Family

ID=49134992

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2013102503301A Pending CN103309734A (en) 2013-06-24 2013-06-24 Embedded task scheduling method based on priority grouping

Country Status (1)

Country Link
CN (1) CN103309734A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103914346A (en) * 2013-12-16 2014-07-09 西北工业大学 Group-based dual-priority task scheduling and energy saving method for real-time operating system
CN104750556A (en) * 2015-04-14 2015-07-01 浪潮电子信息产业股份有限公司 Method and device for dispatching HPC (high performance computing) cluster work
WO2016165467A1 (en) * 2015-09-16 2016-10-20 中兴通讯股份有限公司 Traffic flow-based task scheduling method and apparatus
CN107291542A (en) * 2017-06-27 2017-10-24 北京优特捷信息技术有限公司 A kind of intelligence performs the method and device of retrieval tasks
CN109408208A (en) * 2018-09-21 2019-03-01 深圳华大北斗科技有限公司 Multi-task processing method, equipment, system and the storage medium of navigation chip
CN118025049A (en) * 2024-04-15 2024-05-14 成都创科升电子科技有限责任公司 Control method and system for vehicle electric control based on scheduler and vehicle

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003186685A (en) * 2001-09-21 2003-07-04 Lg Electronics Inc Overload control method for real-time processing system
CN1490722A (en) * 2003-09-19 2004-04-21 清华大学 Graded task switching method based on PowerPC processor structure
CN101178664A (en) * 2007-12-12 2008-05-14 北京中星微电子有限公司 Task scheduling method and system in real-time operating system
CN102043667A (en) * 2010-11-25 2011-05-04 深圳市科陆电子科技股份有限公司 Task scheduling method for embedded operating system
CN102063325A (en) * 2011-01-06 2011-05-18 哈尔滨工业大学 Method for implementing multi-task real-time operating system embedded into 51 series singlechip

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003186685A (en) * 2001-09-21 2003-07-04 Lg Electronics Inc Overload control method for real-time processing system
CN1490722A (en) * 2003-09-19 2004-04-21 清华大学 Graded task switching method based on PowerPC processor structure
CN101178664A (en) * 2007-12-12 2008-05-14 北京中星微电子有限公司 Task scheduling method and system in real-time operating system
CN102043667A (en) * 2010-11-25 2011-05-04 深圳市科陆电子科技股份有限公司 Task scheduling method for embedded operating system
CN102063325A (en) * 2011-01-06 2011-05-18 哈尔滨工业大学 Method for implementing multi-task real-time operating system embedded into 51 series singlechip

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103914346A (en) * 2013-12-16 2014-07-09 西北工业大学 Group-based dual-priority task scheduling and energy saving method for real-time operating system
CN104750556A (en) * 2015-04-14 2015-07-01 浪潮电子信息产业股份有限公司 Method and device for dispatching HPC (high performance computing) cluster work
WO2016165467A1 (en) * 2015-09-16 2016-10-20 中兴通讯股份有限公司 Traffic flow-based task scheduling method and apparatus
CN106547611A (en) * 2015-09-16 2017-03-29 中兴通讯股份有限公司 Method for scheduling task and device based on Business Stream
CN107291542A (en) * 2017-06-27 2017-10-24 北京优特捷信息技术有限公司 A kind of intelligence performs the method and device of retrieval tasks
CN107291542B (en) * 2017-06-27 2020-09-15 北京优特捷信息技术有限公司 Method and device for intelligently executing retrieval task
CN109408208A (en) * 2018-09-21 2019-03-01 深圳华大北斗科技有限公司 Multi-task processing method, equipment, system and the storage medium of navigation chip
CN109408208B (en) * 2018-09-21 2022-04-01 深圳华大北斗科技股份有限公司 Multitasking method, device and system of navigation chip and storage medium
CN118025049A (en) * 2024-04-15 2024-05-14 成都创科升电子科技有限责任公司 Control method and system for vehicle electric control based on scheduler and vehicle

Similar Documents

Publication Publication Date Title
CN103309734A (en) Embedded task scheduling method based on priority grouping
CN103645942B (en) Message queue based write and read method and system of shared memory
CN100549943C (en) Multithreaded microprocessor with the optimization thread scheduler that is used to promote the streamline service efficiency
CN100517236C (en) Intelligent card embedded operation system and its control method
CN100397347C (en) System and method for CPI scheduling on SMT processors
CN101957751B (en) Method and device for realizing state machine
CN103294544B (en) Embedded system and interruption processing method thereof and device
CN108268386A (en) Memory order in accelerating hardware
US7246353B2 (en) Method and system for managing the execution of threads and the processing of data
EP2637095B1 (en) Thin client system, management server, workplace environment setting method and workplace environment setting program
CN101923491A (en) Thread group address space scheduling and thread switching method under multi-core environment
CN101796487A (en) Virtual queue processing circuit and task processor
CN101178664A (en) Task scheduling method and system in real-time operating system
CN104156197A (en) Microprocessor and method for operating microprocessor
US20140317380A1 (en) Multi-core processor
CN103902251A (en) Fault detection in instruction translations
CN102004664A (en) Scheduling method of embedded real-time operating system of space vehicle
CN102541642A (en) Task management method for enhancing real-time performance
CN103412755A (en) Hardware real-time operation system
CN103346902A (en) Method and system for data collection and scheduling
CN109992366A (en) Method for scheduling task and dispatching device
CN106062716A (en) Method, device and single task system for realizing multiple tasks in single task system
CN106201695A (en) It is applicable to the multi-task scheduling method of embedded software system
CN101976204B (en) Service-oriented heterogeneous multi-core computing platform and task scheduling method used by same
CN109992432A (en) A kind of data processing system and method based on message queue

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20130918