微控制器的高阶并发性
Higher-Order Concurrency for Microcontrollers
摘要:
对微控制器进行编程涉及与硬件和外围设备的并发和反应式低级接口。这类程序通常使用并发语言扩展(如$\texttt{FreeRTOS tasks}$和$\texttt{semaphores}$)混合使用C和汇编编写,导致代码不安全、回调驱动、易于出错且难以维护。我们通过引入$\texttt{SenseVM}$来解决这一挑战-一个字节码解释的虚拟机,它提供了一个基于消息传递的$\textit{higher-order concurrency}$模型,最初由Reppy引入,用于微控制器编程。此模型将同步操作视为一级值(称为$\texttt{Events}$),类似于函数式语言中对一级函数的处理。这主要允许程序员编写和定制他们自己的并发抽象,此外,抽象出共享内存并发模型中常见的不安全内存操作,从而使微控制器程序更安全,可组合和易于维护。我们的虚拟机是通过一个低级别的$\textit{bridge}$接口,内置在嵌入式操作系统- Zephyr的便携式。桥接器由所有驱动程序实现,并设计为响应软件消息或硬件中断的编程保持一致和不可区分。在本文中,我们展示了我们的VM通过一个例子,写在一个类似Caml的功能语言,运行在$\texttt{nRF52840}$和$\texttt{STM32F4}$微控制器上的功能。
英文摘要:
Programming microcontrollers involves low-level interfacing with hardware and peripherals that are concurrent and reactive. Such programs are typically written in a mixture of C and assembly using concurrent language extensions (like $\texttt{FreeRTOS tasks}$ and $\texttt{semaphores}$), resulting in unsafe, callback-driven, error-prone and difficult-to-maintain code. We address this challenge by introducing $\texttt{SenseVM}$ - a bytecode-interpreted virtual machine that provides a message-passing based $\textit{higher-order concurrency}$ model, originally introduced by Reppy, for microcontroller programming. This model treats synchronous operations as first-class values (called $\texttt{Events}$) akin to the treatment of first-class functions in functional languages. This primarily allows the programmer to compose and tailor their own concurrency abstractions and, additionally, abstracts away unsafe memory operations, common in shared-memory concurrency models, thereby making microcontroller programs safer, composable and easier-to-maintain. Our VM is made portable via a low-level $\textit{bridge}$ interface, built atop the embedded OS - Zephyr. The bridge is implemented by all drivers and designed such that programming in response to a software message or a hardware interrupt remains uniform and indistinguishable. In this paper we demonstrate the features of our VM through an example, written in a Caml-like functional language, running on the $\texttt{nRF52840}$ and $\texttt{STM32F4}$ microcontrollers.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。