add time test into kernel/task.md

This commit is contained in:
Yan_yan 2020-11-10 17:22:49 +08:00
parent e46df58f68
commit f46e3577eb
11 changed files with 158 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -10,6 +10,10 @@
* [信号量](#sem)
* [互斥量](#mutex)
* [事件集](#event)
* [任务切换时间测试](#time_test)
* [概述](#time_test_intro)
* [基于 ARM 处理器的任务切换时间测试](#time_test_arm)
* [基于 RISC-V 处理器的任务切换时间测试](#time_test_riscv)
* [使用场景](#situation)
<span id="management"></span>
@ -533,6 +537,160 @@ xs_int32 xs_UserEventReinit(xs_uint16 id);
| 参数 | 描述 |
| --- | --- |
| id | 来源消息队列ID |
<span id="time_test"></span>
## 任务切换时间测试
<span id="time_test_intro"></span>
### 概述
下面分别测试XiUOS系统运行在基于ARM和RISC-V不同处理器的开发板时任务的切换时间。
<span id="time_test_arm"></span>
### 基于 ARM 处理器的任务切换时间测试
#### 测试方法
为了测试系统的任务切换时间考虑使用GPIO管脚进行测试将GPIO在任务切换开始和结束时分别置为高电平和低电平。
* 配置C13管脚为输出模式接示波器通道1或2
* 示波器GND和开发板GND共地对接
<center>
![RISCV TEST CONNECT](./imagesrc/arm_test.png)
</center>
XiUOS的任务切换函数为xs_SwitchKthreadContext在SwitchKthreadContext函数入口位置将C13管脚置为高电平出口位置置为低电平则C13管脚保持高电平的时间即切换时间。
#### 编程代码清单
<center>
![RISCV TEST CONNECT](./imagesrc/arm_test_code.png)
</center>
因为测试单板为cortex-m4单板该系列单板的线程切换是基于pendSV CPU异常进行线程切换因此下面基于该特点区分测试场景
* 测量pendSV异常切换 在SwitchKthreadContext函数入口处将C13管脚置为高电平在pendSV异常处理过程保存现场之后切换到目标任务之前将C13管脚置为低电平。得出的管脚电平时间即为带pendSV异常的的任务切换时间。
* 只测了SwitchKthreadContext在SwitchKthreadContext函数入口处将C13管脚置为高电平在出口位置将C13管脚置为低电平。得出的管脚电平时间即为不计算pendSV异常的的任务切换时间。
<center>
![RISCV TEST CONNECT](./imagesrc/arm_test_switch.png)
</center>
<center>
![RISCV TEST CONNECT](./imagesrc/arm_test_switch1.png)
</center>
#### 示波器测试选项设置
* 通道设置
* 耦合:直流
* 带宽限制:关闭
* 伏/格:粗调
* 探头10X 电压
* 反相:关闭
* 触发设置
* 类型:边沿
* 信源: CH1
* 斜率:上升
* 模式:自动
* 触发电压:略低于最高电平即可
* 测量设置
* 测量选通:开启
* 类型:时间
* 信源CH1
* Scale500ns
#### 测试结果
<center>
![RISCV TEST CONNECT](./imagesrc/arm_test_result.png)
</center>
从示波器测试结果上来看单独测试SwitchKthreadContext的执行时间是1.26us。
<center>
![RISCV TEST CONNECT](./imagesrc/arm_test_result1.png)
</center>
从示波器测试结果上来看测试SwitchKthreadContext加上pendSV异常的的执行时间是17us。
<span id="time_test_riscv"></span>
### 基于 RISC-V 处理器的任务切换时间测试
#### 测试方法
为了测试系统的任务切换时间考虑使用GPIO管脚进行测试将GPIO在任务切换开始和结束时分别置为高电平和低电平。
* 配置GPIO18管脚为输出模式接示波器通道1或2
* 示波器GND和开发板GND共地对接
<center>
![RISCV TEST CONNECT](./imagesrc/riscv-test.png)
</center>
XiUOS的任务切换函数为xs_SwitchKthreadContext在SwitchKthreadContext函数入口位置将GPIO18管脚置为高电平出口位置置为低电平;则GPIO18管脚保持高电平的时间即切换时间。
#### 编程代码清单
<center>
![RISCV TEST CONNECT](./imagesrc/riscv_test_code.png)
</center>
初始化GPIO18为输出模式并初始化为低电平在while1当中调用delay函数每隔1个时间片发生一次调度。在下面的switch函数入口和出口位置操作GPIO。
<center>
![RISCV TEST CONNECT](./imagesrc/riscv_test_switch.png)
</center>
### 示波器测试选项设置
* 通道设置
* 耦合:直流
* 带宽限制:关闭
* 伏/格:粗调
* 探头10X 电压
* 反相:关闭
* 触发设置
* 类型:边沿
* 信源: CH1
* 斜率:上升
* 模式:自动
* 触发电压:略低于最高电平即可
* 测量设置
* 测量选通:开启
* 类型:时间
* 信源CH1
* Scale250ns
### 测试结果
<center>
![RISCV TEST CONNECT](./imagesrc/riscv_test_result.png)
</center>
从示波器测试结果上来看测试SwitchKthreadContext的执行时间是160ns.
<span id="situation"></span>
## 使用场景