CN102063325A - Method for implementing multi-task real-time operating system embedded into 51 series singlechip - Google Patents

Method for implementing multi-task real-time operating system embedded into 51 series singlechip Download PDF

Info

Publication number
CN102063325A
CN102063325A CN2011100011178A CN201110001117A CN102063325A CN 102063325 A CN102063325 A CN 102063325A CN 2011100011178 A CN2011100011178 A CN 2011100011178A CN 201110001117 A CN201110001117 A CN 201110001117A CN 102063325 A CN102063325 A CN 102063325A
Authority
CN
China
Prior art keywords
task
stack
current
interrupt
address
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
CN2011100011178A
Other languages
Chinese (zh)
Other versions
CN102063325B (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.)
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 CN 201110001117 priority Critical patent/CN102063325B/en
Publication of CN102063325A publication Critical patent/CN102063325A/en
Application granted granted Critical
Publication of CN102063325B publication Critical patent/CN102063325B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a method for implementing a multi-task real-time operating system embedded into a 51 series singlechip, which relates to the operating system embedded into the singlechip and solves the problems of large code number and single task of the conventional operating system embedded into the singlechip. In the method, the operating system is implemented by the edition of a keil-based C51 programming language and the compilation of a keil-based compiler, and different tasks are distinguished by _task_ keywords. In a multi-task switching process of the operating system, task switching is performed by disabling interrupts and starting a task switching module after a new task signal is received, and comprises the following steps of: first judging whether a current task is an idle task or not, not saving stack information if the current task is the idle task, and saving the stack information if the current task is not the idle task; then judging whether the current task has the highest priority or not, not performing stack adjustment if the current task has the highest priority, and performing the stack adjustment if the current task does not have the highest priority; and finally setting the task with the highest priority to be the current task, directly returning if the current task is the idle task, and judging whether popup is required or not and then returning if the current task is not the idle task.

Description

A kind of implementation method of multiple task real-time operation system of embedding 51 series monolithics
Technical field
The present invention relates to the embedded programming technology, be specifically related to a kind of operating system that embeds single-chip microcomputer inside.
Background technology
Along with the development of software engineering, existing embedded real-time operating system has obtained to use widely.In single-chip microcomputer, implant embedded OS, can realize the intellectuality of single-chip microcomputer product.But, because the size of code of general operating system is all long, make that needed storage space is bigger, be not suitable for the limited single-chip microcomputer of memory headroom.
In the prior art, the operating system that embeds single-chip microcomputer inside has ucosii, small rtos 51 and rtx51-tiny, wherein the ucosii portable arrives in the single-chip microcomputer of many types, but because the internal memory of 51 series monolithics is smaller, this kind operating system is not suitable for 51 series monolithics.Small rtos 51 is a kind of operating system of developing at 51 single-chip microcomputers, the advantage of this operating system is that kernel designs at 51 single-chip microcomputers, kernel is more optimized, more close with ucosii, relatively abundanter system task is provided simultaneously, but there is following shortcoming in this system: do not make full use of at the C51 programming language of keil _ key word among the task_ designs, therefore can not utilize the code optimization function of keil compiler, or even need to be provided with in the artificial compiler, make it stop code optimization; In addition, the code of this system is still a bit long for 51 series monolithics.Rtx51-tiny: be the operating system at 51 single-chip microcomputers of keil company exploitation, this system has overcome the shortcoming of smallrtos 51 systems effectively, and still, this system does not have the advantage of small rtos 51.
Summary of the invention
Be unsuitable for the use of 51 series monolithics greatly in order to solve the existing size of code that embeds the operating system of single-chip microcomputer inside, and the problem that code is long, task is single of the operating system of existing 51 series monolithics of moving into, the present invention proposes a kind of implementation method of multiple task real-time operation system of embedding 51 series monolithics.
The implementation method of the multiple task real-time operation system of embedding 51 series monolithics of the present invention is to adopt based on the C51 programming language editor of keil and adopt the compiling of keil compiler to realize, and the different task of employing _ task_ key word difference, the multitask handoff procedure of this operating system is:
After receiving the new task signal, close to interrupt, initiating task handover module then, this module realizes that the process of switching is:
At first, when the generation task was switched, it judged that at first current moving of task is an idle task, if idle task is not then preserved stack information, otherwise preserved stack information;
Then, judge that current task is the limit priority task, if current task is exactly the limit priority task, then do not do the storehouse adjustment, otherwise do the storehouse adjustment;
At last, after the storehouse adjustment finished, the task of limit priority was set to current task, and observing current task then is idle task, if idle task is just directly returned, just can return then otherwise need judge whether to go out stack operation.
The process of described preservation stack information is:
Step Q1, judge whether current task is idle task, if, execution in step Q2 then, otherwise execution in step Q3;
Step Q2, from the task stack array, load top-of-stack pointer to SP; Execution in step Q4 then;
Step Q3, preservation stack information SP are to task storehouse array.
The process of described storehouse adjustment is:
Step Q4, from task ready list lqRdyTbl, find out the task of the limit priority in the ready list; Execution in step Q5 then;
Step Q5, judge whether the limit priority task in the ready list is current task, if judged result is for being to carry out current task; Otherwise execution in step Q6 carries out the storehouse adjustment;
Step Q6, obtain the stack top location of the limit priority task in the ready list;
Step Q7, judge whether the priority of current task is higher than the priority of the limit priority task in the ready list, if judged result is for being, execution in step Q10 then; Otherwise execution in step Q8;
Step Q8, according to the difference between the stack top address of address that loads stack top in the task stack array and limit priority task, the space length that to move, and the address is located at the bottom of the data of being stored in the storer between the stack top address of the address that loads stack top in the task stack array and the limit priority task in the ready list being transferred to the stack of current task;
Step Q9, according to the difference that loads in address at the bottom of the stack of current task and the task stack array between the stack top address, adjust the task stack stack floors of the ID correspondence of all tasks in the storehouse array, make all tasks the ID correspondence task stack stack floors all the task stack stack floors of the limit priority task ID correspondence in ready list between the task stack stack floors of the ID correspondence of current task; The storehouse adjustment finishes;
Step Q10, according to the difference between the address at the bottom of the stack of the stack top address of the limit priority task in the ready list and current task, obtain mobile space length, and all data in the storer between the address at the bottom of the stack of the stack top address of the limit priority task in ready list and current task are moved to the place, address that loads stack top in the task stack array;
Step Q11, according to the difference that loads in address at the bottom of the stack of current task and the task stack array between the stack top address, adjust the task stack stack floors of the ID correspondence of all tasks in the storehouse array, make all tasks the ID correspondence task stack stack floors all the task stack stack floors of the limit priority task ID correspondence in ready list between the task stack stack floors of the ID correspondence of current task number; The storehouse adjustment finishes.
The task of described limit priority is set to current task, and observing current task then is idle task, if idle task, just directly returns, otherwise need judge whether to go out the detailed process that stack operation just can return then is:
Step Q12, with the task of the limit priority in the ready list as current task;
Step Q13, judge whether current task is idle task, if judged result is for being, execution in step Q16 then; Otherwise execution in step Q14;
Step Q14, judge whether current task is interrupted switching, if judged result is for being, execution in step Q15 then, otherwise execution in step Q16;
Step Q15, task switching type are set to non-interruption switching type, and the execution register goes out stack operation;
Step Q16, open interruption, finish the work and call.
Operating system of the present invention has the advantage of small rtos 51 systems and rtx51-tiny system simultaneously, this operating system made full use of in the C51 programmed environment of keil _ and the key word of task_ designs, given full play to the code optimization function of keil compiler, make the size of code after the compiling few, the system task of this operating system is abundant.
Embodiment
Embodiment one: the implementation method of the multiple task real-time operation system of described a kind of embedding 51 series monolithics of present embodiment, be to adopt based on the C51 programming language editor of keil and adopt the compiling of keil compiler to realize, and the different task of employing _ task_ key word difference, the task handoff procedure of this operating system is:
After receiving the new task signal, close to interrupt, initiating task handover module then, this module realizes that the process of switching is:
At first, when the generation task was switched, it judged that at first current moving of task is an idle task, if idle task is not then preserved stack information, otherwise preserved stack information;
Then, judge that current task is the limit priority task, if current task is exactly the limit priority task, then do not do the storehouse adjustment, otherwise do the storehouse adjustment;
At last, after the storehouse adjustment finished, the task of limit priority was set to current task, and observing current task then is idle task, if idle task is just directly returned, just can return then otherwise need judge whether to go out stack operation.
Embodiment two: present embodiment is that the process of the preservation stack information described in the present embodiment adopts following process to realize to the further qualification of the implementation method of the multiple task real-time operation system of embodiment one described a kind of embedding 51 series monolithics:
Step Q1, judge whether current task is idle task, if, execution in step Q2 then, otherwise execution in step Q3;
Because the data in the idle task storehouse are gibberish entirely, so idle task does not need to preserve stack information; If not idle task, the data in the storehouse are useful information, must preserve stack information when task is switched.
Step Q2, from the task stack array, load top-of-stack pointer to SP; Execution in step Q4 then
Step Q3, preservation stack information SP are to task storehouse array.
The action that this step is finished is to preserve stack information.
Embodiment three: present embodiment is that the process of the storehouse adjustment described in the present embodiment adopts following process to realize to the further qualification of the implementation method of the multiple task real-time operation system of embodiment one described a kind of embedding 51 series monolithics:
Step Q4, from task ready list lqRdyTbl, find out the task of the limit priority in the ready list; Execution in step Q5 then;
Step Q5, judge whether the limit priority task in the ready list is current task, if judged result is for being to carry out current task; Otherwise execution in step Q6 carries out the storehouse adjustment;
If current task is the task of the limit priority in the ready list, do not need so to do the storehouse adjustment, otherwise need the storehouse adjustment, load the storehouse of the limit priority task in the ready list.
Step Q6, obtain the stack top location of the limit priority task in the ready list;
Step Q7, judge whether the priority of current task is higher than the priority of the limit priority task in the ready list, if judged result is for being, execution in step Q10 then; Otherwise execution in step Q8;
Current task is carrying out of a task, and " limit priority task " is exactly that current task is switched away, then " the limit priority task in the ready list " of operation.This thing happens might be that two kinds of reasons cause: one, current moving of task, in the process of operation, activated a task that priority is higher, must the generation task switch so, at this moment the priority of " limit priority task " is certainly greater than current task; Two, current task needs the external world to provide certain resource in the process of operation, and this resource can not obtain for the moment, so current moving of task just is suspended, to wait for that the external world provides its resource needed, current task is when being suspended, the switching of will executing the task switches " limit priority task " in the ready list, and the priority of " limit priority task " is lower than the priority of current task certainly at this moment.
Step Q8, according to the difference between the stack top address of address that loads stack top in the task stack array and limit priority task, the space length that to move, and the address is located at the bottom of the data of being stored in the storer between the stack top address of the address that loads stack top in the task stack array and the limit priority task in the ready list being transferred to the stack of current task;
Step Q9, according to the difference that loads in address at the bottom of the stack of current task and the task stack array between the stack top address, adjust the task stack stack floors of the ID correspondence of all tasks in the storehouse array, make all tasks the ID correspondence task stack stack floors all the task stack stack floors of the limit priority task ID correspondence in ready list between the task stack stack floors of the ID correspondence of current task; The storehouse adjustment finishes;
For the ID number task between current task and limit priority task, their stack floors needs to adjust.
Step Q10, according to the difference between the address at the bottom of the stack of the stack top address of the limit priority task in the ready list and current task, obtain mobile space length, and all data in the storer between the address at the bottom of the stack of the stack top address of the limit priority task in ready list and current task are moved to the place, address that loads stack top in the task stack array;
Step Q11, according to the difference that loads in address at the bottom of the stack of current task and the task stack array between the stack top address, adjust the task stack stack floors of the ID correspondence of all tasks in the storehouse array, make all tasks the ID correspondence task stack stack floors all the task stack stack floors of the limit priority task ID correspondence in ready list between the task stack stack floors of the ID correspondence of current task number; The storehouse adjustment finishes.
Embodiment four: present embodiment is the further qualification to the implementation method of the multiple task real-time operation system of embodiment one described a kind of embedding 51 series monolithics, described in the present embodiment, the task of limit priority is set to current task, observing current task then is idle task, if idle task, just directly return, be otherwise need judge whether to go out the detailed process that stack operation just can return then:
Step Q12, with the task of the limit priority in the ready list as current task;
Step Q13, judge whether current task is idle task, if judged result is for being, execution in step Q16 then; Otherwise execution in step Q14;
At this moment, because current task has been the most enough priority tasks in the ready list, so, if when current task is idle task, directly opens and interrupt returning getting final product.
Step Q14, judge whether current task is interrupted switching, if judged result is for being, execution in step Q15 then, otherwise execution in step Q16;
When carrying out this step, current task has been the most enough priority tasks in the ready list, if current task is an idle task, because all information of idle task all are invalid informations, so directly open and interrupts returning getting final product.
Step Q15, task switching type are set to non-interruption switching type, and the execution register goes out stack operation;
Step Q16, open interruption, finish the work and call.
In the described method of the respective embodiments described above, different tasks distinguished in use _ task_ key word, can be so that the different functions that called by different task be even without calling mutually, and their local variable can not cover mutually yet.
Embodiment five: present embodiment is the further qualification to the implementation method of the multiple task real-time operation system of described a kind of embedding 51 series monolithics of embodiment one to four arbitrary embodiment, present embodiment is that the global variable in the described operating system is done further qualification, and the global variable of this system has:
The global data variable that the variable module comprises has: task status table unaigned char data lqTaskState[lqMaxID], task ready list Unsigned char data lqRdyTb1, task switching type table unsigned char data lqSwitch Type, interrupt number unsigned char data lqIntNum, sign amount data unsigned char data lqCtr, semaphore data structure unsinged char data lqSemData[lqSemMax*2], message mailbox data structure unsinged char datalqMsgData[lqMsgMax*2], wherein:
Task status table unaigned char data lqTaskState[lqMaxID] with the bit representation task status of byte, each the bit representation information in the described byte is:
The 7th K_MSG is mailbox event flag position, and this position bit representation current task is being waited for mailbox;
The 6th K_SEM is semaphore event flag position, and this position bit representation current task is in wait-semaphore;
The 5th K_FLG is sign amount event flag position, and this position bit representation current task is being waited for the sign amount;
The 4th K_TMO postpones the waiting event zone bit, and this position bit representation current task is postponing wait;
The 0-3 position is that task is waited for case index number, is used for the call number of logger task waiting event;
Described the 4th K_TMO can with any one set simultaneously among K_MSG, K_SEM, the K_FLG, certain incident is waited in expression at the appointed time, if this incident takes place in official hour, then this moment, K_TMO was cleared, if in official hour, this time does not take place, and then this task is activated, and this moment, K_TMO was set.
Task in the present embodiment waits for that case index number is the tetrad sign indicating number, can put down in writing 16 incidents.
For example, as task status table unaigned char data lqTaskState[lqMaxID] parameter when being 10010010B, the expression current task is No. 2 mailbox incidents of waiting in official hour.
The i bit representation i task of task ready list Unsigned char data lqRdyTb1 is in ready state;
The i position bit representation i task of task switching type table unsigned char data lqSwitch Type is switched away by interrupting, otherwise, represent that the i task switched away by the higher priority task.
According to the sign in the task switching type table, be when interrupting being switched as task, carry out push operation, save register: when task is switched away by the higher priority task, do not carry out the register push operation.
Interrupt number variable unsigned char data lqIntNum, Senior Three position record interrupt nesting number, low 5 record interrupt types number;
The Senior Three position is used to write down the interrupt nesting number in the described interrupt number variable, and this operating system can have 7 heavy interrupt nestings at most.
Low 5 interrupt type in the middle-end number number is the entry address that is used to obtain interrupt task, and this operating system can be supported 32 interruptions at most.
Sign amount data unsigned char data lqCtr, most significant digit represents whether current sign amount is effective, all the other seven tasks of waiting for this sign amount with the form record of position.
When the most significant digit of these sign amount data is effective, activate low 7 being write down of tasks of these sign amount data.In this operating system, the initial value of sign amount data can be given as 0x80 or 0x00 when initialization.
Semaphore data structure unsinged char data lqSemData[lqSemMax*2], first byte representation signal quantity of this data structure, second byte waited for the task of the signal quantity correspondence that first byte is represented with the form record of position,
In this system, the initial value of this semaphore data structure, first byte is between 0-255, and second byte is 0.When the semaphore incident was effective, the limit priority task of wait-semaphore was ready.If nobody is waiting for this semaphore, the signal value of current demand signal amount adds 1 so.
Message mailbox data structure unsinged char data lqMsgData[lqMsgMax*2], the message value of first this mailbox of byte representation in this data structure, the most significant digit of second byte represents whether this mailbox has message, if this position, position, represent that then this mailbox has message, otherwise represent that this mailbox does not have message; Low 7 mission bit streams of waiting for the incident of this mailbox with the form record of position of second byte;
This message mailbox data structure is when system initialization, and first byte is between 0-255; The initial value of second byte is 0x80 or 0x00.
When in the mailbox message being arranged, can send message to this mailbox again, when message sent failure, the former message in this mailbox can not be capped.When the mailbox incident is effective, the message value in the message mailbox data structure is returned in the highest task of priority of waiting for this message.
Interrupt routine entry address array unsigned int code lqISREnter[], be used to put down in writing the entry address of each interrupt service subroutine;
For example, the entry address of outside No. 0 interruption subroutine of first data record, the entry address of the 2nd data record timer 0 function, the entry address of the 3rd outside No. 1 interruption subroutine of data record, the entry address of the 4th data record timer 1 function, the 5th data record serial ports interrupts the entry address of SPI function, the entry address of the 6th data record timer 2 function.
In this method, with the entrance function of operating system when the initialization storehouse,? RTX? TASKENT? storehouse is inserted in mission function entry address in the S array, and the entry address that user task is arranged, the entry address of an idle task are arranged in this storehouse more.
For example: the location superlatively of supposing the RAM district of single-chip microcomputer is 0xFF, and the value of SP register is 0x40 when entering main, and one has 4 user tasks, adds an idle task again, moves so after the main function, and storehouse is:
The storehouse synoptic diagram:
The ROM address The value of addressed memory storage
?0XFF Idle task entry address most-significant byte
?0XFE Idle task entry address least-significant byte
?0XFD No. 3 task entry address most-significant bytes
0XFC No. 3 task entry address least-significant bytes
0XFB No. 2 task entry address most-significant bytes
0XFA No. 2 task entry address least-significant bytes
0XF9 No. 1 task entry address most-significant byte
0XF8 No. 1 task entry address least-significant byte
0X43 Maximum spaces of No. 0 task stack,
- lqSPtemp=0XF7
0XF7
0X42 No. 0 task entry address most-significant byte
0X41 No. 0 task entry address least-significant byte
This moment SP=0X42, simultaneously entrance function No. 0 task timer of main initialization is also opened interruption, carries out the RET instruction at last, the entry address of No. 0 task PC register of popping, carries out No. 0 task.
Embodiment six: present embodiment is the further qualification to the implementation method of the multiple task real-time operation system of described a kind of embedding 51 series monolithics of embodiment one to five arbitrary embodiment, present embodiment is that interrupt service routine is described further: in this method, interrupt service routine is adopted the assembly language establishment, can under the prerequisite that realizes function, save size of code.
In this method, in the Interrupt Process process, the process that enters user's interruption subroutine is:
Close and interrupt; Store current interrupt number; Enter user's interrupt service subroutine.
The operating process of described user's interrupt service subroutine is:
Carry out current register pop down and handle, the protection register;
Modification task switching type table unsigned char data lqSwitch Type, current the executing the task of mark is switched by interruption; When withdrawing from this interrupt service subroutine, recover current task and need carry out out stack operation, recover register.
The entry address of system break service routine is pressed into storehouse.Guarantee to carry out this subroutine after interrupt returning.
The entry address of system break service routine is pressed into storehouse, is can continue to carry out this system break service routine in order to ensure system after executing user's interrupt service subroutine.
Described system break service routine is used for: at first check according to interrupt number variable lqIntNum whether current interruption is in interrupt nesting, if be in the interrupt nesting, then carry out by nested interruption; If not being in the interrupt nesting, the switching of then executing the task.Obtain the entry address of active user's interrupt routine, and this address date is pressed in the storehouse;
The process that obtains the entry address of current interruption according to interrupt number variable lqIntNum is:
That is: according to the interruption variable lqIntNum that obtains from interrupting program entry address array unsigned int codelqISREnter[] obtain to interrupt the entry address of clothes subroutine,
Obtain to interrupt the high 3 of variable lqIntNum, low 5 of zero clearing simultaneously adds 1 with described high 3 then, upgrades then to interrupt variable lqIntNum data.High 3 storages of described interruption variable lqIntNum be the interrupt nesting number, whenever enter once and to interrupt, these data add 1, expression has one deck to interrupt, and 7 heavy interrupt nestings can be arranged at most.
Open interruption, return and carry out the user's interruption subroutine that starts.
Carry out end when user's interruption subroutine, the process that withdraws from this user's interruption subroutine is:
Close and interrupt, carry out return command RTEI;
Obtain to interrupt the high 3 of variable lqIntNum,, then subtract 1 described high 3 if described high 3 is not zero; Executive system interrupt service subroutine then; Otherwise higher priority and ready task in the table of executing the task.
When described high 3 when being 0, expression has the task of higher priority to be in ready state, if these high 3 is not 0, robs the CPU control when then representing current interruption from the interruption of low priority, so carry out out stack operation, open the interruption of interrupting and returning low priority.
After user's interrupt service subroutine finishes, beginning executive system interrupt service subroutine.

Claims (10)

1. implementation method that embeds the multiple task real-time operation system of 51 series monolithics, it is characterized in that, it is to adopt based on the C51 programming language editor of keil and adopt the compiling of keil compiler to realize, and adopt the different task of task key word difference, the multitask handoff procedure of this operating system is:
After receiving the new task signal, close to interrupt, initiating task handover module then, this module realizes that the process of switching is:
At first, when the generation task was switched, it judged that at first current moving of task is an idle task, if idle task is not then preserved stack information, otherwise preserved stack information;
Then, judge that current task is the limit priority task, if current task is exactly the limit priority task, then do not do the storehouse adjustment, otherwise do the storehouse adjustment;
At last, after the storehouse adjustment finished, the task of limit priority was set to current task, and observing current task then is idle task, if idle task is just directly returned, just can return then otherwise need judge whether to go out stack operation.
2. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 1 is characterized in that the process of described preservation stack information is:
Step Q1, judge whether current task is idle task, if, execution in step Q2 then, otherwise execution in step Q3;
Step Q2, from the task stack array, load top-of-stack pointer to SP; Execution in step Q4 then;
Step Q3, preservation stack information SP are to task storehouse array.
3. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 1 is characterized in that the process of described storehouse adjustment is:
Step Q4, from task ready list lqRdyTbl, find out the task of the limit priority in the ready list; Execution in step Q5 then;
Step Q5, judge whether the limit priority task in the ready list is current task, if judged result is for being to carry out current task; Otherwise execution in step Q6 carries out the storehouse adjustment;
Step Q6, obtain the stack top location of the limit priority task in the ready list;
Step Q7, judge whether the priority of current task is higher than the priority of the limit priority task in the ready list, if judged result is for being, execution in step Q10 then; Otherwise execution in step Q8;
Step Q8, according to the difference between the stack top address of address that loads stack top in the task stack array and limit priority task, the space length that to move, and the address is located at the bottom of the data of being stored in the storer between the stack top address of the address that loads stack top in the task stack array and the limit priority task in the ready list being transferred to the stack of current task;
Step Q9, according to the difference that loads in address at the bottom of the stack of current task and the task stack array between the stack top address, adjust the task stack stack floors of the ID correspondence of all tasks in the storehouse array, make all tasks the ID correspondence task stack stack floors all the task stack stack floors of the limit priority task ID correspondence in ready list between the task stack stack floors of the ID correspondence of current task; The storehouse adjustment finishes;
Step Q10, according to the difference between the address at the bottom of the stack of the stack top address of the limit priority task in the ready list and current task, obtain mobile space length, and all data in the storer between the address at the bottom of the stack of the stack top address of the limit priority task in ready list and current task are moved to the place, address that loads stack top in the task stack array;
Step Q11, according to the difference that loads in address at the bottom of the stack of current task and the task stack array between the stack top address, adjust the task stack stack floors of the ID correspondence of all tasks in the storehouse array, make all tasks the ID correspondence task stack stack floors all the task stack stack floors of the limit priority task ID correspondence in ready list between the task stack stack floors of the ID correspondence of current task number; The storehouse adjustment finishes.
4. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 1, it is characterized in that, the task of described limit priority is set to current task, observing current task then is idle task, if idle task, just directly return, be otherwise need judge whether to go out the detailed process that stack operation just can return then:
Step Q12, with the task of the limit priority in the ready list as current task;
Step Q13, judge whether current task is idle task, if judged result is for being, execution in step Q16 then; Otherwise execution in step Q14;
Step Q14, judge whether current task is interrupted switching, if judged result is for being, execution in step Q15 then, otherwise execution in step Q16;
Step Q15, task switching type are set to non-interruption switching type, and the execution register goes out stack operation;
Step Q16, open interruption, finish the work and call.
5. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 1 is characterized in that,
Global variable in the described operating system has:
The global data variable that the variable module comprises has: task status table unaigned char data lqTaskState[lqMaxID], task ready list Unsigned char data lqRdyTb1, task switching type table unsigned char data lqSwitch Type, interrupt number unsigned char data lqIntNum, sign amount data unsigned char data lqCtr, semaphore data structure unsinged char data lqSemData[lqSemMax*2], message mailbox data structure unsinged char datalqMsgData[lqMsgMax*2], wherein:
Task status table unaigned char data lqTaskState[lqMaxID] with the bit representation task status of byte, each the bit representation information in the described byte is:
The 7th K_MSG is mailbox event flag position, and this position bit representation current task is being waited for mailbox;
The 6th K_SEM is semaphore event flag position, and this position bit representation current task is in wait-semaphore;
The 5th K_FLG is sign amount event flag position, and this position bit representation current task is being waited for the sign amount;
The 4th K_TMO postpones the waiting event zone bit, and this position bit representation current task is postponing wait;
The 0-3 position is that task is waited for case index number, is used for the call number of logger task waiting event;
The i bit representation i task of task ready list Unsigned char data lqRdyTb1 is in ready state;
The i position bit representation i task of task switching type table unsigned char data lqSwitch Type is switched away by interrupting, otherwise, represent that the i task switched away by the higher priority task;
Interrupt number variable unsigned char data lqIntNum, Senior Three position record interrupt nesting number, low 5 record interrupt types number;
Sign amount data unsigned char data lqCtr, most significant digit represents whether current sign amount is effective, all the other seven tasks of waiting for this sign amount with the form record of position;
Semaphore data structure unsinged char data lqSemData[lqSemMax*2], first byte representation signal quantity of this data structure, second byte waited for the task of the signal quantity correspondence that first byte is represented with the form record of position;
Message mailbox data structure unsinged char data lqMsgData[lqMsgMax*2], the message value of first this mailbox of byte representation in this data structure, the most significant digit of second byte represents whether this mailbox has message, if this position, position, represent that then this mailbox has message, otherwise represent that this mailbox does not have message; Low 7 mission bit streams of waiting for the incident of this mailbox with the form record of position of second byte;
Interrupt routine entry address array unsigned int code lqISREnter[], be used to put down in writing the entry address of each interrupt service subroutine.
6. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 1 is characterized in that, interrupt service routine is adopted the assembly language establishment.
7. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 1 is characterized in that,
In the Interrupt Process process, the process that enters user's interruption subroutine is:
Close and interrupt; Store current interrupt number; Enter user's interrupt service subroutine;
The operating process of described user's interrupt service subroutine is:
Carry out current register pop down and handle, the protection register;
Modification task switching type table unsigned char data lqSwitch Type, current the executing the task of mark is switched by interruption;
When withdrawing from this user's interrupt service subroutine, recover current task and need carry out out stack operation, recover register.
8. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 1 is characterized in that,
Described system break service routine is used for: at first check according to interrupting variable lqIntNum whether current interruption is in interrupt nesting, if in interrupt nesting, then carry out by nested interruption in the source; If not being in the interrupt nesting, the switching of then executing the task.
9. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 7 is characterized in that the detailed process that enters user's interruption subroutine is:
Obtain the entry address of active user's interrupt routine;
And this address date is pressed in the storehouse,
Obtain and interrupt the high 3 of variable lqIntNum, low 5 of zero clearing simultaneously adds 1 with described high 3 then, upgrades then to interrupt variable lqIntNum data;
Open interruption, return and carry out the user's interruption subroutine that starts.
10. the implementation method of the multiple task real-time operation system of a kind of embedding 51 series monolithics according to claim 7 is characterized in that the detailed process that withdraws from user's interrupt service subroutine is:
Close and interrupt, carry out return command RTEI;
Obtain to interrupt the high 3 of variable lqIntNum,, then subtract 1 described high 3 if described high 3 is not zero; Executive system interrupt service subroutine then; Otherwise higher priority and ready task in the table of executing the task.
CN 201110001117 2011-01-06 2011-01-06 Method for implementing multi-task real-time operating system embedded into 51 series singlechip Expired - Fee Related CN102063325B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201110001117 CN102063325B (en) 2011-01-06 2011-01-06 Method for implementing multi-task real-time operating system embedded into 51 series singlechip

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201110001117 CN102063325B (en) 2011-01-06 2011-01-06 Method for implementing multi-task real-time operating system embedded into 51 series singlechip

Publications (2)

Publication Number Publication Date
CN102063325A true CN102063325A (en) 2011-05-18
CN102063325B CN102063325B (en) 2013-04-03

Family

ID=43998611

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201110001117 Expired - Fee Related CN102063325B (en) 2011-01-06 2011-01-06 Method for implementing multi-task real-time operating system embedded into 51 series singlechip

Country Status (1)

Country Link
CN (1) CN102063325B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102945183A (en) * 2012-10-31 2013-02-27 四川长虹电器股份有限公司 Bit flag programming control method for single chip in air conditioner
CN103309734A (en) * 2013-06-24 2013-09-18 哈尔滨工业大学 Embedded task scheduling method based on priority grouping
WO2017157186A1 (en) * 2016-03-16 2017-09-21 阿里巴巴集团控股有限公司 Android-based pop-up prompt method and device
CN107844253A (en) * 2016-09-20 2018-03-27 中兴通讯股份有限公司 Display processing method and device
CN109324885A (en) * 2018-09-13 2019-02-12 厦门拓宝科技有限公司 A kind of multitask management process applied to the monolithic processor controlled minimum operation system of UPS and based on minimum operation system
CN109871274A (en) * 2019-02-27 2019-06-11 西安微电子技术研究所 A kind of the multitask construction and processing method of embedded environment application
CN109947434A (en) * 2018-12-19 2019-06-28 中国兵器装备集团上海电控研究所 Non-interrupted formula and pseudo- parallel embedded software real-time response method, system and medium
CN110737522A (en) * 2019-10-16 2020-01-31 福州物联网开放实验室有限公司 Scheduling method for standby tasks of embedded operating systems
CN113450627A (en) * 2021-06-25 2021-09-28 上海商汤临港智能科技有限公司 Experiment project operation method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040172633A1 (en) * 2003-02-28 2004-09-02 Pizzi Robert Gregory Single stack kernel
CN1851648A (en) * 2006-05-25 2006-10-25 浙江大学 Stack overflow protection method in operation for embedded system
CN101290591A (en) * 2008-06-03 2008-10-22 北京中星微电子有限公司 Embedded operating system task switching method and unit
CN101876923A (en) * 2009-11-27 2010-11-03 中国科学院声学研究所 Method for accurately estimating stack demand in embedded system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040172633A1 (en) * 2003-02-28 2004-09-02 Pizzi Robert Gregory Single stack kernel
CN1851648A (en) * 2006-05-25 2006-10-25 浙江大学 Stack overflow protection method in operation for embedded system
CN101290591A (en) * 2008-06-03 2008-10-22 北京中星微电子有限公司 Embedded operating system task switching method and unit
CN101876923A (en) * 2009-11-27 2010-11-03 中国科学院声学研究所 Method for accurately estimating stack demand in embedded system

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102945183A (en) * 2012-10-31 2013-02-27 四川长虹电器股份有限公司 Bit flag programming control method for single chip in air conditioner
CN102945183B (en) * 2012-10-31 2016-05-11 四川长虹电器股份有限公司 Single-chip microcomputer bit flag programmable control method in air-conditioner
CN103309734A (en) * 2013-06-24 2013-09-18 哈尔滨工业大学 Embedded task scheduling method based on priority grouping
US10678564B2 (en) 2016-03-16 2020-06-09 Alibaba Group Holding Limited Android-based pop-up prompt method and device
WO2017157186A1 (en) * 2016-03-16 2017-09-21 阿里巴巴集团控股有限公司 Android-based pop-up prompt method and device
US10853102B2 (en) 2016-03-16 2020-12-01 Advanced New Technologies Co., Ltd. Android-based pop-up prompt method and device
CN107844253A (en) * 2016-09-20 2018-03-27 中兴通讯股份有限公司 Display processing method and device
CN109324885A (en) * 2018-09-13 2019-02-12 厦门拓宝科技有限公司 A kind of multitask management process applied to the monolithic processor controlled minimum operation system of UPS and based on minimum operation system
CN109947434A (en) * 2018-12-19 2019-06-28 中国兵器装备集团上海电控研究所 Non-interrupted formula and pseudo- parallel embedded software real-time response method, system and medium
CN109871274A (en) * 2019-02-27 2019-06-11 西安微电子技术研究所 A kind of the multitask construction and processing method of embedded environment application
CN109871274B (en) * 2019-02-27 2022-12-13 西安微电子技术研究所 Multitask construction and processing method for embedded environment application
CN110737522A (en) * 2019-10-16 2020-01-31 福州物联网开放实验室有限公司 Scheduling method for standby tasks of embedded operating systems
CN110737522B (en) * 2019-10-16 2023-03-03 福州物联网开放实验室有限公司 Standby task scheduling method of embedded operating system
CN113450627A (en) * 2021-06-25 2021-09-28 上海商汤临港智能科技有限公司 Experiment project operation method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN102063325B (en) 2013-04-03

Similar Documents

Publication Publication Date Title
CN102063325B (en) Method for implementing multi-task real-time operating system embedded into 51 series singlechip
KR101057452B1 (en) Smart card embedded operation system and work processing method
CN104915256B (en) A kind of the Real-Time Scheduling implementation method and its system of task
CN103473129B (en) Multi-task queue scheduling system with scalable number of threads and implementation method thereof
CN104899089A (en) Task scheduling method in heterogeneous multi-core architecture
CN105144100A (en) Programmable CPU register hardware context swap mechanism
CN101310257A (en) Multi-processor system and program for causing computer to execute multi-processor system control method
CN103959268A (en) Peripheral communication
CN103473138A (en) Multi-tasking queue scheduling method based on thread pool
CN201716564U (en) Processor architecture special for high-performance programmable logic controller (PLC)
CN102325255A (en) Multi-core CPU (central processing unit) video transcoding scheduling method and multi-core CPU video transcoding scheduling system
CN106663072A (en) Apparatus and method for configuring sets of interrupts
CN102323895A (en) Real-time scheduling method of embedded operating system based on STB (Set Top Box)
US10949243B2 (en) Reducing IPI overhead with CPU overcommit support via IPI broadcast
CN101310241A (en) Method and apparatus for sharing memory in a multiprocessor system
CN102799461A (en) Execution method and device of application, and electronic equipment
CN102214085A (en) Microcomputer and interrupt control method
CN102087609A (en) Dynamic binary translation method under multi-processor platform
CN101819539A (en) Interrupt nesting method for transplanting muCOS-II to ARM7
CN105094973A (en) ADA program partition running supporting system based on sensitive instruction substitution
CN104978174A (en) Method and system for switching network cards in plurality of operating systems
CN102681941A (en) Extensible embedded simulation test system
CN104484202B (en) Suitable for the in-orbit re-injection method of space flight embedded software of 8051 microcontrollers
CN101526904B (en) Switching method for realizing normal and time limited startup of computers based on system BIOS
CN103309734A (en) Embedded task scheduling method based on priority grouping

Legal Events

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

Granted publication date: 20130403

Termination date: 20140106