CN104679585A - Floating-point context switching method - Google Patents
Floating-point context switching method Download PDFInfo
- Publication number
- CN104679585A CN104679585A CN201310637429.7A CN201310637429A CN104679585A CN 104679585 A CN104679585 A CN 104679585A CN 201310637429 A CN201310637429 A CN 201310637429A CN 104679585 A CN104679585 A CN 104679585A
- Authority
- CN
- China
- Prior art keywords
- floating
- task
- point
- context
- fpcontext
- 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
Links
Abstract
The invention relates to a floating-point context switching method. The method comprises the steps: 1) building a task: the task comprises a proceeding task and a successive task, wherein the proceeding task is a task switched out of a processor, and the successive task is a task switched in the processor; 2) judging whether the task built in the step 1) is a floating point task according to parameters input by a user; if the task is the floating point task, applying a floating point context space and recording a first address of the space in a member fpContext in a task control block; if the task is not the floating point task, setting a member fpContext to be NULL in the task control block; 3) judging the types of the proceeding task and the successive task; and 4) switching the floating point context according to the types of the proceeding task and the successive task. According to the floating-point context switching method provided by the invention, the task switching performance can be improved.
Description
Technical field
The invention belongs to computer software control field, relate to a kind of floating-point contextual processing method.
Background technology
In Airborne Embedded Real-time Operating System, user usually need floating-point task and non-floating-point task with the use of, if but operating system all switches the floating-point context that each task is equal, can cause a large amount of system overheads, influential system performance, need to propose new floating-point task and non-floating-point target switching method, under hybrid task environment, the efficient switching of task provides possibility.
Summary of the invention
Mixing the problem of scheduling in order to solve the floating-point task that exists in background technology and non-floating-point task, the invention provides a kind of floating-point contextual processing method improving the performance of task switch.
Technical solution of the present invention is: the invention provides a kind of floating-point contextual processing method, its special character is: described floating-point contextual processing method comprises the following steps:
1) creation task; Business and subsequent tasks is taken over sb.'s job before described task comprises; Taking over sb.'s job business before described is the task of being switched out processor; Described subsequent tasks switches the task into processor;
2) according to user input parameter determining step 1) in create task whether be floating-point task; If so, apply for floating-point context space and the first address in this space be recorded in the member fpContext in task control block (TCB); If not, then the member fpContext arranged in task control block (TCB) is NULL;
3) type of business and subsequent tasks is taken over sb.'s job before judging;
4) according to the type of front taking over sb.'s job business and subsequent tasks, floating-point context is switched.
Above-mentioned steps 3) in before take over sb.'s job business and the type of subsequent tasks comprises: floating-point task switch is to floating-point task, floating-point task switch to non-floating-point task, non-floating-point task switch to floating-point task and non-floating-point task switch to non-floating-point task.
Above-mentioned steps 3) in type be floating-point task switch to floating-point task time, the specific implementation of described step 4) is: carry out Save and restore to the context of floating-point task.
Above-mentioned steps 3) in type be floating-point task switch to non-floating-point task time, the specific implementation of described step 4) is: temporarily do not carry out the contextual preservation of floating-point, the member fpContext front continued in task control block (TCB) is passed to subsequent tasks, only give non-floating some task by the floating-point context address transmission of floating-point task, this preservation work is postponed till when switching floating-point task and just carry out.
Above-mentioned steps 4) in the member fpContext front in task control block (TCB) passed to subsequent tasks specific implementation be after the member fpContext front in task control block (TCB) is marked assignment to the member fpContext in subsequent tasks controll block.
Above-mentioned steps 3) in type be non-floating-point task switch to floating-point task time, the specific implementation of described step 4) is:
4.1) whether the member fpContext continued in task control block (TCB) before judging is NULL; If so, then carry out step 4.2); If not, then carry out step 4.3);
4.2) before this task run, do not run floating-point task: do not need to carry out the contextual preservation work of floating-point, and only needed to recover floating-point context;
4.3) before this task run, floating-point task was run: if the floating-point context of taking over sb.'s job the floating-point context of business and subsequent tasks front is inconsistent, in the context address that the task control block (TCB) that continues before being then saved in by floating-point context transmits, and the mark continued in task control block (TCB) before removing, recover the floating-point context of subsequent tasks, otherwise take over sb.'s job the floating-point context of business before removing.
Above-mentioned steps 3) in type be non-floating-point task switch to non-floating-point task time, the specific implementation of described step 4) is:
4.1) whether the member fpContext continued in task control block (TCB) before judging is NULL; If so, then carry out step 4.2); If not, then carry out step 4.3);
4.2) before this task run, floating-point task was not run; Neither need to carry out the preservation of floating-point context also not need to carry out the recovery of floating-point context;
4.3) before this task run, run floating-point task, will front take over sb.'s job the floating-point context transfer of business to subsequent tasks.
Above-mentioned steps 4.3) in be the member fpContext value of the member fpContext front continued in task control block (TCB) is assigned in subsequent tasks controll block by the specific implementation of the floating-point context transfer to subsequent tasks of front taking over sb.'s job business, the fpContext continued in task control block (TCB) before then removing.
Advantage of the present invention is:
The present invention only switches when needs switch floating-point context, namely only just switches floating-point context when switching floating-point task.If what be switched exactly specifically is non-floating-point task, so think and can not destroy floating-point context in this task, namely do not need to preserve floating-point context, until just carry out floating-point contextual Save and restore work when being switched to floating-point task, effectively raise the performance that operating system task switches.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of method provided by the present invention.
Embodiment
When task creation, judge the parameter that user inputs, if floating-point task, so apply for floating-point context space and the first address in this space be recorded in the member fpContext in task control block (TCB); Otherwise arranging this member is NULL.
When task switch (task that title is switched out processor takes over sb.'s job business before being, claims to switch task into processor for being subsequent tasks), following four kinds of situations may be there are:
1, floating-point task switch is to floating-point task:
In this case, because two tasks all can carry out floating-point operation, so need Save and restore floating-point context.
2, floating-point task switch is to non-floating-point task:
In this case, because subsequent tasks can not carry out floating-point operation, so temporarily context can not preserved.
3, non-floating-point task switch is to floating-point task:
In this case, due to subsequent tasks can carry out floating-point operation but before take over sb.'s job business and do not carry out floating-point operation, so need to recover context.
4, non-floating-point task switch is to non-floating-point task:
In this case, because two tasks all can not carry out floating-point operation, so do not need Save and restore context.
Different treatment measures are taked respectively according to above four kinds of situations:
1, floating-point task switch is to floating-point task
In this case, floating-point context Save and restore is carried out.
2, floating-point task switch is to non-floating-point task
In this case, temporarily do not carry out the contextual preservation work of floating-point, but the member fpContext front continued in task control block (TCB) is passed to subsequent tasks, after marking by the member fpContext front in task control block (TCB), assignment is to the member fpContext in subsequent tasks controll block.Now, system does not need to carry out the contextual preservation work of floating-point, only gives non-floating some task by the floating-point context address transmission of floating-point task, this preservation work is postponed till when switching floating-point task and just carries out.
3, non-floating-point task switch is to floating-point task
Also need in this case to divide into two kinds of situations:
3.1) the front member fpContext continued in task control block (TCB) is NULL, namely before this task run, do not run floating-point task: in this case, and do not need to carry out the contextual preservation work of floating-point, only need to recover floating-point context.
3.2) the front member fpContext continued in task control block (TCB) is not NULL, namely before this task run, floating-point task was run: in this case, the floating-point context of taking over sb.'s job the floating-point context of business and subsequent tasks if front is inconsistent, in the context address that the task control block (TCB) that continues before being then saved in by floating-point context transmits, and the mark continued in task control block (TCB) before removing, then recover the floating-point context of subsequent tasks, otherwise take over sb.'s job the floating-point context of business before removing.
4, non-floating-point task switch is to non-floating-point task
Also need in this case to divide into two kinds of situations:
4.1) the front member fpContext continued in task control block (TCB) is NULL, namely before this task run, does not run floating-point task:
In this case, neither need to carry out the preservation of floating-point context also not need to carry out the recovery of floating-point context.
4.2) the front member fpContext continued in task control block (TCB) is not NULL, namely before this task run, runs floating-point task:
In this case, the value of the member fpContext front continued in task control block (TCB) is assigned to the member fpContext in subsequent tasks controll block, then the fpContext continued in task control block (TCB) before removing, by front taking over sb.'s job the floating-point context transfer of business to subsequent tasks.
Use this method floating-point task and non-floating-point task mixed scheduling example, as shown in Figure 1:
1) floating-point task A is switched to non-floating-point task B, is assigned to the fpContext member of task B after the value of the fpContext member of task A is increased mark.
2) non-floating-point task B is switched to floating-point task C, the memory headroom that fpContext members content in flating point register being saved in task B points to, then the fpContext member of task B is set to NULL, the floating-point context of task C is returned in flating point register.
3) floating-point task C is switched to non-floating-point task B, is assigned to the fpContext member of task B after the value of the fpContext member of task C is increased mark.
4) non-floating-point task B is switched to non-floating-point task D, the fpContext member of task B is assigned to the fpContext member of task D, then the fpContext member of task B is set to NULL.
5) non-floating-point task D is switched to floating-point task C, due to the fpContext member of task D and the fpContext member of task C consistent, so do not need to switch floating-point context, only the fpContext member of task D is set to NULL.
5 subtasks occur altogether switch, but floating-point contextual processing only occurs 1 time, improves the performance of task switch.
Claims (8)
1. a floating-point contextual processing method, is characterized in that: described floating-point contextual processing method comprises the following steps:
1) creation task; Business and subsequent tasks is taken over sb.'s job before described task comprises; Taking over sb.'s job business before described is the task of being switched out processor; Described subsequent tasks switches the task into processor;
2) according to user input parameter determining step 1) in create task whether be floating-point task; If so, apply for floating-point context space and the first address in this space be recorded in the member fpContext in task control block (TCB); If not, then the member fpContext arranged in task control block (TCB) is NULL;
3) type of business and subsequent tasks is taken over sb.'s job before judging;
4) according to the type of front taking over sb.'s job business and subsequent tasks, floating-point context is switched.
2. floating-point contextual processing method according to claim 1, is characterized in that: take over sb.'s job business before in described step 3) and the type of subsequent tasks comprises: floating-point task switch is to floating-point task, floating-point task switch to non-floating-point task, non-floating-point task switch to floating-point task and non-floating-point task switch to non-floating-point task.
3. floating-point contextual processing method according to claim 2, it is characterized in that: the type in described step 3) be floating-point task switch to floating-point task time, the specific implementation of described step 4) is: carry out Save and restore to the context of floating-point task.
4. floating-point contextual processing method according to claim 2, it is characterized in that: the type in described step 3) be floating-point task switch to non-floating-point task time, the specific implementation of described step 4) is: temporarily do not carry out the contextual preservation of floating-point, the member fpContext front continued in task control block (TCB) is passed to subsequent tasks, only give non-floating some task by the floating-point context address transmission of floating-point task, this preservation work is postponed till when switching floating-point task and just carry out.
5. floating-point contextual processing method according to claim 4, is characterized in that: the specific implementation in described step 4), the member fpContext front in task control block (TCB) being passed to subsequent tasks be after the member fpContext front in task control block (TCB) is marked assignment to the member fpContext in subsequent tasks controll block.
6. floating-point contextual processing method according to claim 2, is characterized in that: the type in described step 3) be non-floating-point task switch to floating-point task time, the specific implementation of described step 4) is:
4.1) whether the member fpContext continued in task control block (TCB) before judging is NULL; If so, then carry out step 4.2); If not, then carry out step 4.3);
4.2) before this task run, do not run floating-point task: do not need to carry out the contextual preservation work of floating-point, and only needed to recover floating-point context;
4.3) before this task run, floating-point task was run: if the floating-point context of taking over sb.'s job the floating-point context of business and subsequent tasks front is inconsistent, in the context address that the task control block (TCB) that continues before being then saved in by floating-point context transmits, and the mark continued in task control block (TCB) before removing, recover the floating-point context of subsequent tasks, otherwise take over sb.'s job the floating-point context of business before removing.
7. floating-point contextual processing method according to claim 2, is characterized in that: the type in described step 3) be non-floating-point task switch to non-floating-point task time, the specific implementation of described step 4) is:
4.1) whether the member fpContext continued in task control block (TCB) before judging is NULL; If so, then carry out step 4.2); If not, then carry out step 4.3);
4.2) before this task run, floating-point task was not run; Neither need to carry out the preservation of floating-point context also not need to carry out the recovery of floating-point context;
4.3) before this task run, run floating-point task, will front take over sb.'s job the floating-point context transfer of business to subsequent tasks.
8. floating-point contextual processing method according to claim 7, it is characterized in that: described step 4.3) in be the member fpContext value of the member fpContext front continued in task control block (TCB) is assigned in subsequent tasks controll block by the specific implementation of the floating-point context transfer to subsequent tasks of front taking over sb.'s job business, the fpContext continued in task control block (TCB) before then removing.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310637429.7A CN104679585B (en) | 2013-11-28 | 2013-11-28 | Floating-point context switching method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310637429.7A CN104679585B (en) | 2013-11-28 | 2013-11-28 | Floating-point context switching method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104679585A true CN104679585A (en) | 2015-06-03 |
CN104679585B CN104679585B (en) | 2017-10-24 |
Family
ID=53314679
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310637429.7A Active CN104679585B (en) | 2013-11-28 | 2013-11-28 | Floating-point context switching method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104679585B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112395005A (en) * | 2019-08-19 | 2021-02-23 | 无锡江南计算技术研究所 | Performance optimization method for floating point SIMD context switching |
CN112799792A (en) * | 2021-02-01 | 2021-05-14 | 安徽芯纪元科技有限公司 | Method for protecting task context register of embedded operating system |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1177147A (en) * | 1996-08-19 | 1998-03-25 | 三星电子株式会社 | System and method for handling software interrupts with argument passing |
US20030204639A1 (en) * | 2002-04-30 | 2003-10-30 | David Lake | Task dispatch in priority pre-emptive real-time operating systems |
US20060026398A1 (en) * | 2004-07-27 | 2006-02-02 | Texas Instruments Incorporated | Unpack instruction |
US20100325397A1 (en) * | 2009-06-19 | 2010-12-23 | Arm Limited | Data processing apparatus and method |
CN103092772A (en) * | 2011-08-18 | 2013-05-08 | 国际商业机器公司 | Vector register file caching of context data structure for maintaining state data in multithreaded image processing pipeline |
CN103116539A (en) * | 2012-02-15 | 2013-05-22 | 无锡江南计算技术研究所 | Performance loss testing method and device of fine-grained virtual system |
-
2013
- 2013-11-28 CN CN201310637429.7A patent/CN104679585B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1177147A (en) * | 1996-08-19 | 1998-03-25 | 三星电子株式会社 | System and method for handling software interrupts with argument passing |
US20030204639A1 (en) * | 2002-04-30 | 2003-10-30 | David Lake | Task dispatch in priority pre-emptive real-time operating systems |
US20060026398A1 (en) * | 2004-07-27 | 2006-02-02 | Texas Instruments Incorporated | Unpack instruction |
US20100325397A1 (en) * | 2009-06-19 | 2010-12-23 | Arm Limited | Data processing apparatus and method |
CN103092772A (en) * | 2011-08-18 | 2013-05-08 | 国际商业机器公司 | Vector register file caching of context data structure for maintaining state data in multithreaded image processing pipeline |
CN103116539A (en) * | 2012-02-15 | 2013-05-22 | 无锡江南计算技术研究所 | Performance loss testing method and device of fine-grained virtual system |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112395005A (en) * | 2019-08-19 | 2021-02-23 | 无锡江南计算技术研究所 | Performance optimization method for floating point SIMD context switching |
CN112395005B (en) * | 2019-08-19 | 2022-07-12 | 无锡江南计算技术研究所 | Performance optimization method for floating point SIMD context switching |
CN112799792A (en) * | 2021-02-01 | 2021-05-14 | 安徽芯纪元科技有限公司 | Method for protecting task context register of embedded operating system |
CN112799792B (en) * | 2021-02-01 | 2023-12-05 | 安徽芯纪元科技有限公司 | Task context register protection method of embedded operating system |
Also Published As
Publication number | Publication date |
---|---|
CN104679585B (en) | 2017-10-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2018099299A1 (en) | Graphic data processing method, device and system | |
CN102110015B (en) | Method and device for determining task progress and task processing time | |
EP3306470B1 (en) | Method and apparatus for executing non-maskable interrupt | |
CN103514038A (en) | Method and system for smoothly shutting down virtual system | |
JP2013093053A5 (en) | ||
CN109885406B (en) | Operator calculation optimization method, device, equipment and storage medium | |
MX2016002563A (en) | Method and device for controlling power consumption. | |
CN106462451A (en) | Interruption handling method and relevant device of virtual platform | |
CN104881316A (en) | Virtual machine transferring method and device | |
WO2009057208A1 (en) | Resource assignment program, management node, resource assignment method, and parallel computer system | |
CN104424037A (en) | Method and device for dynamically patching function | |
CN103076867A (en) | Cloud terminal processing method and system with function of identifying action of power key | |
CN104915254A (en) | Embedded system multi-task scheduling method and system | |
CN104679585A (en) | Floating-point context switching method | |
CN105528253A (en) | A running water form communication parallel method for a heterogeneous many-core system | |
CN106598508A (en) | Solid-state hard disc and write-in arbitrating method and system thereof | |
CN102411519A (en) | Process restoring method and device | |
CN103617060A (en) | Method for accelerating starting procedure of embedded software by using super state storage | |
CN106683033B (en) | Out-of-order OpenGL interface processing method | |
CN103019813B (en) | Method for obtaining interactive strength of SaaS-based interactive program | |
CN104679584A (en) | Method for switching vector context | |
CN101980170B (en) | Communication method, system and device for software module in microkernel system | |
CN104809686A (en) | Picture and text watermark batch processing method | |
WO2019126797A3 (en) | System and method for executing instructions | |
CN104965749A (en) | Kernel-based virtual machine (kvm) snapshot recovery optimization method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |