CN103377078B - Real-time task scheduling method and system for vehicular ATP - Google Patents

Real-time task scheduling method and system for vehicular ATP Download PDF

Info

Publication number
CN103377078B
CN103377078B CN201210105512.5A CN201210105512A CN103377078B CN 103377078 B CN103377078 B CN 103377078B CN 201210105512 A CN201210105512 A CN 201210105512A CN 103377078 B CN103377078 B CN 103377078B
Authority
CN
China
Prior art keywords
task
kernel
global variable
time
module
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.)
Active
Application number
CN201210105512.5A
Other languages
Chinese (zh)
Other versions
CN103377078A (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.)
Guangzhou Railway Sciences Intelligent Controls Co ltd
China Academy of Railway Sciences Corp Ltd CARS
Guangzhou Metro Group Co Ltd
Original Assignee
China Academy of Railway Sciences Corp Ltd CARS
Guangzhou Metro Group 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 China Academy of Railway Sciences Corp Ltd CARS, Guangzhou Metro Group Co Ltd filed Critical China Academy of Railway Sciences Corp Ltd CARS
Priority to CN201210105512.5A priority Critical patent/CN103377078B/en
Publication of CN103377078A publication Critical patent/CN103377078A/en
Application granted granted Critical
Publication of CN103377078B publication Critical patent/CN103377078B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention belongs to the technical field of urban rail traffic CBTC and particularly discloses a real-time task scheduling method and system for a vehicular ATP. The method includes: generating a global variable, calling a highest-priority first task in a task list to run in a kernel, comparing the priority of the first task running in the kernel to that of a second task newly entering, and continuing to sequentially call all tasks in the task list according to the priority levels to run in the kernel, or interrupting the first task to run the second task. The system comprises a global variable generation module, a kernel running module, a priority level comparison module, and a kernel task running state judgment module. The method and the system mainly have the advantages that inter-task communication awaiting time is shorter, switching efficiency is higher, real-time protection and safety are higher, and the requirement of the vehicular ATP subsystems in the CBTC system for multi-variable, multi-task and high-timeliness task control is met.

Description

Vehicle-mounted ATP real-time task scheduling method and its task scheduling system
Technical field
The invention belongs to urban track traffic CBTC technical fields, and in particular to one kind is embedded in real time based on μ C/OS-II Operating system task scheduling mechanism optimizes the method for scheduling task and its task scheduling system with improved vehicle-mounted ATP.
Background technology
CBTC, it is based on the train automatic controlling system of wireless communication technology.It is in Urban Rail Transit Signal control In system, its vehicle-mounted ATP (time interval between to trains device) is responsible for obtaining and safeguarding train position, receive mobile authorization and calculate safety The functions such as rate curve, supervision train status.The realization of these functions needs vehicle-mounted ATP system to have high real-time, Response in real time and quickly scheduling can be carried out to each task.Therefore vehicle-mounted ATP system generally adopts embedded real-time operation System, for example:TKCG-08 type vehicle-mounted ATP devices just employ μ C/OS-II real time operating systems.
μ C/OS-II are a kind of based on the increasing income of priority, Preemptive multitask real time operating system, contain real-time kernel, Task management, time management, the synchronous function such as (semaphore, mailbox, message, queue) and memory management of intertask communication.It can So that each task works independently, it is non-interference, it is easy to realize punctual and errorless execution, make the design of real-time application Become easy with extension, the design process for making application program is greatly simplified.Just because of these features so that μ C/OS-II are very It is adapted for use with the high occasion of real-time, reliability and security requirement.In fact, μ C/OS-II are used in numerous areas, such as Military project, Aeronautics and Astronautics, armarium and Industry Control etc..
μ C/OS-II operating systems belong to preemptive kernel system, and its functional realiey is task based access control, current car Carry the communication in the task scheduling system of ATP between task mainly has following several ways with scheduling:
(1) the task management mode based on semaphore
Semaphore in μ C/OS-II is made up of two parts:One be semaphore count value, it is the nothing of 16 Symbol integer (between 0 to 65,535);Another wait task list being made up of the waiting the semaphore of the task.Semaphore Semaphore, waiting signal amount, inquiry semaphore and the several functions of sending signal amount are set up using including.Communication between each task according to Ensure the uniqueness that data are used between task by judging the value of semaphore.Such as task A uses variable C simultaneously with task B, with This related semaphore be D, task A using need before variable by waiting signal measure semaphore D be " effective " instruction Just can normally run.If semaphore idle task A will be into sleep state, until semaphore is effective or waits time-out time to arrive.
(2) the task management mechanism based on mailbox
Mailbox is another kind of communication mechanism in μ C/OS-II, and it can make a task or interrupt service subroutine to another One task sends the variable of a pointer type.The pointer points to a data structure for containing specific " message ".Using postal Before case, it is necessary to first set up the mailbox.The operation can be completed (see next section) by calling OSMboxCreate () function, And specify the initial value of pointer.Generally, this initial value is NULL, but it is also possible to initializes a mailbox, makes It is most starting just comprising a piece of news.If the use of the purpose of mailbox being for notifying that the generation of an event (sends one Message), then it is NULL that will initialize the mailbox, because when starting, event does not also occur.If user with mailbox come Share some resources, then the pointer that the mailbox is a non-NULL will be initialized.In this case, mailbox is treated as one Individual binary signal amount is used.Each task sends control information in mailbox, before information of other tasks using mailbox association, needs The whether available mandate of task is obtained from mailbox.If mailbox message is unavailable, task suspension until mailbox message is available or Time-out is waited to reach.
Therefore, existing μ C/OS-II systems are provided task communication and scheduling mechanism, although can effectively protect not With using identical data between task simultaneously, but have the disadvantage that:
(1) substantial amounts of data exchange can cause dispatch command very loaded down with trivial details between task, and program structure is complicated;
(2) exception occurs in individual task can cause other task deadlocks;
(3) without special real-time property preventing mechanism, once semaphore or mailbox operation irregularity, data safety cannot Ensure.
The content of the invention
In order to solve the above problems, it is an object of the invention to provide a kind of method for scheduling task of succinct vehicle-mounted ATP And its task scheduling system, to reduce the communication latency between task and improve switching efficiency.
For achieving the above object, the present invention adopts technical scheme as follows:
A kind of method for scheduling task of vehicle-mounted ATP, including:Generate at least one and be available for the shared global change of multiple tasks Amount, each global variable specifies a task to carry out data modification renewal to it;Priority level highest in calling task list First task is run into kernel, when operating first doing honest work carry out the global variable of data modification renewal by it to specifying When carrying out data modification renewal, the locked task switching of kernel is until data modification renewal is completed;In first task operation Whether the second task is newly entered in monitoring task list simultaneously;After the second task is newly entered, compare just the of kernel operation The priority level height of one task and the second task of the new entrance;If the priority of second task is less than described first Task, then continue to be run into kernel according to each task in priority level height successively calling task list;If described Whether the priority of two tasks is higher than the first task, then judge kernel in locked task switching state;If being not in lock Dead task switching state, then directly interrupt first task and transfer to run the second task;If being in locked task switching state, Wait kernel to release after task switching locking state, then interrupt first task and transfer to run the second task.
Further, before the generation at least one is available for the shared global variable of multiple tasks, the method is also wrapped Include:Multiple tasks are created, and according to the different priority of the relation allocation between each task;Activate each task to perform respectively The corresponding program code of each task, and task list is entered into after the completion of task timer counter wait kernel calls operation.
Further, before generation at least one is available for the shared global variable of multiple tasks, the method also includes:Swash A hardware timer living, the hardware timer is incremented by build a time reference axle according to the cycle of setting;It is complete at each After being updated when office's variable is generated or by modification, the time numerical value on the time reference axle is read immediately as the global variable Timestamp;When each task is run by kernel calls also from the time reference axle read a time numerical value as this The timestamp of business;In each task call global variable, the timestamp for first obtaining this task and the global variable that called The time difference of timestamp, then compare the time difference and default time threshold to determine the effectiveness of corresponding global variable.
Further, it is described to compare the time difference with default time threshold to determine the effective of corresponding global variable Property, specifically:When the time difference is less than or equal to default time threshold, assert that the global variable is effective;When this Between difference be more than default time threshold when, assert that the global variable is invalid.
Further, operating first task uses the specified global variable for being responsible for data modification renewal by other tasks Concrete mode be:For using, wherein the local becomes the local variable of a mapping defined in the storehouse of the first task Measure with specify by the first task be responsible for data modification renewal global variable it is corresponding.
A kind of task scheduling system of vehicle-mounted ATP, including:
Global variable generation module, for generating at least one the shared global variable of multiple tasks is available for, and each is global Variable specifies a task to carry out data modification renewal to it;
Kernel runs module, runs into kernel for priority level highest first task in calling task list, when It is operating it is first do honest work to specify by its global variable for carrying out data modification renewal carry out data modification update when, kernel Locked task switching is until data modification renewal is completed;It is whether new in monitoring task list while the first task is run Into the second task;
Priority comparison module, after the second task is newly entered, for comparing first task and institute just in kernel operation State the priority level height of the second task of new entrance;If the priority of second task is less than the first task, refer to Task execution module is made to continue to be run into kernel according to each task in priority level height successively calling task list;If The priority of second task is higher than the first task, then start kernel running status judge module;
Kernel tasks running status judge module, for judging kernel whether in locked task switching state;If not locating In locked task switching state, then instruct kernel operation module directly to interrupt first task and transfer to run the second task;If just locating In locked task switching state, then instruct kernel operation module to wait kernel to release after task switching locking state, then interrupt the One task transfers to run the second task.
Further, the system also includes task creation module and mission-enabling module;Wherein, task creation module, uses In establishment multiple tasks, and according to the different priority of the relation allocation between each task;Wherein, mission-enabling module, is used for Each task is activated to perform the corresponding program code of each task respectively, and task list is entered into after the completion of task timer counter Wait kernel calls operation.
Further, the system also includes hardware timer, timestamp load-on module and timestamp comparation module;Its In, hardware timer, for being incremented by build a time reference axle according to the cycle of setting;Wherein, timestamp load-on module, After updating when each global variable is generated or by modification, the time numerical value conduct on the time reference axle is read immediately The timestamp of the global variable;When each task is run by kernel calls also from the time reference axle read a time Timestamp of the numerical value as this task;Wherein, timestamp comparation module, in each task call global variable, first obtaining The time difference of the timestamp that takes this task and the timestamp of the global variable for being called, then compare the time difference with it is default Time threshold corresponds to the effectiveness of global variable to determine.
Further, in the timestamp comparation module of the system, the described time difference that compares is with default time threshold To determine the effectiveness of correspondence global variable, specifically:When the time difference is less than or equal to default time threshold, recognize The fixed global variable is effective;When the time difference is more than default time threshold, assert that the global variable is invalid.
Further, the system also includes:Local variable mapping block, for when the operation the run in kernel in module One task using specify be responsible for the global variable of data modification renewal by other tasks when, the local variable mapping block this Defined in the storehouse of one task one mapping local variable for using, wherein the local variable with specify by the first task The global variable that responsible data modification updates is corresponding.
Invention defines multiple global variables, modify more in task running to its corresponding global variable When new, the locked task switching of kernel does not allow other task preemption kernels, but as long as task is not in locked task switching state (be operating first task be not changing update its management global variable when), than operating first task The second high task of priority just can at any time seize kernel, so as to simplify Task Scheduling Mechanism, further reduce certainly Communication latency between task, just improves switching efficiency naturally, changeable such that it is able to meet CBTC system onboard ATP subsystems Amount, multitask, the control task of hard real time need.
Description of the drawings
The there is provided picture of this description of the drawings constitutes of the application for aiding in a further understanding of the present invention Point, inappropriate limitation of the present invention is not constituted, in the accompanying drawings:
Fig. 1 is the ultimate principle schematic flow sheet of method for scheduling task of the present invention;
Fig. 2 is the entire flow schematic diagram of method for scheduling task of the present invention;
Fig. 3 is the timestamp loading principle schematic diagram of another embodiment of the present invention;
Fig. 4 is the corresponding scheduling system principle diagram of Fig. 1 dispatching methods;
Fig. 5 is the corresponding scheduling system principle diagram of Fig. 2 dispatching methods;
Fig. 6 is the corresponding scheduling system principle diagram of Fig. 3 dispatching methods.
Specific embodiment
The present invention is described in detail below in conjunction with specific implementation method, be used in the exemplary embodiment and description of the present invention The present invention is explained, but it is not as a limitation of the invention.
Fig. 1 is the ultimate principle schematic flow sheet of method for scheduling task of the present invention.As shown in figure 1, the dispatching method 100 is wrapped Include:
S110, generates at least one and is available for the shared global variable of multiple tasks, each global variable to specify a task Data modification renewal is carried out to it;
S120, priority level highest first task is run into kernel in calling task list, when operating first Task just to specify carry out data modification by its global variable for carrying out data modification renewal and update when, the switching of kernel locked task Until data modification updates completing;Whether second is newly entered while the first task is run in monitoring task list Business;
After the second task is newly entered, then order performs S130 steps;
S130, compares the priority level height of the second task of the first task and new entrance for just running in kernel; Its comparative result:
If the priority of second task is less than the first task, S120 steps are continued executing with, namely are to continue with Run into kernel according to each task in priority level height successively calling task list;
If the priority of second task is higher than the first task, order performs S140 steps;
Whether S140, judge kernel in locked task switching state;
If judged result is not in locked task switching state, order performs S151 steps, if being in locked task Switching state, then sequentially perform S152 steps;
S151, directly interrupts first task and transfers to run the second task
S152, waits kernel to release after task switching locking state, then interrupts first task and transfer to run the second task.
Known according to above-described embodiment method, the present invention is again based on the scheduling mechanism of task priority, but difference is When a higher priority personage arrives, the mode of interrupt call is entirely different.For example in task list have five it is different Task:T1, T2, T3, T4, T5, if the priority of the distribution of T1-T5 is successively from high to low, then normal condition calls first T1 Into kernel operation, T2, T3, T4, T5 are then called in successively and is run into kernel;When new task Tx enters task list, just In task T3 of execution;If the priority level of Tx is less than T3, continue the operation of T3, certainly after the completion of T3 operations, similarly Be according to T4, T5, Tx they three priority level height call in successively kernel operation;But if the priority level of Tx is higher than Whether T3, then first judge kernel in locked task switching state, straight if kernel is not in locked task switching state Meet interruption T3 to transfer to run Tx, kernel releasing task switching is needed to wait for if kernel is not in locked task switching state locked After state, T3 could be interrupted and transfer to run Tx.
The locked switching state of so-called task, refers to operating T3 just to specifying the global variable updated by its modification to enter State when row modification updates, once is finished in modification renewal release at once task switching locking state.Because, in T3 runnings In, comprising many specific execution actions, also include that data modification update action (including data write by so-called data modification certainly Enter process), it is breakneck to be performed and read the data by other tasks interrupts in data modification renewal process, so this reality The strategy that example just takes the locked switching of task is applied, prevents other tasks from seizing kernel at the moment;Equally, in T3 runnings not Only include data modification renewal process, more times are to perform other actions, if always locked kernel is not cut Change, then the Tx waiting time is longer long, the requirement that emergency is processed in time can not be reached completely, so the present embodiment task lock Extremely switch only in data modification renewal process, if it is corresponding complete to need repeatedly modification to update its in T3 implementation procedures certainly Office's variable, then perform repeatedly locked and releasing task switching state.
Therefore, the locked task handover operation that the present embodiment is carried out by the more new stage in data, can be prevented effectively from The risk read by other tasks in data modification renewal process.Meanwhile, it is this only in data maintenance stage control task scheduling Method the time that task is mutually waited is reduced for semaphore or mailbox.
Certainly, for the locked switchover policy of task for preferably coordinating embodiment to introduce, the present embodiment additionally uses shared Global variable+mapping local variable mode, be:Generate at least one and be available for the shared global variable of multiple tasks, Each global variable specifies a task to modify to it renewal, and other task calls global variable data are just in its storehouse Defined in one mapping local variable it is corresponding with shared global variable;For example:Five different tasks and respective global change Amount (task can be to reply global variable, but a global variable can only be updated modification by a task) It is:T1-a, T2-b, T3-c, T4-d, T5-(e, f), if need to use variable in T3 runnings by a, c, e, f, T3 Except in addition to it can directly invoke c, a, e, f all can only map in storehouse a local variable a1 corresponding with them, e2, F1 is for using.Essence is that the reading of data and modification are updated to be divided into different authorities, and each data is by generating its task Safeguarded, global variable of the task directly to sharing is modified.Other tasks then should be in this task using the data The local variable of a mapping is corresponding with shared global variable defined in storehouse.
Fig. 2 is the entire flow schematic diagram of method for scheduling task of the present invention.As shown in Fig. 2 the method for scheduling task 200 with The difference of method for scheduling task 100 is also to include and existing μ C/OS-II system scheduling methods identical conventional steps S210: Multiple tasks are created, and according to the different priority of the relation allocation between each task;It is each to perform respectively to activate each task The corresponding program code of task, and task list wait kernel calls operation is entered into after the completion of task timer counter.The task Step 220 in dispatching method 200 to 261 (262) is identical to 151 (152) with step S110 in method for scheduling task 100, Here is not repeated.Because many data need to gather before system operation or generate, these are all to have to appoint by establishment The execution of business difference, such as:Door contact interrupter state correspondence defines a vehicle door status Detection task, certainly before train operation The on off state of car door is known for other task calls, so first the corresponding program code of vehicle door status Detection task to refer to Corresponding hardware is made to obtain on off state, other tasks (such as vehicle launch task) are obtained could basis after the status data It makes corresponding action.
In order to ensure the ageing security performance to improve system of data, when the present embodiment also introduces effective data Effect property checking mechanism, does not rely only on the scheduling mechanism of operating system to ensure data validity.The present embodiment is in Fig. 2 basis On, timestamp mechanism has been incorporated herein, the timestamp of each task is generated based on hardware timer, protect by timestamp monitoring It is ageing that card task works, and is:Before generation at least one is available for the shared global variable of multiple tasks, one is activated Hardware timer, the hardware timer is incremented by build a time reference axle according to the cycle of setting, the time cycle according to It can be 1 millisecond or several milliseconds that actual system needs;After updating when each global variable is generated or by modification, read immediately The time numerical value on the time reference axle is taken as the timestamp of the global variable;When each task is run by kernel calls Also a time numerical value is read from the time reference axle as the timestamp of this task;In each task call global variable When, the time difference of the timestamp of the timestamp for first obtaining this task and the global variable for being called, then compare the time difference With default time threshold determining the effectiveness of corresponding global variable.Can be specifically:When the time difference is less than or waits When default time threshold, assert that the global variable is effective;When the time difference is more than default time threshold, assert should Global variable is invalid.
With specific reference to shown in Fig. 3:
Generate in moment t1 or have updated global variable a, b, then obtain timestamp on a timeline and cause the data to be t1+a、t1+b;
Generate in moment t2 or have updated global variable c, d, then obtain timestamp on a timeline and cause the data to be t2+c、t2+d;
In moment t3 operation task 1, in the same manner the timestamp of task 1 is t3, if the operation of task 1 need to call data a, B, c, d, then use compare the time difference obtained between them first:
R1=t3-t1, R2=t3-t2
Then R1 is compared with default time threshold Y1, if R1 is less than or equal to preset time threshold Y1 When, it is believed that a, b are effective;
R2 is compared with default time threshold Y2 again, if R2 is more than default time threshold Y2, it is believed that c, d It is invalid.
The present embodiment is substantially:Independent hardware timer is introduced as system time axle, each task can be by reading The depositor for taking hardware timer obtains own timestamp.On the one hand the timestamp is responsible for safeguarding the life of data as this task Starting mark is checked for other tasks, while being also to check that other tasks are supplied to this task to use the ageing foundation of data. Even if such mechanism ensure that operating system breaks down causes task time delay execution, the delay of data renewal, also will not The safety of impact system, equivalent to system one insurance is increased.
It should be noted that its time threshold is the different numerical value arranged according to actual different situations, such as:Start train Task is task 1, needs to call door contact interrupter state variable to be that (a=1 represents pass to a, and a=0 represents pass, and the moment, difference a was continuous Change update), our given thresholds are 1000 milliseconds;If it is constantly t3 that task 1 brings into operation, obtain first between them Time difference R2=t3-t2, only R2 be less than or equal to 1000 milliseconds, just think that a data are valid data.If this when Between threshold value arrange too big such as 10 minutes, then when within 10 minutes switch gate repeatedly and status data do not update when, it is this It is abnormal just abnormally dangerous, in fact it could happen that car door opens, and train is but travelled always.
Once the system malfunctions in existing system, it is likely that cause data to update delay, it is longer that data update delay Great potential safety hazard will be brought, such as train arrival tail gate opens a period of time, but data never update, also In the closed mode at a certain moment before, due to going checking without timestamp, then will be considered to the data effectively, then will be direct Cause car door not close just to start with regard to train.But the present embodiment is added after timestamp mechanism, and it is to use independently firmly Part intervalometer, can effectively verify the effectiveness of each data, so as to further improve the security performance of system.
Task scheduling system corresponding with preceding method is described below.
Fig. 4 is the corresponding scheduling system principle diagram of Fig. 1 dispatching methods.As shown in figure 4, this enforcement also example discloses a kind of car Carry the task scheduling system 400 of ATP, including global variable generation module 410, kernel operation module 420, priority comparison module 430th, kernel tasks running status judge module 440 and local variable mapping block 450.Wherein, global variable generation module 410, it is available for the shared global variable of multiple tasks, each global variable to specify a task to enter it for generating at least one Row modification updates;Wherein, local variable mapping block 450, for using when the operation first task in kernel operation module When being responsible for changing the global variable for updating by other tasks, the local variable mapping block is defined in the storehouse of the first task For using, wherein the local variable is responsible for data modification renewal to the local variable of one mapping with specifying by the first task Global variable is corresponding.Wherein, kernel operation module 420, for priority level highest first task in calling task list Into kernel operation, when operating first doing honest work carry out data modification renewal by the global variable of its modification renewal to specifying When, the locked task switching of kernel is until data modification renewal is completed;The monitoring task list while first task is run In whether newly enter the second task;Wherein, priority comparison module 430, it is interior for comparing after the second task is newly entered The priority level height of the first task of core operation and the second task of the new entrance;If the priority of second task is low In the first task, then task execution module is instructed to continue according to each in priority level height successively calling task list Task is run into kernel;If the priority of second task is higher than the first task, starts kernel running status and sentence Disconnected module;Wherein, kernel tasks running status judge module 440, for judging kernel whether in locked task switching state; If being not in locked task switching state, instruct kernel operation module directly to interrupt first task and transfer to run the second task; If being in locked task switching state, instruction kernel operation module waits kernel to release after task switching locking state, then Interrupt first task to transfer to run the second task.
Fig. 5 is the corresponding scheduling system principle diagram of Fig. 2 dispatching methods.As shown in figure 5, this scheduling system 500 with tune The difference of degree system 400 is also to include and existing μ C/OS-II system calls system identical conventional modules:Task creation module 510 and mission-enabling module 520.Other modules 530-570 in the system all with scheduling system 400 in module 410-450 It is identical, it is not repeated.Wherein, task creation module 510, for creating multiple tasks, and according to the relation between each task With different priority;Wherein, mission-enabling module 520, for activating each task to perform the corresponding journey of each task respectively Sequence code, and task list wait kernel calls operation is entered into after the completion of task timer counter.
Fig. 6 is the corresponding scheduling system principle diagram of the corresponding dispatching methods of Fig. 3.As shown in figure 5, this scheduling system 600 With scheduling system 500 difference be, also including hardware timer 608, timestamp load-on module 609, timestamp comparation module 610.Other modules 601-607 in the system are all identical with module 510-570 in scheduling system 500, are not repeated.Its In, hardware timer 608, for being incremented by build a time reference axle according to the cycle of setting;Wherein, timestamp loading mould Block 609, after updating when each global variable is generated or by modification, reads immediately the time number on the time reference axle It is worth the timestamp as the global variable;Also from the time reference axle one is read when each task is run by kernel calls Timestamp of the individual time numerical value as this task;Wherein, timestamp comparation module 610, in the global change of each task call During amount, the time difference of the timestamp of the timestamp for first obtaining this task and the global variable for being called, then compare the time difference Value and default time threshold are determining the effectiveness of corresponding global variable.It is described in the timestamp comparation module 610 of the system The relatively time difference and default time threshold to determine the effectiveness of corresponding global variable, specifically:When the time difference During less than or equal to default time threshold, assert that the global variable is effective;When the time difference is more than default time threshold During value, assert that the global variable is invalid.
The technical program is enclosed within μ C/OS-II operating systems for the 1 of the practice proposition of vehicle-mounted ATP system and carries out The solution of task scheduling, it can simplify the interface between application software and operating system, be conducive to Software Architecture Design; The waiting time that can also be communicated between reduction task, improve switching efficiency;The real-time of data exchange between its increase task Protection, can improve security of system.
To sum up embodiment understands that the present invention mainly takes following to realize more safe and efficient task scheduling 2 points of improvement:
First, the present invention adopts succinct task scheduling and communication mechanism, based on μ C/OS-II operating system practical application rings The analysis in border, abandon that μ C/OS-II systems carry based on the task schedulings such as semaphore, mailbox and communication mechanism.Only used Most basic task based access control priority and the function of time management, the priority and execution cycle during by creating to different task Definition, the operating mechanism for realizing task determines.Meanwhile, the globally shared variable task level self-locking implemented by run duration is become More the data exchange between task is realized with local mapping variable call-by mechanism, so as to meet CBTC system onboard ATP subsystems Multivariate, multitask, the control task of hard real time need.
2nd, the present invention is the real-time property protection based on timestamp, introduces independent hardware timer as system Time shafts, each task can pass through to read the depositor of hardware timer and obtain own timestamp.The timestamp one side conduct This task is responsible for safeguarding the life starting mark of data for other task inspections, while being also to check that other tasks are supplied to this The ageing foundation make sure with data, so as to further increase the security performance of system.
The technical scheme for being provided the embodiment of the present invention above is described in detail, specific case used herein The principle and embodiment of the embodiment of the present invention are set forth, the explanation of above example is only applicable to help and understands this The principle of inventive embodiments;Simultaneously for one of ordinary skill in the art, according to the embodiment of the present invention, in specific embodiment party Will change in formula and range of application, in sum, this specification content should not be construed as limiting the invention.

Claims (10)

1. a kind of vehicle-mounted ATP real-time task scheduling method, it is characterised in that include:
Generating at least one is available for the shared global variable of multiple tasks, each global variable to specify a task to enter line number to it Update according to modification;
In calling task list priority level highest first task into kernel run, when it is operating it is first do honest work to refer to When determining to carry out data modification renewal by its global variable for carrying out data modification renewal, the locked task switching of kernel is until data are repaiied Change renewal to complete, operating first task can be used and specify the global variable for being responsible for data modification renewal by other tasks; Whether the second task is newly entered while the first task is run in monitoring task list;
After the second task is newly entered, compare just kernel operation first task and the new entrance the second task it is preferential Rank height;
If the priority of second task is less than the first task, continue according to priority level height successively calling task Each task in list is run into kernel;
If the priority of second task is higher than the first task, judge whether kernel switches shape in locked task State;
If being not in locked task switching state, directly interrupt first task and transfer to run the second task;
If being in locked task switching state, wait kernel to release after task switching locking state, then interrupt first task Then the second task of operation.
2. vehicle-mounted ATP real-time task scheduling method according to claim 1, it is characterised in that generate at least described Individual to be available for before the shared global variable of multiple tasks, the method also includes:
Multiple tasks are created, and according to the different priority of the relation allocation between each task;
Activate each task and taken office with performing the corresponding program code of each task respectively, and entering after the completion of task timer counter Business table waits kernel calls operation.
3. vehicle-mounted ATP real-time task scheduling method according to claim 1, it is characterised in that can generating at least one Before the global variable shared for multiple tasks, the method also includes:
One hardware timer of activation, the hardware timer is incremented by build a time reference axle according to the cycle of setting;
After updating when each global variable is generated or by modification, the time numerical value conduct on the time reference axle is read immediately The timestamp of the global variable;
When each task is run by kernel calls also from the time reference axle read a time numerical value as this task Timestamp;
In each task call global variable, the timestamp of the timestamp for first obtaining this task and the global variable for being called Time difference, then compare the time difference and default time threshold to determine the effectiveness of corresponding global variable.
4. vehicle-mounted ATP real-time task scheduling method according to claim 3, it is characterised in that described to compare the time difference Value and default time threshold to determine the effectiveness of corresponding global variable, specifically:
When the time difference is less than or equal to default time threshold, assert that the global variable is effective;
When the time difference is more than default time threshold, assert that the global variable is invalid.
5. vehicle-mounted ATP real-time task scheduling method according to claim 1, it is characterised in that operating first task It is using the concrete mode for specifying the global variable for being responsible for data modification renewal by other tasks:
Defined in the storehouse of the first task one mapping local variable for using, wherein the local variable with specify by The global variable that the first task is responsible for data modification renewal is corresponding.
6. a kind of vehicle-mounted ATP real-time task scheduling system, it is characterised in that include:
Global variable generation module, for generating at least one the shared global variable of multiple tasks, each global variable are available for A task is specified to carry out data modification renewal to it;
Kernel runs module, runs into kernel for priority level highest first task in calling task list, works as operation In it is first do honest work to specify by its global variable for carrying out data modification renewal carry out data modification update when, kernel is locked Task switching updates up to data modification and completes, and operating first task can be responsible for data modification using specifying by other tasks The global variable of renewal;Whether the second task is newly entered while the first task is run in monitoring task list;
Priority comparison module, after the second task is newly entered, for comparing just in the first task of kernel operation and described new Into the second task priority level height;If the priority of second task is less than the first task, instruction is appointed Business performing module continues to be run into kernel according to each task in priority level height successively calling task list;If described The priority of the second task is higher than the first task, then start kernel running status judge module;
Kernel tasks running status judge module, for judging kernel whether in locked task switching state;If being not in lock Dead task switching state, then instruct kernel operation module directly to interrupt first task and transfer to run the second task;If being in lock Dead task switching state, then instruct kernel operation module to wait kernel to release after task switching locking state, then interrupts first The second task of operation is transferred in business.
7. vehicle-mounted ATP real-time task scheduling system according to claim 6, it is characterised in that the system also includes:
Task creation module, for creating multiple tasks, and according to the different priority of the relation allocation between each task;
Mission-enabling module, for activating each task to perform the corresponding program code of each task respectively, and in task timing Task list is entered into after the completion of counting and waits kernel calls operation.
8. vehicle-mounted ATP real-time task scheduling system according to claim 6, it is characterised in that the system also includes:
Hardware timer, for being incremented by build a time reference axle according to the cycle of setting;
Timestamp load-on module, after updating when each global variable is generated or by modification, reads immediately the time ginseng The time numerical value on axle is examined as the timestamp of the global variable;When each task is run by kernel calls also from the time A time numerical value is read on reference axis as the timestamp of this task;
Timestamp comparation module, in each task call global variable, first obtaining the timestamp of this task and being called Global variable timestamp time difference, then compare the time difference and default time threshold to determine corresponding global become The effectiveness of amount.
9. vehicle-mounted ATP real-time task scheduling system according to claim 8, it is characterised in that the timestamp ratio of the system It is described to compare the time difference and default time threshold to determine the effectiveness of corresponding global variable, specifically in compared with module:
When the time difference is less than or equal to default time threshold, assert that the global variable is effective;
When the time difference is more than default time threshold, assert that the global variable is invalid.
10. vehicle-mounted ATP real-time task scheduling system according to claim 6, it is characterised in that the system also includes:
Local variable mapping block, for being born by other tasks using specified when the operation first task in kernel operation module During the global variable that duty data modification updates, local variable mapping block mapping defined in the storehouse of the first task Local variable for using, wherein the local variable and specify by the first task be responsible for data modification renewal global variable It is corresponding.
CN201210105512.5A 2012-04-11 2012-04-11 Real-time task scheduling method and system for vehicular ATP Active CN103377078B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210105512.5A CN103377078B (en) 2012-04-11 2012-04-11 Real-time task scheduling method and system for vehicular ATP

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210105512.5A CN103377078B (en) 2012-04-11 2012-04-11 Real-time task scheduling method and system for vehicular ATP

Publications (2)

Publication Number Publication Date
CN103377078A CN103377078A (en) 2013-10-30
CN103377078B true CN103377078B (en) 2017-04-12

Family

ID=49462238

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210105512.5A Active CN103377078B (en) 2012-04-11 2012-04-11 Real-time task scheduling method and system for vehicular ATP

Country Status (1)

Country Link
CN (1) CN103377078B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104732434B (en) * 2015-03-31 2018-08-24 北京畅游天下网络技术有限公司 Virtual role transaction system and method
CN104915256B (en) * 2015-06-05 2019-03-26 惠州Tcl移动通信有限公司 A kind of the Real-Time Scheduling implementation method and its system of task
CN105550032A (en) * 2015-10-27 2016-05-04 深圳市美贝壳科技有限公司 CPU (Central Processing Unit) optimization method and system based on Android
CN105824768B (en) * 2016-03-15 2018-09-07 杭州中天微系统有限公司 A kind of vectored interrupt controller for supporting multilayer interrupt priority level to control
WO2018050242A1 (en) * 2016-09-16 2018-03-22 Huawei Technologies Co., Ltd. Efficient scheduler for short periodic tasks
CN106773711B (en) * 2017-01-13 2019-09-17 清华大学 A kind of the hybrid tasks scheduling method and model of railway locomotive operation steerable system
JP6406466B1 (en) * 2017-04-07 2018-10-17 オムロン株式会社 Control device, control method, and control program
CN108111317A (en) * 2017-12-14 2018-06-01 上汽通用五菱汽车股份有限公司 Communication control method based on intra-node state transition
CN109597383B (en) * 2018-12-08 2021-10-08 顾满洲 Lightweight small system reliability structural design
CN109862071B (en) * 2018-12-21 2021-09-10 交控科技股份有限公司 Method and system for automatically uploading vehicle-mounted log based on LTE
CN109981397B (en) * 2019-02-13 2020-12-01 烽火通信科技股份有限公司 Network performance acquisition method and system
CN113515516A (en) * 2021-08-09 2021-10-19 北京字节跳动网络技术有限公司 Data processing method and device, computer equipment and computer storage medium
CN114613041A (en) * 2022-02-24 2022-06-10 智己汽车科技有限公司 Bluetooth key intelligent control method, device, vehicle and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5274823A (en) * 1992-03-31 1993-12-28 International Business Machines Corporation Interrupt handling serialization for process level programming
CN1949178A (en) * 2005-10-11 2007-04-18 国际商业机器公司 Apparatus, system, and method for overriding resource controller lock ownership
CN101290588A (en) * 2008-03-07 2008-10-22 重庆邮电大学 Micro-embedded real time task scheduling device and scheduling method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5274823A (en) * 1992-03-31 1993-12-28 International Business Machines Corporation Interrupt handling serialization for process level programming
CN1949178A (en) * 2005-10-11 2007-04-18 国际商业机器公司 Apparatus, system, and method for overriding resource controller lock ownership
CN101290588A (en) * 2008-03-07 2008-10-22 重庆邮电大学 Micro-embedded real time task scheduling device and scheduling method

Also Published As

Publication number Publication date
CN103377078A (en) 2013-10-30

Similar Documents

Publication Publication Date Title
CN103377078B (en) Real-time task scheduling method and system for vehicular ATP
Wu et al. Distributed mutual exclusion algorithms for intersection traffic control
CN101246437B (en) Built-in real-time system course equalization scheduling method
CN102216902A (en) Method for the deterministic execution and synchronisation of an information processing system comprising a plurality of processing cores executing system tasks
CN107608351A (en) A kind of autonomous traffic control device and methods of AGV
CN102285364B (en) Distributed train concurrent dispatching method based on train priorities
CN102184373B (en) Method for designing safety core of operation system based on protection mode and virtualization mechanism
CN105138310A (en) Concurrent access control method and system
CN102096605A (en) Multi-level resource management implementation method in embedded real-time operation system
CN109376009A (en) A kind of method and device of shared resource
CN100549972C (en) Train control system
CN101770398A (en) Operating system kernel
CN102915292B (en) Based on the communication means of polycaryon processor and detection method thereof and control method
CN101158849A (en) Method for preventing industrial automation system from snowslip
CN113860097B (en) Elevator dispatching method and device, terminal equipment and storage medium
CN106445475A (en) Process-based asynchronous call model realized by using lambda expression
CN109756546B (en) Intelligent networked automobile cloud control operating system
CN115123343A (en) Vehicle control method, device, vehicle and computer storage medium
CN109710399A (en) A kind of DSP communication task scheduling system and method
Ni et al. A message efficient intersection control algorithm based on VANETs
CN113415312A (en) Turnout control method and device under train dynamic test based on FAO
Carr et al. An open on-board CBTC controller based on N-version programming
CN101539863A (en) Task key system survival emergency recovery method based on quaternary nested restart
JP7409567B2 (en) Automotive computer control method and vehicle electronic control device
WO2024051004A1 (en) Sorting management method for rail transit line resources, and device and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 510335 Guangdong city in Guangzhou Province, Haizhuqu District Road No. 618 Xingang South Fenghui Global trade and Exhibition Center from eleventh to 14

Applicant after: GUANGZHOU METRO GROUP Co.,Ltd.

Applicant after: CHINA ACADEMY OF RAILWAY SCIENCES

Address before: 510030 Guangdong city of Guangzhou province Zhongshan five China Travel Commercial City No. 219 sixteen floor

Applicant before: GUANGZHOU METRO Corp.

Applicant before: China Academy of Railway Sciences

COR Change of bibliographic data
GR01 Patent grant
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: 510335 Floor 11-14 of Nanfenghui Global Exhibition and Trade Center, 618 Xingang East Road, Haizhu District, Guangzhou City, Guangdong Province

Co-patentee after: CHINA ACADEMY OF RAILWAY SCIENCES Corp.,Ltd.

Patentee after: GUANGZHOU METRO GROUP Co.,Ltd.

Address before: 510335 Floor 11-14 of Nanfenghui Global Exhibition and Trade Center, 618 Xingang East Road, Haizhu District, Guangzhou City, Guangdong Province

Co-patentee before: China Academy of Railway Sciences

Patentee before: GUANGZHOU METRO GROUP Co.,Ltd.

CP01 Change in the name or title of a patent holder
TR01 Transfer of patent right

Effective date of registration: 20181130

Address after: Room 661, Room 333 Jiufojian Road, Zhongxin Guangzhou Knowledge City, Guangzhou, Guangdong Province

Patentee after: GUANGZHOU RAILWAY SCIENCES INTELLIGENT CONTROLS Co.,Ltd.

Address before: 510335 Floor 11-14 of Nanfenghui Global Exhibition and Trade Center, 618 Xingang East Road, Haizhu District, Guangzhou City, Guangdong Province

Co-patentee before: CHINA ACADEMY OF RAILWAY SCIENCES Corp.,Ltd.

Patentee before: GUANGZHOU METRO GROUP Co.,Ltd.

TR01 Transfer of patent right