目录
- 关键词
- 平台说明
- 一、显式(Explicit)和隐式(Implicit)
- 1.1 显式模式
- 1.1.1code
- 二、隐式模式
- 2.1 code
- 三、区别
关键词
嵌入式、C语言、autosar、EcuM、Rte
平台说明
项目 | Value |
---|---|
OS | autosar OS |
autosar厂商 | vector |
芯片厂商 | TI |
编程语言 | C,C++ |
编译器 | HighTec (GCC) |
一、显式(Explicit)和隐式(Implicit)
创建两种不同类型的port
1.1 显式模式
1.1.1code
TASK(OsTask_10ms) /* PRQA S 3408, 1503 */ /* MD_Rte_3408, MD_MSR_Unreachable */
{/* call runnable */Runnable11(); /* PRQA S 2987 */ /* MD_Rte_2987 */(void)TerminateTask(); /* PRQA S 3417 */ /* MD_Rte_Os */
} /* PRQA S 6010, 6030, 6050, 6080 */ /* MD_MSR_STPTH, MD_MSR_STCYC, MD_MSR_STCAL, MD_MSR_STMIF */
读写均为操作中间变量,在runnable运行中可以被其他地方赋值改变此中间变量。
# define Rte_Write_AsrTest_Send_Explicit_test1 Rte_Write_CpApServer_AsrTest_Send_Explicit_test1
# define Rte_Write_CpApServer_AsrTest_Send_Explicit_test1(data) (Rte_CtApsever_AsrTest_Send_Explicit_test1 = (data), ((Std_ReturnType)RTE_E_OK))
# define Rte_Write_AsrTest_Send_Explicit_test2 Rte_Write_CpApServer_AsrTest_Send_Explicit_test2
# define Rte_Write_CpApServer_AsrTest_Send_Explicit_test2(data) (Rte_CtApsever_AsrTest_Send_Explicit_test2 = (data), ((Std_ReturnType)RTE_E_OK))
二、隐式模式
2.1 code
TASK(Appl_Task_10ms_OsCore3) /* PRQA S 3408, 1503 */ /* MD_Rte_3408, MD_MSR_Unreachable */
{EventMaskType ev;for(;;){(void)WaitEvent(Rte_Ev_Cyclic2_Appl_Task_10ms_OsCore3_0_20ms | Rte_Ev_Cyclic_Appl_Task_10ms_OsCore3_0_10ms | Rte_Ev_Cyclic_Appl_Task_10ms_OsCore3_0_20ms | Rte_Ev_Cyclic_Appl_Task_10ms_OsCore3_0_40ms); /* PRQA S 3417 */ /* MD_Rte_Os */(void)GetEvent(Appl_Task_10ms_OsCore3, &ev); /* PRQA S 3417 */ /* MD_Rte_Os */(void)ClearEvent(ev & (Rte_Ev_Cyclic2_Appl_Task_10ms_OsCore3_0_20ms | Rte_Ev_Cyclic_Appl_Task_10ms_OsCore3_0_10ms | Rte_Ev_Cyclic_Appl_Task_10ms_OsCore3_0_20ms | Rte_Ev_Cyclic_Appl_Task_10ms_OsCore3_0_40ms)); /* PRQA S 3417 */ /* MD_Rte_Os */if ((ev & Rte_Ev_Cyclic_Appl_Task_10ms_OsCore3_0_10ms) != (EventMaskType)0){/* START PRE RUNNABLE Appl_Runnable10ms_core0 *//* read implicit data */*(&Rte_Appl_Task_10ms_OsCore3.Rte_RB.Rte_CtAp_Demo_Core0_Appl_Runnable10ms_core0.Rte_AsrTest_recive_Implicit_test1.value) = Rte_CtApsever_AsrTest_Send_Implicit_test1; /* PRQA S 1339, 2982 */ /* MD_Rte_1339, MD_Rte_2982 */*(&Rte_Appl_Task_10ms_OsCore3.Rte_RB.Rte_CtAp_Demo_Core0_Appl_Runnable10ms_core0.Rte_AsrTest_recive_Implicit_test2.value) = Rte_CtApsever_AsrTest_Send_Implicit_test2; /* PRQA S 1339, 2982 */ /* MD_Rte_1339, MD_Rte_2982 *//* STOP PRE RUNNABLE Appl_Runnable10ms_core0 *//* call runnable */Runnabletest_server(); /* PRQA S 2987 */ /* MD_Rte_2987 */(); /* PRQA S 2987 */ /* MD_Rte_2987 */}
}
在调用runnabl之前就把值从地址中直接取出,在runnable当前运行完毕之前不会被重新赋值。
三、区别
1.运行效率:因为显式会比隐式多一次拷贝操作,因此在效率上显示<隐式
2.读写一致性:因为显示在runnable运行途中值会被随时改变,因此在读写一致性上显示<隐式
3.实时性:参考第二条,在实时性上显示>隐式