|
楼主 |
发表于 2017-3-12 15:24:30
|
显示全部楼层
官网的介绍如下
What is the context switch time?
Context switch times are dependent on the port, compiler and configuration. A context switch time of 84 CPU cycles was obtained under the following test conditions:
FreeRTOS ARM Cortex-M3 port for the Keil compiler
Stack overflow checking turned off
Trace features turned off
Run-time stats feature turned off
Compiler set to optimise for speed
configUSE_PORT_OPTIMISED_TASK_SELECTION set to 1 in FreeRTOSConfig.h
Notes:
Under these test conditions the context switch time is not not dependent on whether a different task was selected to run or the same task was selected to continue running.
The ARM Cortex-M port performs all task context switches in the PendSV interrupt. The quoted time does not include interrupt entry time.
The quoted time includes a short section of C code. It has been determined that 12 CPU cycles could have been saved by providing the entire implementation in assembly code. It is considered that the benefit of maintaining a short section of generic C code (for reasons of maintenance, support, robustness, automatic inclusion of features such as tracing, etc.) outweighs the benefit of removing 12 CPU cycles from the context switch time.
The Cortex-M CPU registers that are not automatically saved on interrupt entry can be saved with a single assembly instruction, then restored again with a further single assembly instruction. These two instructions on their own consume 12 CPU cycles. |
|