基于r-Kernel的LiteOS操作系统

LiteOS是应用于资源受限的传感网络的一种基于线程的类UNIX操作系统。也就是说它跑在存储空间和RAM有限的超低电压微控制器上,这也是吸引我关注它的原因(在超低电压下系统更易出错)。它採用r-kernel内核,r-kernel有三个特征:


1)为线程创建checkpoint。能够在出错时进行rollback。以下是用r-kernel给出的API写出的演示样例程序:

checkpointIndex = createCheckPoint();
printf("Point A,");
rollbackCheckpoint(checkpointIndex);
printf("Point B,");

程序会一直输出Point A。它将断点存在了Flash中。这是由于RAM是嵌入式设备上最受限的资源。

这个特征用来解决那些能够通过又一次运行来消除的错误。如竞态条件和死锁。但对于确定的错误,要通过以下这个特征来解决。


2)让一些系统调用拥有影子考虑以下的程序:

char *buffer = malloc(100);
/*some more code here*/
buffer[100] = 1;

显然存在Dynamic memory overrun,一旦buffer[100]的内存地址分配给了还有一个线程。就会出现错误。事实上malloc是通过系统调用来与内核打交道的,假设我们能将这些系统调用的实现进行改动。如malloc是连续分配内存块,但我们将之改动为每两个内存块之间增添固定大小的空间,这样便在一定程度上解决上述问题(这要取决于添加空间的大小)。

这就是所谓的影子(system call shadowing)。




3)watchdog是最后的防线。如内核陷入死锁,不能定期地进行喂狗。watchdog便会进行reboot。但为了防止一次重新由于同一个bug重新启动的尴尬。一种叫past-run race reconstruction的方法用来推断是哪一个线程造成了重新启动,这样下一次它就被禁止运行。为此我们须要将重新启动前的状态记录下来(存在EEPROM或on-board Flash),之后内核会通过这些信息找出重新启动前最后一个在执行的用户线程,它一般就为错误线程,临时丢弃它。


注:翻译来源 IEEE INFOCOM 2011论文

Qing Cao, Xiaorui Wang, Hairong Qi and Tian He, r-Kernel: An Operating System Foundation for Highly Reliable Networked Embedded Systems

恒玄开发版适配libmodbus报错[OHOS ERROR] [44/124] gcc cross compiler obj/third_party/libmodbus/src/libmodbus_static.modbus-rtu.o [OHOS ERROR] FAILED: obj/third_party/libmodbus/src/libmodbus_static.modbus-rtu.o [OHOS ERROR] ccache arm-none-eabi-gcc -D_XOPEN_SOURCE=700 -DOHOS_DEBUG -D__LITEOS__ -D__LITEOS_M__ -DSECUREC_IN_KERNEL=0 -D_BSD_SOURCE=1 -I../../../third_party/libmodbus -I../../../third_party/libmodbus/src -I../../../device/soc/bestechnic/aos_bsp/include/rtos/liteos/liteos_m/kal/cmsis -I../../../device/soc/bestechnic/aos_bsp/rtos/liteos/liteos_m -I../../../device/soc/bestechnic/aos_bsp/platform/hal -I../../../commonlibrary/utils_lite/include -I../../../base/iothardware/peripheral/interfaces/inner_api -I../../../kernel/liteos_m/arch/arm/common -I../../../kernel/liteos_m/arch/arm/cortex-m33/gcc/NTZ -I../../../kernel/liteos_m/arch/arm/include -I../../../kernel/liteos_m/arch/include -I../../../kernel/liteos_m/kernel/include -I../../../kernel/liteos_m/kal/libc/newlib/porting/include -I../../../third_party/bounds_checking_function/include -I../../../kernel/liteos_m/kal/posix/include -I../../../kernel/liteos_m/components/backtrace -I../../../kernel/liteos_m/components/cpup -I../../../kernel/liteos_m/components/exchook -I../../../kernel/liteos_m/components/fs/vfs -I../../../third_party/littlefs -I../../../third_party/littlefs/bd -I../../../kernel/liteos_m/components/fs/littlefs -I../../../device/soc/bestechnic/bes2600/liteos_m/components/net/lwip-2.1/porting/include -I../../../kernel/liteos_m/components/net/lwip-2.1/porting/include -I../../../third_party/lwip/src/include -I../../../kernel/liteos_m/components/power -I../../../kernel/liteos_m/components/signal -I../../../kernel/liteos_m/utils -Igen/device/board/fnlink/shields/v200zr-evb-t1 -I../../../device/soc/bestechnic/aos_bsp/rtos/liteos/liteos_m/kal/cmsis -I../../../device/soc/bestechnic/aos_bsp/platform/cmsis/inc -I../../../device/soc/bestechnic/aos_bsp/platform/drivers/ana -I../../../device/soc/bestechnic/aos_bsp/services/wifi_app/wifi_console -I../../../device/soc/bestechnic/aos_bsp/utils/crc32 -I../../../device/soc/bestechnic/aos_bsp/utils/kfifo -I../../../device/soc/bestechnic/aos_bsp/net/wifi -I../../../device/soc/bestechnic/aos_bsp/platform/hal/best2003 -I../../../device/soc/bestechnic/aos_bsp/services/norflash_api -I../../../device/soc/bestechnic/aos_bsp/utils/eshell -I../../../device/soc/bestechnic/aos_bsp/services/aiot/ota_secboot -I../../../device/soc/bestechnic/aos_bsp/net -I../../../device/soc/bestechnic/bes2600/liteos_m/components/drivers/display/hal -I../../../device/soc/bestechnic/bes2600/liteos_m/components/drivers/flash -I../../../device/soc/bestechnic/bes2600/liteos_m/components/drivers/mipi_dsi -I../../../device/soc/bestechnic/bes2600/liteos_m/components/drivers/touch -I../../../device/soc/bestechnic/bes2600/liteos_m/components/drivers/touch/include -I../../../device/soc/bestechnic/bes2600/liteos_m/components/fs -I../../../device/soc/bestechnic/bes2600/liteos_m/components/ui -I../../../device/soc/bestechnic/bes2600/liteos_m/components/utils/include -I../../../device/soc/bestechnic/bes2600/liteos_m/components/bt/inc -Os -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -fdata-sections -mthumb -mthumb-interwork -DPLAYER_TOOL -DCHIP_BEST2003 -DOS_HEAP_SIZE=0x600000 -DCHIP_HAS_UART=3 -DRTOS -DDEBUG=1 -DCMSIS_OS_VER=2 -DOS_HWI_MAX_NUM=96 -DCONFIG_DISPLAY_A064 -DLFS_MAX_OPEN_DIRS=32 -DMBEDTLS_CMSIS_FILE=\"rtos/liteos/liteos_m/kal/cmsis/cmsis_os.h\" -DMINE_HARMONY_SOFTBUS -DLOSCFG_BASE_CORE_HILOG -DPTHREAD_KEYS_MAX=128 -DWIFI_STATE_NOT_AVALIABLE=0 -DTCP_USER_TIMEOUT=18 -D_stext=__text_start__ -D_etext=__text_end__ -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -fdata-sections -mthumb -mthumb-interwork -DPLAYER_TOOL -DCHIP_BEST2003 -DOS_HEAP_SIZE=0x600000 -DCHIP_HAS_UART=3 -DRTOS -DDEBUG=1 -DCMSIS_OS_VER=2 -DOS_HWI_MAX_NUM=96 -DCONFIG_DISPLAY_A064 -DLFS_MAX_OPEN_DIRS=32 -DMBEDTLS_CMSIS_FILE=\"rtos/liteos/liteos_m/kal/cmsis/cmsis_os.h\" -DMINE_HARMONY_SOFTBUS -DLOSCFG_BASE_CORE_HILOG -DPTHREAD_KEYS_MAX=128 -DWIFI_STATE_NOT_AVALIABLE=0 -DTCP_USER_TIMEOUT=18 -D_stext=__text_start__ -D_etext=__text_end__ -mcpu=cortex-m33 -fno-common -fno-builtin -fno-strict-aliasing -Wall -fsigned-char -fstack-protector-all -imacros /home/zkxi/workspace/L0_332/src/out/v200zr/display_demo/config.h -std=c99 -c ../../../third_party/libmodbus/src/modbus-rtu.c -o obj/third_party/libmodbus/src/libmodbus_static.modbus-rtu.o [OHOS ERROR] In file included from ../../../third_party/libmodbus/src/modbus-rtu-private.h:19, [OHOS ERROR] from ../../../third_party/libmodbus/src/modbus-rtu.c:18: [OHOS ERROR] /root/toolchain/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/include/termios.h:4:10: fatal error: sys/termios.h: No such file or directory [OHOS ERROR] 4 | #include <sys/termios.h> [OHOS ERROR] | ^~~~~~~~~~~~~~~ [OHOS ERROR] compilation terminated. 这是怎么回事,这个问题需要怎么修改,给出详细的修改方案?
最新发布
09-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值