scieee AI-readable full text Open interactive document viewer

ChamelIoT: agnostic operating systems framework for reconfigurable IoT devices

Silva, Miguel Ângelo Fernandes

Abstract

O constante crescimento do número de dispositivos conectados à Internet of Things (IoT), assim como a expansão das áreas de aplicação IoT está a condicionar cada vez mais a forma como estes dispositivos operam. No edge da rede existem dispositivos de baixo custo que processam workloads com crescente complexidade enquanto atendem a rigorosas restrições temporais, simultaneamente necessitando de reduzir o consumo energético, o tamanho físico e requisitos de memória. A tecnologia Field-Programmable Gate Array (FPGA) surge como uma alternativa, uma vez que proporciona desempenho e determinismo ao migrar tarefas de software para o hardware. Contudo, a aceleração por hardware tem encontrado resistência significativa na indústria da IoT. Aceleradores em hardware são frequentemente implementados com o objetivo de acelerar uma única aplicação, limitando o número de sistemas em que um dado acelerador pode ser integrado. Como consequência, estes aceleradores impõem curvas de aprendizagem acentuadas, que por sua vez, atrasam o tempo de entrada no mercado. Assim, para que haja uma adoção generalizada de aceleradores em hardware na IoT, é essencial desenvolver soluções agnósticas que possam ser aplicadas a um espectro alargado de sistemas sem exigir conhecimento aprofundado do acelerador aos desenvolvedores. Neste sentido, esta tese propõe a framework ChamelIoT, uma framework agnóstica para aceleração em hardware de Sistemas Operativos (SOs) para a IoT, que aproveita a ubiquidade destes SOs para maximizar a adoção de aceleração em hardware na IoT. O ChamelIoT implementa um acelerador em hardware altamente adaptável que, em combinação com uma ferramenta user-friendly de alto nível, possibilita a implementação de uma pilha de sistema completa para vários SOs da IoT acelerados por hardware. Ao longo desta tese os artefactos desenvolvidos demonstram: (1) quais são as características dos SOs da IoT necessárias para migrar serviços do kernel para hardware; (2) de que forma diferentes SOs da IoT podem ser melhorados por um acelerador em hardware suportado por uma framework dedicada; (3) como diferentes abordagens de acoplamento impactam o desempenho de um acelerador e que trade-offs existem entre diferentes tipos de configurações; e, finalmente, (4) qual é a influência da aceleração de serviços de kernel nas métricas de rede de um controlador industrial da IoT.

Full text

Universidade do Minho Escola de Engenharia Miguel Ângelo Fernandes Silva ChamelIoT: Agnostic Operating Systems Framework for Reconfigurable IoT Devices Abril de 2024 ChamelIoT: Agnostic Operating Systems Framework for Reconfigurable IoT Devices Miguel Silva UMinho |2024 ii Universidade do Minho Escola de Engenharia Miguel Ângelo Fernandes Silva ChamelIoT: Agnostic Operating Systems Framework for Reconfigurable IoT Devices Tese de Doutoramento Programa Doutoral em Engenharia Eletrónica e Computadores Trabalho efetuado sob a orientação de: Professor Doutor Adriano José da Conceição Tavares Professor Doutor Tiago Manuel Ribeiro Gomes Professor Doutor Mongkol Ekpanyapong Abril de 2024 COPYRIGHT AND TERMS OF USE OF THIS WORK BY A THIRD PARTY This is academic work that can be used by third parties as long as internationally accepted rules and good practices regarding copyright and related rights are respected. Accordingly, this work may be used under the license provided below. If the user needs permission to make use of the work under conditions not provided for in the indicated licensing, they should contact the author through the RepositoriUM of Universidade do Minho. Licença concedida aos utilizadores deste trabalho Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en This document was created with the (pdf/Xe/Lua)L A T EX processor and the NOVAthesis template (v7.0.2) . ii Acknowledgements I wish to express my sincere gratitude to Dr. Adriano Tavares for his continuous support, patience, and motivation throughout these years. His priceless guidance made this journey considerably easier. Thank you for everything. I am also grateful to Dr. Mongkol Ekpanyapong for receiving me at the Asian Institute of Technology. His guidance in my work there and hospitality in his lab made my travel to Thailand a shining moment in this thesis. A warm thank you from Portugal. I am eternally thankful to Dr. Tiago Gomes, the best advisor a student could ever ask for. All the valuable discussions, timely advices, and insightful comments made the Ph.D. journey an enjoyable ride. You transcended the role of academic advisor to become a friend for life. No amount of ”thank you”will ever be enough. To Dr. Sandro Pinto, the best advisor and friend I could hope for. Thank you for guiding me in everything research-related and thank you for never giving up on me, even in the darkest times. I can’t put into words how grateful I am for everything you have done for me. Thanks to Fundação para a Ciência e Tecnologia for financing my Ph.D. (grant SFRH/BD/146678/2019). Thanks to the ESRG group and Centro ALGORITMI of the University of Minho for being such a fantastic workplace. Thanks to the MES group of the Asian Institute of Technology, Thailand, for hosting me. Special thanks to all my Ph.D. and lab colleagues who were in the same boat as me during this journey. Thank you, David, for the company during our stay in Thailand. Thank you, Martins, for the whisky recommendations. Thank you, Dani, for the invaluable pauses every afternoon. Thank you, Costa, for bringing laughter with you. And thank you, Sérgio, for letting my mind rest from work with bouldering problems. Last but not least, I would like to thank my family, who had to bear with me at home. To my mom and dad, thank you for supporting me in each way you knew and could. To my sister, thank you for your support and for bringing to life the most precious thing I have, my goddaughter Letícia. You are beyond priceless, and without you, everything would have been impossible. iii STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the Universidade do Minho. , (Place) (Date) (Miguel Ângelo Fernandes Silva) iv „“ Small hopes can grow surprising fruit. ” — Robert Jordan, Knife of Dreams (Author of the epic fantasy series ”The Wheel of Time”) v Resumo ChamelIoT: Framework Agnóstica para Sistemas Operativos em Dispositivos IoT Reconfiguráveis O constante crescimento do número de dispositivos conectados à Internet of Things (IoT), assim como a expansão das áreas de aplicação IoT está a condicionar cada vez mais a forma como estes dispositivos operam. No edge da rede existem dispositivos de baixo custo que processam workloads com crescente complexidade enquanto atendem a rigorosas restrições temporais, simultaneamente necessitando de reduzir o consumo energético, o tamanho físico e requisitos de memória. A tecnologia Field-Programmable Gate Array (FPGA) surge como uma alternativa, uma vez que proporciona desempenho e determinismo ao migrar tarefas de software para o hardware. Contudo, a aceleração por hardware tem encontrado resistência significativa na indústria da IoT. Aceleradores em hardware são frequentemente implementados com o objetivo de acelerar uma única aplicação, limitando o número de sistemas em que um dado acelerador pode ser integrado. Como consequência, estes aceleradores impõem curvas de aprendizagem acentuadas, que por sua vez, atrasam o tempo de entrada no mercado. Assim, para que haja uma adoção generalizada de aceleradores em hardware na IoT, é essencial desenvolver soluções agnósticas que possam ser aplicadas a um espectro alargado de sistemas sem exigir conhecimento aprofundado do acelerador aos desenvolvedores. Neste sentido, esta tese propõe a framework ChamelIoT, uma framework agnóstica para aceleração em hardware de Sistemas Operativos (SOs) para a IoT, que aproveita a ubiquidade destes SOs para maximizar a adoção de aceleração em hardware na IoT. O ChamelIoT implementa um acelerador em hardware altamente adaptável que, em combinação com uma ferramenta user-friendly de alto nível, possibilita a implementação de uma pilha de sistema completa para vários SOs da IoT acelerados por hardware. Ao longo desta tese os artefactos desenvolvidos demonstram: (1) quais são as características dos SOs da IoT necessárias para migrar serviços do kernel para hardware; (2) de que forma diferentes SOs da IoT podem ser melhorados por um acelerador em hardware suportado por uma framework dedicada; (3) como diferentes abordagens de acoplamento impactam o desempenho de um acelerador e que trade-offs existem entre diferentes tipos de configurações; e, finalmente, (4) qual é a influência da aceleração de serviços de kernel nas métricas de rede de um controlador industrial da IoT. Palavras-chave: Aceleração em Hardware, Dispositivos Edge , FPGA, Internet of Things , Sistemas Operativos Embebidos vi Abstract ChamelIoT: Agnostic Operating Systems Framework for Reconfigurable IoT Devices The evergrowing Internet of Things (IoT) ecosystem increasingly imposes new requirements and constraints on every device. At the edge, low-end devices are processing increasing workloads and attending stricter timing deadlines while simultaneously being required to minimize their power consumption, form factor, and memory footprint. Field-Programmable Gate Array (FPGA) technology has been established as a key solution for the increasing demands as it achieves good performance and determinism by enabling the offload of software tasks to hardware. However, hardware acceleration has yet to gain significant traction in the IoT industry for various reasons. Hardware accelerators are often implemented to enhance a single application, limiting the number systems they can be integrated with. Furthermore, these accelerators can impose significant learning curves for developers, potentially delaying the time-to-market. As a crucial step towards the widespread adoption of hardware acceleration in the IoT, it is essential to explore agnostic solutions that can be used by a broad range of systems and do not require developers to have extensive knowledge of the accelerator. This dissertation proposes ChamelIoT, an agnostic framework for hardware acceleration of IoT Operating Systems (OSs). This framework aims to leverage the ubiquity of OSs in embedded systems to maximize is adoption of hardware acceleration in the IoT landscape. ChamelIoT implements a highly adaptable hardware accelerator that, in combination with a user-friendly high-level building tool, eases the deployment of a complete system stack for multiple IoT OSes enhanced by hardware acceleration. The artifacts developed during this doctoral project demonstrate the following: (1) which IoT OS features can be leveraged to offload kernel services to hardware; (2) how different IoT OSs can be improved by a single hardware accelerator with a supporting framework; (3) how different coupling approaches impact the performance of a hardware accelerator and the trade-offs between these configurations; and (4) what is the influence of accelerating the kernel services on the networking metrics of an industrial IoT controller. Keywords: Edge devices, Embedded Operating Systems, FPGA, Hardware Acceleration, Internet of Things vii 26 Network nodes IPs and ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 27 Average response time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 xiv List of Listings 5.1 Hardware accelerator Nix package declaration. . . . . . . . . . . . . . . . . . . . 57 5.2 Operating system Nix package declaration. . . . . . . . . . . . . . . . . . . . . 57 6.1 Memory access example to interact with the loosely-coupled accelerator. . . . . . . 60 6.2 Write and read data to the loosely-coupled accelerator. . . . . . . . . . . . . . . . 60 7.1 C macro for the RoCC instruction. . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.2 Write and read data to the tightly-coupled accelerator. . . . . . . . . . . . . . . . 75 8.1 IIoT Controller main Nix recipe. . . . . . . . . . . . . . . . . . . . . . . . . . . 90 xv xvi Acronyms AHB Advanced High-Performance API Application Programming Interface ASIC Application-Specific Integrated Circuit AXI Advanced eXtensible Interface bps bits per second CISC Complex Instruction Set Computing COTS Commercial off-the-shelf CPU Central Processing Unit DMA Direct Memory Access DPR Dynamic Partial Reconfiguration EDF Earliest Deadline First FF Flip-Flop FIFO First-In-First-Out FPGA Field-Programmable Gate Array GPOS General Purpose Operating System HW-OS Hardware-Accelerated Operating System IIoT Industrial Internet of Things IoT Internet of Things xvii IPC Inte-Process Communication ISA Instruction Set Architecture ISR Interrupt Service Routine LUT Look-Up Table LUTRAMs LUTs as RAM M2M Machine-to-Machine MAC Medium Access Control MCU Microcontroller Unit MMU Memory Management Unit OS Operating System PAN ID Personal Area Network Identifier PDR Packet Delivery Ratio PHY Physical PLIC Platform-Level Interrupt Controller pthreads POSIX Threads RFID Radio-Frequency Identification RISC Reduced Instruction Set Computing RMS Rate-Monotonic Scheduling RoCC Rocket Custom Coprocessor RTOS Real-Time Operating System SDR Software-Defined Radio SoC System-on-Chip SPI Serial Peripheral Interface SRL Shift-Register LUT SW-OS Software Operating System SWaP-C Size, Weight, Power, and Cost TCB Thread Control Block TID Thread Identifier UDP User Datagram Protocol xviii WCET Worst-Case Execution Time WSN Wireless Sensor Network xix 1 Introduction The continuous integration of Internet of Things (IoT) devices into a multitude of ecosystems poses several challenges, especially for resource-constrained edge devices. These devices, often characterized by limited processing power, memory, and energy resources, struggle to meet the increasing requirements of performance and real-time. As IoT proliferates across domains such as industrial automation, healthcare, domotics, and others, ensuring interoperability among devices and protocols, becomes increasingly imperative to guarantee seamless interaction across the system. Nonetheless, addressing these challenges on resource-constrained devices requires exploring new technologies and solutions. This chapter starts by detailing the motivation for the work realized in this Ph. D. dissertation in Section 1.1. Then, Section 1.2 reviews the problems and limitations this doctoral project proposes to overcome and Section 1.3 delineates the scope of this dissertation. Section 1.4 details the main research questions and methodology required to answer those questions. Lastly, Section 1.5 outlines the structure of this dissertation, while Section 1.6 lists the main academic contributions. 1.1 Motivation The IoT is significantly changing the way technology integrates into everyday life, with a network that consists of billions of connected devices that gather, process, and share data worldwide [1]. Recent statistics show that there were 16.7 billion IoT devices in 2023 and this number is expected to keep increasing in the upcoming years [2]. At the same time, reports predict that 29.42 billion devices will be connected to the IoT worldwide by the end of 2030 [3]. Arm goes even further, envisioning that a trillion new IoT devices will be produced by the end of 2035 [4]. This trend has revolutionized various sectors, with IoT devices being deployed in diverse applications such as remote patient monitoring in healthcare [5, 6], vehicle tracking and diagnostics in automotive [7, 8], predictive maintenance in industrial settings [9, 10], and smart home automation in domotics [11, 12], among other applications [13–15]. A significant subset of the IoT ecosystem comprises edge and low-end devices, which are required to execute progressively more complex tasks despite their limited computational power, memory, and energy resources [16, 17]. These devices operate near the data source and, consequently, they must process 1 CHAPTER 1. INTRODUCTION and react to real-time environmental data, reducing reliance on cloud-based architectures and addressing concerns such as latency and bandwidth constraints [18, 19]. The shift towards edge computing unveils the need for more robust systems to handle complex and computation-intensive applications despite the constraints imposed by limited resources. The complexity of applications running on these constrained devices continues to rise, driven by the continuous quest to achieve smarter and more autonomous functionality that can operate independently of constant cloud connectivity. This growth poses the challenge of enhancing device capability without significant increases in power consumption or physical size [16]. One promising solution lies in hardware acceleration, particularly through the use of Field-Programmable Gate Arrays (FPGAs) [20, 21]. Recent advancements have made FPGAs more affordable and energy-efficient, enabling their integration even with resource-constrained edge devices [22, 23]. However, most existing solutions are highly specialized and tailored to specific applications or device types, limiting their broader usefulness across the diverse landscape of IoT devices. As such, expanding hardware acceleration beyond the application level presents an opportunity to overcome these challenges. This brings attention to the role of Operating Systems (OSs), which handle device functionality by managing hardware resources and providing necessary services for application execution. In the realm of IoT, especially at the edge, Real-Time Operating Systems (RTOSs) are prevalent due to their ability to handle the strict requirements of real-time processing and hardware heterogeneity [24–26]. Accelerating these OSs through hardware has shown system-wide improvements in performance and determinism [27–34]. Despite the proven benefits, such solutions failed to gain traction in the IoT due to being highly specialized to a single OS or application. As such, there is a lack of an agnostic and scalable solution that can enhance a variety of IoT OSs to maximize the potential for widespread adoption and promote performance benefits across the IoT ecosystem. 1.2 Problem Statement The expanding heterogeneity of IoT and the increasing demand for edge computing have led the industry to explore new technologies to cope with the stricter requirements [35, 36]. Hardware acceleration has proved beneficial in terms of performance and real-time capabilities, but it comes at the cost of requiring reconfigurable fabric to be available on the platform [37]. In the IoT environment, literature has presented several examples of applications leveraging FPGAs to enhance their system [38, 39]. However, these accelerators are mainly designed to optimize a specific set of functions and tasks, which limits the extent to which these can be used across multiple sectors, platforms, or applications [39–41]. Accelerating OS kernel services is an endeavor that can provide the benefits of hardware acceleration to a higher quantity of devices. However, migrating kernel features to hardware has yet to gain traction in the IoT. Based on previous research [27–34], this can be attributed to the possible following reasons: 2 1.2. PROBLEM STATEMENT •Narrow application scope: Even though OS acceleration inherently can reach more devices, most accelerators are designed to enhance a single kernel, a specific application, or implement an entirely new OS. The two latter cases severely hinder the adoption of this technology: (1) an accelerator for an OS tailored to a singular application can only be deployed on systems using that application; and (2) an accelerator that implements a new OS requires developers to learn further implementation details and Application Programming Interfaces (APIs) to develop new systems. •Limited target platforms: Most works on hardware acceleration of kernel services target platforms with an independent processor and external FPGA fabric. This processor, typically Commercial off-the-shelf (COTS), is proprietary and provides limited methods for integrating hardware accelerators, often as peripherals, thus constraining the accelerators’ architecture. Additionally, implementations focused on FPGA platforms require deploying a soft-core processor, which enables the modification of the processor internals to accommodate the OS acceleration. However, this approach is restrictive when the soft-core architecture is not open-source (e.g., Arm) or does not have silicon processors established in the market (e.g., Microblaze [42]). •Complex Integration Process: Considering that an OS is the software foundation of any IoT system, one of its primary responsibilities is to ease the development process through abstraction interfaces and libraries. Systems that provide kernel services in hardware have struggled to provide an easy-to-use interface for the final developer since they create entirely new APIs or go even further and add new instructions to the processor. Thus, this presents additional challenges to the development process as the developer must learn the implementation details of the hardware accelerator and new software interfaces. Furthermore, this hinders legacy applications from using hardware acceleration as they would require modifications on the application level. The previous limitations prevent the IoT from adopting hardware acceleration for OSs on a large scale. Consequently, to overcome these limitations, a hardware accelerator must tackle the following challenges: 1. The target platform should offer scalability and portability. In particular, the microprocessor architecture must be available for development and deployment. 2. The system should be capable of accelerating multiple OSs. The most prominent IoT OSs should be considered to reach a broader range of devices. 3. Several kernel services must be implemented in hardware. The kernel services identified in multiple IoT OSs should be the core of the hardware accelerator. 4. The hardware accelerator must provide a high degree of configurability. With multiple configurations, the system must be able to adapt to the application’s requirements and constraints. 3 CHAPTER 1. INTRODUCTION 5. An integration framework should be provided to ease the accelerator’s development and integration process. A set of APIs and guidelines must be provided to facilitate the interface between software and hardware. 6. Legacy applications should be able to use the accelerator without modifications to their code. Any required changes should be made to the system software internals and at compile time. This Ph. D. dissertation presents ChamelIoT, a framework for agnostic hardware acceleration of IoT OSs. ChamelIoT aims to maximize the adoption rate of hardware-accelerated OSs by providing an easy-to- use framework capable of building and integrating the whole system stack, from hardware to software. The framework offers multiple configurability points to the various kernel services to fit the system’s constraints. Furthermore, the hardware accelerator can be integrated with two different approaches, loosely- and tightly-coupled, allowing the developer to explore the trade-offs between scalability and performance. 1.3 Scope Offloading kernel services to hardware is not a new endeavor. It has proven to bring several benefits in terms of performance, predictability, and determinism. Figure 1 depicts a Hardware-Accelerated Operating System (HW-OS), which can be seen as an intersection of three distinct concepts: Reconfigurable Logic, Processor Architecture, and Operating System. It falls under the HW-OS responsibilities to manage the interactions between the three elements while still ensuring the availability of the kernel services. The HW-OS needs to accommodate an API that enables the Software Operating System (SW-OS) to interact easily with functionalities available in the reconfigurable logic. Furthermore, any operation the SW-OS performs over the processor architecture, e.g., context-switching or memory sharing, must remain unchanged behaviorwise in hardware. Lastly, there are two different approaches to the integration of hardware accelerators with the processor: (1) a loosely-coupled approach, where the accelerator is considered a peripheral, connected through a standard peripheral bus (e.g., Advanced eXtensible Interface (AXI) [43] or TileLink [44]); or (2) a tightly-coupled approach, where the accelerator is directly implemented in the processor’s datapath, for instance, as a co-processor. The HW-OS has to manage this interface, guaranteeing that the accelerator executes the correct functions with the right inputs and outputs. ChamelIoT focuses on building a holistic framework that eases designing and deploying HW-OSs on IoT devices. As such, this dissertation explores the following topics: • Identifying the most ubiquitous OSs in IoT edge devices; • Determining the most commonly used kernel services in IoT applications; • Selecting an open-source Instruction Set Architecture (ISA) to integrate the accelerator; • Developing a hardware accelerator that provides performance and real-time benefits to multiple OS kernel services; 4 2.1. INTERNET OF THINGS 2.1.1 Requirements Low-end IoT devices have proliferated throughout many ecosystems, and this heterogeneity raises several challenges that must be addressed [1, 47]. These devices are characterized by being energy-efficient, having a small form factor, needing to be connected to the Internet and other devices, and handling sensible data, among other features. These features can be translated into requirements imposed on most edge devices, which are detailed in the following subsections [25, 26, 60]. 2.1.1.1 Low Power Consumption IoT low-end devices often resort to low-power hardware, given that they are usually battery-powered and need to efficiently manage the power supply. To achieve reduced energy consumption, it is essential not to overdesign the system, choose low-power components, optimize the software and algorithms, and explore the processor’s low-power modes (e.g., deep sleep). This requirement is one of the most challenging for reconfigurable edge devices since FPGAs are traditionally known to be power-hungry. However, with proper design, hardware accelerators can be used to minimize power consumption [61]. This is particularly true for heavy workloads, as the hardware accelerator reduces the time required to perform an algorithm (e.g., AI), thus maximizing the processor’s idle time. 2.1.1.2 Resource-constrained Embedded Devices There is an ongoing trend in the industry to squeeze, as much as possible, the so-called Size, Weight, Power, and Cost (SWaP-C) budget. IoT devices are a great example of such a paradigm. These devices are designed with minimal margins and are usually limited to accommodate only the target application, as oversized and unused components also contribute to increased power consumption and overall cost [25, 26, 62]. Another important aspect that significantly limits the resources available on these devices is their placement, frequently requiring footprints as small as possible. Hence, the number of components has to be kept to the bare minimum to avoid any waste of space. Considering the previous aspects, the size and type of available memory in a system can also be an indicator of the class of an IoT device, as these components are sometimes the most power-consuming elements of the final solution. Therefore, it is essential to determine the size of the available memory, both for code and data, while minimizing the amount of data that needs to be saved between sleep/wake-up cycles, as this may require memory to be permanently powered. FPGAs significantly impact the assembly budget of reconfigurable devices [38, 39]. Hence, it is essential to design hardware accelerators that fit the system’s needs or are highly configurable to adapt to the application. The amount of hardware resources the accelerator consumes allows the developers to decide on the best FPGA for the job and minimize the space and power consumed. 11 CHAPTER 2. BACKGROUND 2.1.1.3 Connectivity and Interoperability At the core of the IoT concept is the ability to connect everything. Hence, each device must include the necessary hardware and software for connectivity. Regarding the hardware, power consumption is a crucial aspect that led to the adoption of standard communication protocols for lossy communication links. The most common are the IEEE 802.15.4, BLE, and Wi-Fi [49, 63]. Transceiver devices compliant with these protocols often include two layers, Physical and Data Link, from the network stack [64], depicted in Figure 3, implemented in hardware. Figure 3: Standard IoT network stack. The software is then responsible for implementing the remaining layers. The network stack illustrated in Figure 3 was derived from the traditional seven-layer OSI Model stack [64], and most OSs adopt it for IoT low-end devices. It is divided into five independent layers, which allow full interoperability and eases its portability among heterogeneous devices. For each layer, several standards and protocols, e.g., UD- P/TCP, IPv6, CoAP, 6LoWPAN, were carefully selected to fulfill the tight constraints of the target devices. Regarding the network layer, by using a 128-bit addressing scheme, IPv6 is the key to connecting billions of devices to the Internet [65]. In order to allow its support over different Medium Access Control (MAC) and Physical (PHY) standards, an adaptation layer protocol, e.g., 6LoWPAN for IEEE 802.15.4, is necessary. Due to the portability and interoperability requirements, the OS usually provides the network stack. Several open-source network stacks for low-end devices, like OpenWSN [66] or lwIP [67], provide different characteristics, making them suitable for different sets of applications. Additionally, OSs usually offer the network stack tightly intertwined with the kernel, where both kernel and network stack are developed and optimized together.. Lastly, reconfigurable technology can be used to accelerate the network stack [41, 68]. However, interoperability is still paramount. Therefore, the hardware accelerator must guarantee that the system can still communicate with the Internet and other devices. 2.1.1.4 Real-Time Real-time functionality entails the capacity of an edge device to promptly process and respond to incoming data or events with strict time constraints. This attribute is particularly critical in applications requiring immediate decision-making and action, such as autonomous systems, industrial automation, and healthcare 12 2.2. OPERATING SYSTEMS monitoring. Achieving real-time capabilities demands efficient hardware configurations and meticulously designed software algorithms that minimize processing latency [69, 70]. The system software plays a major role in this aspect. Several essential OS features, such as implementation, optimization, architecture, programming model, scheduling algorithm, and support for realtime events (e.g., interrupts), define how the OS can attend critical tasks with high predictability and determinism [25, 26]. On the other hand, hardware also heavily influences a system’s real-time capabilities. Especially on reconfigurable devices, hardware accelerators’ inherent parallel processing capabilities substantially decrease the time spent on any given task. Additionally, they often can execute those tasks in a deterministic fashion. 2.1.1.5 Security and Safety The ongoing cat-and-mouse game of increasing hacks and software patches has raised significant concerns about securing IoT devices. Moreover, there is an ever-growing volume of sensible data processed by IoT nodes. Examples include personal or health-related data acquired from sensors [71, 72]. Therefore, to ensure the privacy and security of critical data through communications in the IoT ecosystem, security mechanisms must ensure confidentiality, integrity, authenticity, and non-repudiation of the whole information’s life cycle. This can be achieved through the protocols implemented on the network stack or other external mechanisms [73]. Safety is another crucial aspect of IoT devices, as most tend to implement several mixed-criticality features. Furthermore, safety and security stand hand by hand - there is no safety without security and vice versa. Any malfunction or attack that seizes control of onboard actuators can directly influence the system’s normal behavior or even cause hazards to users [74]. For example, a widespread attack on any device connected to a network or the Internet is called a denial of service (DoS) attack. Although it can be achieved in several ways, the main idea is to deprive the system of its resources (e.g., processing time), preventing it from performing as expected. For example, this is a problem in automotive applications when critical tasks must be executed under bounded and deterministic deadlines. While the DoS attack is only a generic example, several other types of attacks can be performed by simply adapting the same concept from classical attacks on network-based systems to IoT devices. Edge devices can leverage reconfigurable technology to provide enhanced security by isolating sensible algorithms or data from the remaining system stack [75, 76]. This technique not only provides benefits to security but can also be used to increase performance and real-time capabilities. 2.2 Operating Systems OSs play a pivotal role in real-time and embedded systems, where precise timing and efficient resource utilization are paramount. Unlike General Purpose Operating Systems (GPOSs) that cater to a wide range of applications, embedded systems demand specialized OSs tailored to their unique requirements. These 13 CHAPTER 2. BACKGROUND systems are characterized by strict timing constraints, where tasks must be executed within predetermined time limits to ensure the reliability and effectiveness of the applications they support [77, 78]. The fundamental concept underlying RTOSs is the deterministic and predictable response to external events. In the IoT context, where interconnected sensors, actuators, and devices collaborate to gather and process data, RTOSs are instrumental. These OSs enable the coordination and synchronization of tasks across IoT devices, ensuring that data is acquired, processed, and transmitted with minimal latency and in a deterministic manner. Furthermore, OSs designed for the IoT include libraries that implement and manage the most relevant features of IoT applications like networking stacks and power management. Additionally, the scheduling algorithm is critical in the system’s real-time and deterministic capabilities as it determines which and when a task should be executed. Lastly, OSs provide a suite of essential kernel services that facilitate the execution of real-time tasks. These services encompass task scheduling, thread management, synchronization mechanisms, and Inte-Process Communication (IPC). 2.2.1 Scheduling The scheduler in a RTOS is a fundamental component that manages task execution. Its pivotal role lies in arbitrating access to the Central Processing Unit (CPU) among competing tasks, ensuring that each task receives its fair share of processing time while adhering to the defined scheduling policy. The scheduler employs algorithms and heuristics to determine the order in which tasks are granted access to the CPU, considering factors such as task priorities, deadlines, and preemption rules. The scheduler enables the RTOS to meet strict timing constraints and react promptly to external events, a critical requirement in realtime and embedded systems. The effectiveness of the scheduler directly influences the system’s ability to provide timely and deterministic execution, making it a cornerstone in the design and operation of RTOS environments. Among the variety of scheduling algorithms in IoT environments, the most prevalent are [70, 79]: •Rate-Monotonic Scheduling (RMS) - This algorithm assigns priorities to tasks based on their execution frequencies, with shorter periods receiving higher priority. This is suitable for periodic tasks with known, fixed deadlines. •Earliest Deadline First (EDF) - The algorithm prioritizes tasks based on their deadlines, allowing for dynamic scheduling. EDF is well-suited for dynamic environments with both periodic and nonperiodic tasks. •Fixed-Priority Preemptive Scheduling - This algorithm assigns static priorities to tasks, and the highest priority task that is ready to execute is given control of the processor. This is a simple and widely used scheduling approach. 14 2.2. OPERATING SYSTEMS Fixed-Priority Preemptive Scheduling algorithm is well-suited for systems with well-defined, predictable task behaviors and where tasks have distinct levels of urgency. However, it is essential to carefully assign task priorities to avoid priority inversion and deadlock scenarios. Despite its simplicity, Fixed-Priority Preemptive Scheduling is a fundamental scheduling algorithm in many embedded systems and IoT applications, providing deterministic behavior crucial for meeting strict timing constraints [80]. As depicted in Figure 4, the basic principle of this algorithm is that a high-priority task should preempt a low-priority task and start executing. The low-priority task only resumes execution after the high-priority task yields. Nonetheless, even though this algorithm assumes fixed priorities, under certain circumstances, the task’s priority can be changed dynamically, e.g., priority inheritance in synchronization mechanisms. Priority High Low Time Event Scheduling Point Thread A Thread C Figure 4: Fixed-priority preemptive scheduling algorithm. 2.2.2 Thread Management Thread management is critical to resource allocation and task execution in RTOSs. A thread is an independent and concurrent execution unit within a program and is represented by the Thread Control Block (TCB) in most kernels. The TCB encapsulates essential information like its state, priority, program counter, and other relevant context. The essential functions of thread management include adding and removing threads, pausing and resuming them, and modifying some TCB values. While different OSs have different distributions and namings for thread states, the following groups can be identified as common across a majority of IoT OSs: •Ready State - Threads with this state are to be considered by the scheduling algorithm as a possibility to take execution rights. •Blocked State - This state represents threads that have been paused or blocked (e.g., sleeping or waiting for an event). •Running State - This state is reserved for a single thread currently executing in the processor. Each OS often has several states that are functionally similar to the ones mentioned above. However, they label each variation differently according to their implementation details, e.g., a different state for 15 CHAPTER 2. BACKGROUND different reasons blocking a thread. The thread manager has to organize this data so that the scheduler can readily determine and access the ready and executing threads to schedule the following thread. The list of threads that are in a ready state constitutes the ready queue. A traditional approach to the ready queue is having all the ready threads in a single data structure, such as a linked list. As a result, the list has to be iterated over at every scheduling point to find the following thread to execute. As depicted in Figure 5a, for the scheduler to find Thread 4, it would have to go over three iterations on the linked list. It consequently increases the time required by the scheduling process, which is detrimental to performance and determinism. However, in priority-based kernels, the thread data is often organized according to their priorities. The same is true for the ready queue, where each priority level has its list of ready threads, as shown in Figure 5b. Such an approach allows the scheduler to quickly determine which thread is the following by assessing the list corresponding to the next highest priority. Considering this, the thread manager is responsible for ensuring that all the data is organized correctly and that every operation on the TCB is reflected on the ready queue. Thread 4 Thread 5Thread 1 Thread 2 Thread 3 (a) Ready queue with single linked list. Priority Thread 4 Thread 5 Thread 1 Thread 2 Thread 3 0 1 2 ... N Executing ReadyNext Ready Blocked (b) Ready queue with one linked list per priority level. Figure 5: Different implementations of ready queues. 2.2.3 Synchronization Mechanisms Synchronization mechanisms are pivotal in orchestrating the orderly access to shared resources among concurrent threads. These mechanisms are essential in IoT OSs, where multiple threads often need to access shared sensors, communication channels, or memory buffers. By utilizing synchronization primitives, IoT applications can ensure that critical code sections are executed atomically, preventing race conditions and data corruption. Furthermore, these mechanisms facilitate task coordination, enabling efficient resource utilization and synchronization of activities across the IoT system. However, it is imperative to correctly employ these synchronization primitives, as improper use may lead to deadlocks or priority inversion issues, potentially compromising the system’s real-time responsiveness and reliability. Two prominent synchronization mechanisms employed in IoT applications are mutexes and semaphores. 16 2.2. OPERATING SYSTEMS 2.2.3.1 Mutexes A mutex (deriving from ”mutual exclusion”) is a synchronization primitive that ensures mutually exclusive access to a resource. In the context of OSs, a thread can use a mutex to guarantee that its access to a shared resource is undisturbed and that other threads cannot corrupt it. A mutex operates under the principle of ownership, where a task that successfully acquires a mutex gains exclusive rights to the protected resource, thereby preventing other tasks from concurrently accessing it. In the event that a mutex is already locked, the requesting task is temporarily blocked, waiting for the release of the mutex from the owning task. In a simplistic implementation of mutexes, a failed acquisition can result in a priority inversion scenario. In this case, a thread with lower priority gets execution rights before another with higher priority, which violates the expected behavior of the systems. It can lead to an instance where a critical portion of code protected by a mutex is delayed to a later scheduling point [81]. This is depicted in Figure 6a, where the highest priority Thread C interrupts Thread A and fails to lock a mutex currently owned by Thread A. This leads to a case where the Thread A critical section only occurs after Thread B finishes executing. These situations are not desirable in IoT edge devices where real-time and determinism are paramount. A possible solution to priority inversion scenarios is using priority inheritance algorithms, which consist of raising the priority level of the current owner of a mutex to the highest priority of the threads that attempted to lock the same mutex [81]. This is represented in Figure 6b, where after Thread C fails to lock the mutex, Thread A is given the same priority level to finish executing its critical section and unlock the mutex. Once Thread A unlocks the mutex, Thread C can resume its critical section, and Thread B only runs after the highest priority thread finishes its execution Priority 0 1 2 Time Lock Mutex Lock Mutex Unlock Mutex (a) Priority inversion scenario. Priority 0 1 2 Time Lock Mutex Lock Mutex Unlock Mutex Scheduling Point Thread A Thread A Critical Section Thread C Thread C Critical Section Thread B (b) Priority inheritance scenario. Figure 6: Mutexes use case scenarios. 17 CHAPTER 2. BACKGROUND 2.2.3.2 Semaphores Semaphores are synchronization primitives that enable controlled access to shared resources and intertask communication through signaling mechanisms. They follow a producer-consumer scheme, where a producer thread signals the semaphore once it finishes acquiring or processing a particular resource. Internally, the semaphore registers the number of signals emitted by the producer thread. In turn, the consumer thread checks, through the semaphore, if the resource is available. The consumer thread keeps executing if the semaphore’s internal signal count exceeds zero. Otherwise, the thread is blocked. Semaphores are often used in cases where a resource is produced at a high frequency, e.g., data acquired from a sensor, and multiple threads need access to it. Semaphores come in two primary variants: binary semaphores and counting semaphores. Binary semaphores possess two states, ”taken”or ”available,”providing a means for tasks to signal events or manage access to a singular resource. In contrast, counting semaphores allows multiple tasks to signal the semaphore up to a defined limit. This feature is invaluable in scenarios necessitating the controlled allocation of resources from a pool. Figure 7 illustrates a scenario where a producer thread signals the semaphore several times before a scheduling point, and a consumer thread takes the semaphore. Time Signal Producer Consumer Sem. Count Signal Signal Take 0 1 2 3 2 Figure 7: Counting semaphore example. 2.2.4 Inter-Process Communication Inter-process communication enables the exchange of data among concurrently active threads. IPC are valuable when tasks collaborate, share information, or coordinate operations. In IoT OS environments, IPC mechanisms can take various forms, each tailored to specific synchronization and communication requirements [82]. The three most common IPC approaches are: •Message Queues - This mechanism provides a structured means of communication between threads. Threads can send and receive messages or data packets through these queues. This asynchronous communication method allows tasks to exchange information without direct coupling, making it particularly suitable for applications with sporadic and variable data exchange needs. •Mailboxes - Mailboxes are similar to message queues but often offer more extensive storage capabilities. They enable threads to send and receive messages or data packets, allowing for 18 2.3. RISC-V efficient buffering and synchronization. Mailboxes are commonly used in scenarios where threads may produce data faster than others can consume it. •Shared Memory - This mechanism facilitates direct data sharing between threads by providing a shared memory region that multiple threads can access concurrently. While efficient, it requires careful synchronization mechanisms to avoid race conditions and data corruption. Considering the fact that mailboxes tend to be more complex and require more resources, and shared memory is very susceptible to data corruption, the most used IPC mechanism is message queues. Message queues are asynchronous communication mechanisms that send data from one thread to another. Typical implementations of message queues in OSs use First-In-First-Out (FIFO) queues to store messages waiting for a receiving thread. When a thread attempts to send a message, it should provide a pointer to the data so that the message queue can store a copy of the message. Likewise, when a thread receives a message, it should provide a pointer to the address where it wants the data to be stored so it can receive a copy of the data. Figure 8 illustrates a message queue example where a thread sends messages through the queue, and another thread receives a message that was sent before. Message Queue Message 4 Message 3 Message 2 Message 1 Thread A Thread B sending receiving firstlast Figure 8: Message queue example. 2.3 RISC-V RISC-V is an open-source ISA, a pivotal development in computer architecture, indicating a departure from traditional proprietary architectures. Conceptualized at the University of California, Berkeley, RISC-V embodies the principles of Reduced Instruction Set Computing (RISC), characterized by its streamlined instruction set, modular design, and extensibility [83]. Unlike its closed-source counterparts, RISC-V’s opensource nature fosters a collaborative ecosystem where a global community of developers, researchers, and practitioners converge to collectively refine and extend the architecture. This accessibility creates an environment conducive to innovation, as it eliminates the barriers associated with proprietary architectures, empowering individuals to explore novel architectural paradigms and design methodologies. The fundamental principles of RISC-V are rooted in simplicity, modularity, and orthogonal design principles. The base integer instruction set forms a minimalist yet versatile foundation, supplemented by a suite of extensions catering to specialized domains, including floating-point arithmetic, vector processing, security, and virtualization features. This extensible framework enables developers to customize the architecture to address specific computational requirements, fostering adaptability across a broad spectrum of applications. RISC-V’s open-source nature presents many advantages, notably affording unparalleled 19 CHAPTER 2. BACKGROUND transparency and accessibility to the underlying architecture. This transparency facilitates a deep understanding of the hardware, enabling developers to explore intricate details of the ISA and optimize for specific use cases. Furthermore, the absence of licensing fees and intellectual property encumbrances associated with proprietary ISAs liberates RISC-V from economic constraints, rendering it an attractive proposition for both academia and industry [84]. However, despite its myriad advantages, RISC-V has its challenges and limitations. The relatively early stage of the ecosystem may present hurdles in terms of toolchain availability, comprehensive hardware support, and a mature development ecosystem. Compatibility concerns with existing software and hardware infrastructure also warrant consideration, particularly in contexts where legacy systems are prevalent. On the other hand, the versatility of RISC-V is evident in its diverse applications. RISC-V demonstrates its applicability across a broad spectrum of industries, from embedded systems in IoT devices, where resource efficiency and flexibility are paramount, to aerospace and defense applications, requiring robust and adaptable computing platforms. Its role is further highlighted in research and academia, serving as a fertile ground for exploration and experimentation in computer architecture. Several implementations of RISC-V cores have emerged, offering a range of options to cater to specific application needs. Noteworthy examples include: •Rocket Core [85] - Developed by the University of California, Berkeley, the Rocket Core is an opensource, in-order, scalar RISC-V core that serves as a versatile starting point for building customized RISC-V systems. •Berkeley Out-of-Order Machine (BOOM) core [86] - Also from the University of California, Berkeley, the BOOM core is an open-source, out-of-order processor designed for higher-performance computing tasks. •Parallel Ultra-Low Power (PULP) core [87] - The PULP project provides a family of opensource RISC-V cores optimized for energy efficiency. These cores are designed for IoT and wearable devices. •Ariane core [88] - Ariane is a 6-stage, single-issue, in-order RISC-V core developed at ETH Zurich. This core aims for simplicity and efficiency, making it suitable for various embedded applications. •CVA6 [75] core - The CVA6 project offers a family of production quality, open source, heavily parameterizable, and application class cores targeting Application-Specific Integrated Circuit (ASIC) and FPGA implementations. 2.3.1 Instruction Set Architecture The RISC-V ISA follows RISC principles, characterized by its simplicity, modularity, and extensibility. RISC-V embraces a minimalist set of instructions, each designed to perform a singular, well-defined operation, 20 3.2. HARDWARE ACCELERATION OF OPERATING SYSTEMS implemented within the Cop2-OSC coprocessor. Using the hardware RTOS services presents better performance results than their software implementation. For instance, the OreK Executive takes 66 clock cycles in software to schedule the following thread, and the hardware version only takes 23 clock cycles. HartOS: HartOS [30] is a microkernel-structured RTOS implemented in hardware that targets hard realtime applications. HartOS deploys a special-purpose Complex Instruction Set Computing (CISC)-based processor to execute the kernel functions invoked from the software. This internal processor communicates to the main CPU via AXI buses (loosely-coupled) and shares an internal register map with the kernel services offloaded to hardware. These services include scheduling, task management, interrupt handling, and synchronization mechanisms. HartOS provides a custom, easy-to-use API for implementing software applications and presents a performance evaluation comparing itself to a different software RTOS (uc/OS-II). This evaluation measures CPU workload according to different tick periods and task numbers. Furthermore, the work also evaluates the average periodic error and jitter for cycling tasks but does not present any determinist time measurement for any service implemented in hardware. SEOS: SEOS [31] is a hardware-accelerated OS designed to provide high adaptability for easy hardware RTOS adoption. It offloads several kernel services to hardware, including the scheduling, interrupt handling, synchronization mechanisms, and IPC. Each service is connected to an independent bus interface capable of communicating with several other industry-standard buses (e.g., Avalon, AXI, and Wishbone). This loosely-coupled approach promotes high adaptability, allowing SEOS to be used by multiple CPU architectures. SEOS uses a direct register mapped API and Context Switch Macro (CSM) for application software to interface with the hardware. These enable easy porting of application software by simply adjusting offsets and macros in a header file, further enhancing the adaptability of this OS. In terms of evaluation, SEOS compared with uC/OS-II, measuring the number of computation loops, interrupt latency, and IPC latency. SEOS shows performance improvements of 31.6%, 83,5%, and 71,9% in these metrics, respectively. RT-SHADOWS: RT-SHADOWS [32] is an architecture that provides unified hardware-software scheduling by manipulating an ARM-based soft-core to include support for multi-threading in the datapath. RTSHADOWS is implemented as a tightly-coupled coprocessor that includes a scheduler, thread manager, context switching, and synchronization and communication mechanisms. Paired with multiple configurability points, these hardware services were designed to be adopted by multiple RTOSs. RT-SHADOWS leverages magic instructions (supported by unmodified compilers) to enable multiple APIs directly mapped to RTOS APIs, allowing for effortless integration in software by swapping both calls. RT-SHADOWS presents a thorough evaluation that comprises hardware resource consumption, API performance benchmarks, and a complete OS benchmark. Furthermore, RT-SHADOWS accelerates two different RTOSs, uC/OS-II and FreeRTOS, which show significant performance improvements. Notably, there was a decrease in the interrupt overhead from approximately 1300 to 400 clock cycles in uC-OS/II, and from 2250 to 1400 clock cycles in FreeRTOS. 27 CHAPTER 3. STATE-OF-THE-ART OSEK-V: OSEK-V [33] explores the hardware-software design space for event-triggered fixed-priority realtime systems at the hardware-OS boundary. By modifying a RISC-V core’s whole pipeline and introducing additional ISA instructions, OSEK-V integrates a highly tailored hardware RTOS. Instead of developing flexible and generic hardware components, OSEK-V attempts to increase adoption by focusing on the automation process of developing static tailored hardware. As such, the work presented can almost fully automate and instantiate the kernel services (scheduling, thread managing, and synchronization mechanisms) and finite state machines that replicate entirely the original software application. Tailored hardware also requires customizing the system software. By pushing the OS logic into hardware, only a little functionality is left to the software part of the kernel. However, OSEK-V also fully automates this process. Considering OSEK-V is a heavily customized hardware accelerator, the performance evaluation was realized using a real-world case study, i.e., a quadrotor helicopter control system. As expected, OSEK-V presents performance improvements compared to the original application using specialized software, which, according to the authors, results in the hardware being close to 50% faster than the software. ARTESSO-TC: ARTESSO-TC [119] was initially developed as a hardware RTOS integrating part of a proprietary purpose-built CPU for TCP/IP-based applications. This OS was implemented following a tightlycoupled approach, where the trapping of specific instructions is used to interact with the hardware accelerator. ARTESSO-TC provided scheduling, thread managing, synchronization mechanisms, and IPC as the primary kernel services available. One of the main innovations of this work was a virtual queue technique applied to manage multiple threads, semaphores, or mailboxes. The virtual queue only uses a single clock cycle to perform an operation over a queue, such as writing or reading data. ARTESSO-TC was evaluated over simulations and experiments on an ASIC with this OS deployed in silicon. The evaluation included several microbenchmarks to multiple APIs to determine the performance increase of ARTESSO-TC compared to another RTOS (ITRON). In the worst-case scenario, ARTESSO required 11 clock cycles to change a task priority, and the software OS used 541 cycles. Other experiments were also presented regarding the throughput of a TCP/IP stack and the silicon area used by ARTESSO-TC. ARTESSO-LC: ARTESSO-LC [34] is the successor of the previous hardware-accelerated OS. Intending to maximize scalability and adoption in industrial controllers, Maruryma et al. decided to explore porting ARTESSO-TC to a loosely-coupled accelerator connected to an Arm CPU via an Advanced High- Performance (AHB) bus. ARTESSO-LC uses a custom interface controller to parse the AHB commands issued by the Arm core and communicate with the kernel services available to execute the instruction correctly. Moreover, ARTESSO-LC offers the same kernel services as its predecessor. In this work , Maruyama et al. [34] extensively compare ARTESSO implementations with a software example. This evaluation encompasses API execution times, interrupt responses, the influence of interrupts and ticks, and UDP/IP throughput. The results show that using a hardware RTOS improves the system’s performance and determinism compared to a software-only approach. Furthermore, the tightly-coupled approach results presented are at least one order of magnitude better than the loosely-coupled one. 28 3.2. HARDWARE ACCELERATION OF OPERATING SYSTEMS Notwithstanding, the authors point out that better performance of the tightly-coupled approach comes at the cost of portability and integrability. The tightly-coupled approach requires a modified Arm core, while the loosely-coupled is more straightforward to integrate with any FPGA-based platform. 3.2.3 Gap analysis and Discussion Table 1 presents presents the gap analysis among the aforementioned hardware-accelerated OSs and puts it into perspective with the framework proposed in the Ph. D. dissertation, ChamelIoT. The main parameters evaluated for each OS are grouped into four distinct categories: (1) hardware interface; (2) software interface; (3) supported kernel services; and (4) a qualitative evaluation. The hardware interface relates to how the hardware accelerator interacts with the processor. The target CPU architecture can limit a given hardware accelerator’s integration, deployment, and adoption. A closed architecture inhibits most developers from experimenting with the architecture internals and integrating accelerators directly in the datapath. Furthermore, each CPU architecture has an expected method for integrating a hardware accelerator, which favors the most widespread architectures on the market. As such, the ideal CPU architecture is open-source, which enables any developer to use and modify as they see fit. Lastly, the coupling approach used by the hardware-accelerated OS offers a trade-off between performance and adaptability. A tightly-coupled approach provides better performance and determinism since the accelerator is closer to the CPU and does not need to go through external buses to communicate with it. However, a loosely-coupled approach offers easier integration with multiple architectures as it resorts to standard peripheral buses to connect the accelerator with the CPU. The software interface refers to the interaction between the executing software and the hardware accelerator and depends on whether the hardware-accelerated OS enhances a COTS RTOS or replaces a software OS. The former approach enables the hardware-accelerated OS to be adopted by preexisting system software, enabling legacy applications to benefit from hardware acceleration and consequently maximizes the OS’s reach and scalability in the industry. On the other hand, the latter approach forces developers to implement applications from scratch, which limits the adoption of the hardware-accelerated OS to new systems. Furthermore, the abstraction API provided by the hardware-accelerated OS impacts the level of knowledge and the learning curves imposed on developers. A custom API forces the developers to have intimate knowledge of the OS, while a POSIX-compliant API allows users to implement their applications with a familiar standard API. Lastly, the hardware-accelerated OS can provide a method of mapping its API to other functions, which is suitable for systems that want to enable hardware acceleration in COTS OS. Lastly, Table 1 summarizes the most common kernel offload to hardware and provides a qualitative evaluation of the hardware-accelerated OSs mentioned previously. These OSs often implement kernel services in hardware that are widely used in IoT applications. Nonetheless, some works implemented additional services in hardware, e.g., memory management or watchdog timers, which aim to solve specific problems and are not aimed at the generic application scope. Regarding the qualitative evaluation, 29 CHAPTER 3. STATE-OF-THE-ART each system is assigned a symbol that represents whether it fares positively or negatively in performance, determinism, and configurability. Positive performance results indicate that the system improves the time used to execute kernel services and minimizes CPU workloads, and a deterministic solution indicates a reduction in the jitter in system calls. Additionally, the configurability aspect of a hardware-accelerated OS relates to the possibility of modifying portions of the system to fit the solution perfectly. If the primary goal of a hardware-accelerated OS is to maximize its adoption in the industry, it can be concluded that it should: (1) target an open-source CPU architecture, i.e., RISC-V; (2) offer multiple methods of integration with the CPU, allowing the developer to decide between performance and adaptability; (3) provide the benefits of hardware acceleration to COTS OS, therefore allowing easy porting of legacy applications; (4) provide an easy-to-use API, mappable with other OS APIs; (5) implement multiple kernel services in hardware with enough configurability to adapt to different constraints; and (6) bring performance and determinism to the system as a whole. As depicted in Table 1, the envisioned ChamelIoT aims to satisfy all of these points. Table 1: Gap analysis of hardware-accelerated OSs. indicates that the system fares positively, #that it fares negatively. HW-Accelerated OS Hthreads ARPA-MT HartOS SEOS RT-SHADOWS OSEK-V ARTESSO-LC ARTESSO-TC ChamelIoT Hardware Interface CPU Architecture Microblaze MIPS32 Microblaze Microblaze Arm RISC-V Arm Arm RISC-V Coupling Approach Loosely Tightly Loosely Loosely Tightly Tightly Loosely Tightly Both Software Interface Sofware RTOS HThreads OreK Executive HartOS Multiple Multiple OSEK-V ITRON ITRON Multiple Abstraction API POSIX Custom Custom Mapped Mapped Custom N/A N/A Mapped Supported Kernel Services Scheduling 333333333 Thread Manager 3 3 3 3 3 7 3 3 3 Synchronization 3 3 3 3 3 3 3 3 3 IPC 3 7 3 3 7 7 3 3 3 Interrupt Handling 7 3 3 3 3 3 3 3 7 Qualitative Evaluation Performance Determinism Configurability G# G# # # # 30 4 Operating Systems Analysis Operating Systems are critical components within the evergrowing realm of the IoT, where interconnected devices necessitate precise and timely execution of tasks. OSs provide a framework that enables concurrent execution of multiple tasks with deterministic timing characteristics, ensuring that critical operations are executed within specified time constraints. Furthermore, OSs offer libraries and abstraction APIs for complex applications, e.g., networking stack or security, that enable fast development cycles. Considering the broad collection of OSs and the lack of a “one size fits all” solution, analyzing and benchmarking some of the most prominent open-source OSs for the IoT becomes crucial. By understanding their main differences and characteristics, they can be carefully selected and deployed according to the application needs, i.e., when real-time is required or a low-power solution is preferred. Moreover, such a deep analysis cultivated extensive knowledge about the internals of multiple IoT OSs, which later translated into developing and implementing a hardware kernel capable of accelerating multiple OSs. This chapter details several IoT OSs and, through a preliminary evaluation, aims to select the ideal OSs and their kernel services to be accelerated in hardware by the solution proposed in this Ph. D. dissertation. Section 4.1 contains an overview of Contiki-NG, RIOT, and Zephyr, which are the OSs being evaluated. Section 4.2 describes the experiments realized and draws conclusions about the results obtained. Lastly, Section 4.3 contains final remarks about the three OSs evaluated, focusing on what can be used for the next steps of the ChamelIoT framework. The ideas and findings presented in this chapter resulted in the following publication: M. Silva, D. Cerdeira, S. Pinto and T. Gomes, ”Operating Systems for Internet of Things Low-End Devices: Analysis and Benchmarking,”in IEEE Internet of Things Journal, vol. 6, no. 6, pp. 10375-10383, Dec. 2019, doi: 10.1109/JIOT.2019.2939008 4.1 Operating Systems Several studies provide comprehensive analyses and comparative surveys on the most prevalent OSs in the low-end IoT landscape [120, 121]. These studies highlight several key distinctions among the OSs, such as the programming model (e.g., event-driven and multithreading), kernel architecture (e.g., monolithic 31 CHAPTER 4. OPERATING SYSTEMS ANALYSIS and microkernel), scheduling policy (e.g., cooperative and preemptive), and native support of a network stack for low-end devices. The ChamelIoT framework aims to agnostically accelerate kernel services in hardware, enabling new and legacy applications to benefit from hardware acceleration. Aiming to maximize its adoption across the IoT industry, ChamelIoT’s target OSs should already be widespread in the IoT and have a well-established community, ideally open-source. Some of the most prominent open-source OSs for the IoT include Contiki [122], RIOT [123], Zephyr [124], and FreeRTOS [125]. 4.1.1 Contiki-NG Contiki was originally proposed by Dunkels et al. as an OS for Wireless Sensor Networks (WSNs) targeting resource-constrained wireless nodes and was only later adapted for more powerful devices [122]. The OS follows an event-driven programming model based on a cooperative scheduling approach using protothreads, a lightweight mechanism for pseudo-threading, from which the programmer is abstracted. In its current version, these are seen as statically defined Processes and do not support priorities since this OS implements a cooperative scheduler. From a developer perspective, aside from its declaration, each Process must be implemented as a function that, at some point, yields the execution time to the following Process . Failing to yield, e.g., stopping in an infinite loop, would cause the whole system to halt. When deployed in low-end devices, Processes are expected to sleep or wait for events that trigger their execution. While the OS supports such a feature, fast response times to event occurrence may not be achieved due to its scheduling policy. By design, interrupts are the only form of preemption available in any Contiki application. Considering this, the execution flow of any program is dictated by the fully cooperative scheduling algorithm, where a Process can have two states, running or not running. When a synchronization mechanism is used, e.g., a mutex or a semaphore, there is no guarantee that the thread executing next is the one waiting for a shared resource. As for IPC mechanisms, Contiki applications are limited to shared memory. Lastly, ensuring the correctness of data and timing is part of the developer’s responsibilities. To support the OS’s main requirements, Contiki includes features that aim at communication-based low-power systems, such as sleep mode managing and support for several network stacks, e.g., uIP [126]. These stacks support standard and well-known protocols such as IPv6, RPL, 6LoWPAN, and CoAP while supporting several PHY technologies, such as IEEE 802.15.4, Wi-Fi, or BLE. Contiki mainly focuses on dependable (secure and reliable) low-power communication and standard protocols for modern IoT platforms based on 32-bit microcontrollers, primarily supporting Arm architectures. On its latest version, Contiki-NG [127], the overall code structure was revised and optimized with new configurations and a significant code base cleanup (obsolete protocols and standards were removed), minimizing the final binary size. 32 4.1. OPERATING SYSTEMS 4.1.2 RIOT Initially designed with the IoT ecosystem as the primary target, RIOT’s main characteristics comprise realtime capabilities and low-power efficiency [123]. This OS employs a multi-thread programming model and follows a microkernel-like architecture, which strives for a simpler and shorter development cycle due to its modular nature. RIOT implements a tickless priority-based scheduler, meaning there are no periodic events as scheduling points. This method tries to optimize the time spent in low-power modes, i.e., sleep or deep sleep modes, by forcing the system into these states whenever there are no threads to be executed, i.e., when the idle thread is active. RIOT follows a descending priority scheme, i.e., the highest priority thread has the lowest value, and each thread can be in up to 14 different states. The ready-queue implementation resorts to a circular list per priority level with a dedicated pointer to the following thread ready on each list. This approach facilitates the scheduling algorithm as it does not need to iterate over any list to determine the next thread. RIOT also allows for the dynamic creation and scheduling of threads. This OS also offers traditional implementations of mutexes, semaphores, mailboxes, and message queues. Notably, the mutexes do not offer any preventive mechanism toward priority inversion. The OS further guarantees the execution of kernel tasks and inter-process communication to fulfill realtime requirements. Additionally, this OS implements a complete IoT stack named gnrc , which supports new protocols such as 6TiSCH, the IPv6 over the TSCH mode of IEEE 802.15.4 standard. 4.1.3 Zephyr Zephyr is an ongoing project from the Linux Foundation designed for resource-constrained systems [124]. One of the notable strengths of Zephyr is its emphasis on security. It incorporates features like memory protection, hardware-based isolation, secure boot, and support for cryptographic protocols. These provisions contribute to safeguarding sensitive data and ensuring the integrity of IoT systems. Regarding networking features, Zephyr integrates its own network stack implementation, including support for lowpower devices requiring IEEE 802.15.4 or BLE radio interfaces to communicate. Therefore, the 6LoWPAN adaption layer is also supported to provide IPv6 connectivity, leading to a highly modular and flexible network stack implementation. Zephyr follows a multi-threading programming model with a microkernel-based architecture. This OS implements a preemptive priority-based scheduling mechanism following a descendent-priority scheme, with eight possible states per thread. Thread management resorts to a multi-list ready-queue, with a list per priority level. Zephyr provides several synchronization and IPC mechanisms, including mutexes, semaphores, message queues, and mailboxes. Notably, Zephyr implements priority inheritance algorithms to prevent deadlocks when using mutexes. 33 CHAPTER 4. OPERATING SYSTEMS ANALYSIS 4.1.3.1 FreeRTOS FreeRTOS, short for Free Real-Time Operating System, is a widely used open-source RTOS designed to provide versatility and robustness in the embedded systems domain. FreeRTOS does not provide a network stack implementation compatible with low-end IoT radios. However, due to its popularity in embedded systems development, there are third-party network stacks that support FreeRTOS, e.g., lwIP. FreeRTOS employs a minimalist microkernel architecture characterized by its lightweight design and efficient resource utilization. This OS offers a rich set of features tailored for real-time systems, including preemptive and cooperative multitasking, priority-based scheduling, synchronization mechanisms like semaphores and mutexes, dynamic memory allocation, and inter-process communication via message queues. FreeRTOS organizes the active threads in a single linked list, meaning accessing a specific thread requires longer processing times. 4.1.4 Summary Table 2 summarizes the main defining characteristics of the OSs mentioned above, including the programming model, kernel architecture, scheduler, supported network stack, and CPU architectures. Contiki-NG distinguishes itself by following a purely event-driven programming model with a cooperative scheduler. Furthermore, Contiki is the only OS that does not yet support the RISC-V architecture. Both RIOT and Zephyr are implemented as microkernels with priority-based schedulers. Despite their similarities, these two OSs differ in their approach and implementation of several kernel services. For instance, Zephyr offers priority inheritance mechanisms for mutexes, while RIOT does not. Lastly, FreeRTOS is the only OS that does not support a native network stack, which is detrimental to developing IoT applications. Table 2: OSs feature comparison. OS Architecture Programming Model Scheduler Network Support Supported Architectures Contiki-NG Monolithic Event-driven Cooperative uIP and RIME AVR, MSP430, Arm Cortex-M RIOT Microkernel Multithreading Preemptive Priority-based gnrc AVR, MSP430, Arm Cortex-M, x86, RISC-V Zephyr Microkernel Multithreading Preemptive Priority-based Native implementation AVR, MSP430, Arm Cortex-M, x86, RISC-V FreeRTOS Microkernel Multithreading Preemptive Priority-based none Arm Cortex-A, Arm Cortex-M, Arm Cortex-R x86, RISC-V 4.2 Evaluation Since the ChamelIoT framework intends to offload kernel services to hardware, it is essential to understand how the most common IoT OSs implement these services and how the connectivity with other devices impacts them. Furthermore, evaluating OSs with different characteristics helps in understanding which services can be offloaded to hardware and what conditions are required for an OS to benefit from hardware acceleration. 34 4.2. EVALUATION Taking this into consideration, a series of experiments were conducted on three different OSs: Contiki, RIOT, and Zephyr. Contiki is considerably different from the other OSs since it only allows a cooperative scheduling algorithm and follows a monolithic architecture. Despite RIOT and Zephyr having similar characteristics regarding architecture, programming model, and scheduler, they present different degrees of implementation complexity. For example, RIOT’s primary targets are low-end devices, while Zephyr can also be deployed on high-end devices. Lastly, FreeRTOS was left out of this evaluation because it does not provide native support for a network stack. While third-party software could have been used, the goal of this evaluation is to understand the impact of a working network stack on the kernel services, and thirdparty software tends not to leverage the services provided by the OS optimally. The experiments realized assessed memory footprint, performance, real-time, and power consumption. 4.2.1 Experimental Setup All experiments were performed on an STM32L476G-DISCOVERY, connected to a TI CC2520 radio through a Serial Peripheral Interface (SPI). This development board features an Arm Cortex-M4 processor running at a clock speed of 80MHz. The Arm Cortex-M4 is one of the most widespread microprocessor architectures in the embedded systems market, and, therefore, it is widely supported by the developers community. The radio in this setup supports the IEEE 802.15.4 standard, one of the most widely used protocols in IoT applications such as home automation and industrial monitoring systems [128, 129]. Such systems are expected to have several nodes connected to each other and the Internet. Due to the intrinsic difficulty in recreating a big-scale network, a smaller topology composed of three nodes was deployed, as depicted in Figure 11. This setup evaluates a device under test on different network conditions. Despite simple, it still recreates the desired scenario where a node in operation receives random connections from surrounding nodes, and the incoming data is directed to the node itself or another node in the network. Node 1 represents the device under test and establishes a connection with both other nodes. However, Node 2 and Node 3 cannot directly communicate with each other. Thus, they rely on the tested node to forward their message to its destination. Given that the nodes are role-independent, the communication to and from the device under test is established through a User Datagram Protocol (UDP) connection without a specific protocol at the application layer. As a result, the entire network is being used with the following configuration: UDP, IPv6/RPL, 6LoWPAN, IEEE 802.15.4 (MAC and PHY). Whenever Node 1 receives a message from the network, it must accept, reject, or forward it. Figure 11: Network topology used in the experiments. Experiments were performed by sending a fixed-size UDP message of 24 bytes (which corresponds to 58 bytes of the MAC Data Frame) through a socket on local/remote ports 8080/8081. The number of 35 CHAPTER 4. OPERATING SYSTEMS ANALYSIS frames sent to the device under test was kept at an average rate of 230 packets per second, reaching a point where the network was almost overloaded, but the receiving node could still attend to each packet being received. All the evaluated OSs already supported the target board, and only slight modifications were required to run them. Furthermore, the integration of the radio driver with the network stack, as well as with the benchmark suit to each OS, just required a small porting effort. Each OS was kept with its default or suggested settings for a similar application to the one under evaluation. Therefore, the conducted benchmarks evaluate each OS as an off-the-shelf solution, representing the conditions the developers will expect when using each OS without modifications. In all performed experiments, the network stack is always initialized, whether network traffic exists or not. Depending on the stack implementation and its integration with the kernel, there may be threads related to the network stack initiated before each benchmark starts executing. The approach allows the understanding of the stack influence, even if it is idle while benchmarking each OS. Additionally, based on Figure 11, four different states of the network were used: •Idle: In this state, there is no traffic in the network, and only essential tasks are being executed. It is expected that the system does not perform any network-related tasks. •Accept: All the network traffic is directed to Node 1. Data must be accepted and processed accordingly, requiring the intervention of all the network stack layers. •Reject: Contrary to the previous test case scenario, all the traffic is intended to be rejected, e.g., the data destination is another node and must not be forwarded. In this case, the packet is rejected as soon as possible (it can be done either at the MAC or upper layers). •Forward: This last test assumes that the packet’s destination is unreachable by the original sender but belongs to the same network, and the selected routing scheme is aware of this neighbor’s existence. The packet is forwarded before reaching the stack’s application layer in such cases. The Thread-Metric Benchmark Suite [130] was used to measure each OS’s performance. This suite aims to evaluate the most common RTOS services and interrupt processing mechanisms, encompassing a total of eight benchmarks: •Basic Processing (T1): A single thread performs mathematical operations in a loop and counts the number of times the operation is performed. This serves as the baseline for the remaining tests. •Cooperative context switching (T2): Five threads execute concurrently, each counting the number of times they run. The result is the sum of all counters from each thread. •Preemptive context switching (T3): Consists of five threads with different priorities, each resuming the following thread with a higher priority before suspending and counting the number of times they run. The result is the sum of the count values of each thread. 36 4.3. DISCUSSION extensive operations of context-switching. On the other hand, RIOT stands in the middle, balancing its performance with the advantages of microkernel architecture. 4.3.2 Real-Time Evaluation Regarding determinism, most systems’ initialization and cleanup stages can be neglected since these occur only once. Hence, it is important to focus on analyzing the kernel functions used constantly throughout the system’s life cycle. Moreover, network traffic significantly affects the determinism of all OSs, given that the system is continually being interrupted when the radio interface receives new packets. Additionally, on all OSs, the network stack is implemented monolithically with the kernel, which can cause interference with other OS services. 4.3.3 Memory and Power Evaluations The resources consumed by the OS are directly related to the system’s power consumption. Memory is usually the most power-consuming component on embedded devices, which is reflected in the performed evaluations. However, OSs primarily implemented with static resources usually use more memory, significantly increasing their power consumption. Contrarily, using dynamic management of resources, despite increasing their memory footprint, can be a determining factor in reducing the energy consumption. 4.3.4 Discussion Table 6 depicts a qualitative comparison of the three evaluated OSs. This comparison considers the metrics discussed previously according to the network state. Contiki-NG offers the best performance results, while RIOT provides higher time predictability. Despite Zephyr seemingly being lacking compared to the other two OSs, Zephyr focus on other areas that were not evaluated, e.g., security. Table 6: Qualitative comparison of the evaluated OSs. OS Network State Performance Time Predicatability Memory Footprint Power Consumption Contiki-NG Idle # Active # # RIOT Idle # Active # Zephyr Idle # # ## # Active ## ## # Even though Contiki-NG presents better overall results, this OS is not suitable for more dynamic and state-of-the-art IoT systems because of its programming model. Expecting every thread to be statically defined at compile time inhibits the system from dynamically answering the environment needs, e.g., creating new threads to attend different nodes. Furthermore, a fully cooperative scheduling algorithm 43 CHAPTER 4. OPERATING SYSTEMS ANALYSIS prevents the system from prioritizing critical tasks, which could lead to missing important timing deadlines. Considering that not many applications can be developed with a static number of threads and that real-time is not assured with Contiki, ChamelIoT will be aiming to enhance this OS with hardware acceleration. Based on the evaluation and study of these OSs, ChamelIoT should aim to accelerate hardware OSs that follow a multithreading programming model and have a microkernel architecture. In the IoT, where an unknown number of devices can be connected, a system must be capable of dealing with varying amounts of requests, which only a multithreaded OS can do. Furthermore, OSs designed with a microkernel architecture are modular by nature, which eases the possible replacement of a software service with a hardware-accelerated one. For these reasons, FreeRTOS will also be one of the main IoT OSs targeted by ChamelIoT, along with RIOT and Zephyr. FreeRTOS has characteristics similar to those of the other two, but it provides variation in its implementation of most kernel services. Furthermore, FreeRTOS also supports RISC-V architectures, on of the most notable CPU architectures in reconfigurable IoT devices. 44 5 ChamelIoT Framework The ChamelIoT framework aims to provide agnostic hardware acceleration of kernel services to IoT reconfigurable devices. Nonetheless, maximizing adoption across the IoT field is of the utmost importance to ChamelIoT. The envisioned framework encompasses distinct components that interact with the whole system stack and enable developers to easily deploy OS hardware acceleration to their system. Furthermore, ChamelIoT intends to provide enough configurability points so that multiple IoT OSs can use a given hardware kernel service without requiring developers to have extensive knowledge of implementation details. This chapter details the ChamelIoT framework from a high-level perspective, expanding on what challenges it addresses and how it intends to overcome them. Section 5.1 covers ChamelIoT’s main objectives, goals, design choices, target platforms and OSs, and scope. Section 5.2 describes the ChamelIoT framework architecture, detailing the three main framework components. The insights revealed in this chapter resulted in the following publications: M. Silva, T. Gomes and S. Pinto, ”Leveraging RISC-V to build an open-source (hardware) OS framework for Reconfigurable IoT devices”, in Fifth Workshop on Computer Architecture Research with RISC-V (CARRV 2021), Valencia, Spain, 2022 M. Silva, T. Gomes and S. Pinto, ”Agnostic Hardware-Accelerated Operating System for Low-End IoT,”2022 IEEE 28th International Conference on Embedded and Real-Time Computing Systems and Applications (RTCSA), Taipei, Taiwan, 2022, pp. 21-30, doi: 10.1109/RTCSA55878.2022.00009 5.1 Overview With the goal of designing ChamelIoT as an agnostic framework for hardware acceleration of kernel services in reconfigurable IoT platforms, it is necessary to identify the main challenges similar solutions face, how ChamelIoT intends to overcome these challenges, ChamelIoT’s main goals, and clearly define its scope. 45 CHAPTER 5. CHAMELIOT FRAMEWORK 5.1.1 Challenges As supported by the literature review in Chapter 3, offloading OS kernel services to hardware is not a new endeavor. However, hardware-accelerated OSs have yet to gain traction in the industry and the IoT. These OSs have not aimed to reach a broader range of devices and applications. Instead, they focused on goals like maximizing performance or minimizing resource consumption. From the state-of-the-art analysis, three main obstacles that prevent the adoption of kernel acceleration in hardware were identified. Software Interface: The software API provided by each OS influences the amount of knowledge the application developer requires regarding the whole system. Some hardware-accelerated OSs provide their custom-built and unique API, which increases the development and learning curves since it requires developers to learn a complete set of new APIs and develop the application from scratch. Considering that time-to-market is a driving force for the IoT industry, the additional development time imposed by the learning curve of these hardware OS APIs compels the industry to opt for COTS solutions. To solve these issues, other hardware-accelerated OSs use compatibility standards like POSIX as a basis for their APIs, allowing for better portability for legacy Linux-based applications and the development of new applications due to the community’s overall familiarity with POSIX-like APIs. Lastly, the remaining OSs’ APIs were designed to mimic software IOT OSs’ APIs and replace them seamlessly. This approach allows developers to keep using the OS they are familiar with since the compiler or other external tools select which APIs to use. This method can also enable legacy applications to use hardware acceleration since no modification is required at the application level. Target Architecture: The processing system in reconfigurable platforms provides a limited number of interfaces usable by external peripherals and devices, consequently limiting the methods for integrating hardware accelerators with the core. Furthermore, not all Microcontroller Units (MCUs) are designed with hardware accelerators in mind, consequently reducing the number of processing systems that can be used for OS hardware acceleration. Similarly to the software interface, developers also have a degree of familiarity with some processor families and architectures, which results in these being preferred by the IoT industry. Considering these facts, soft-core MCUs are well-suited for reconfigurable IoT systems since they can be modified to include and accept tightly- and loosely-coupled hardware accelerators. Hardwareaccelerated OSs are usually developed targeting a single CPU or architecture, which limits their overall usability and portability, hindering their adoption. The problem worsens when the accelerators are tightlycoupled to the CPU and require modifications to the datapath. This fact makes the hardware replication in mass a challenge, as it involves redesigning the silicon, which is nearly impossible with proprietary CPU architectures, often behind a paywall. To tackle this issue, some hardware OSs are exploring open ISAs, e.g., RISC-V, as their foundation due to their availability and openness. This approach future-proofs the system and thus enhances its scalability and possible adoption. Application Suitability: Due to the heterogeneity of the IoT ecosystem, the myriad of different systems presents a variety of requirements and constraints. Notably, closer to the edge, each application is progressively more constrained regarding energy consumption and form factor, as these applications are 46 5.1. OVERVIEW often small sensors or actuators powered by batteries. Therefore, reconfigurable IoT edge platforms ideally use the smallest FPGA available. To cope with this, hardware-accelerated OSs must provide enough configurability points to fit within the hardware constraints. As such, the OS should allow the user to modify kernel parameters, e.g., number of states or priorities, or entirely remove unused features. This is only possible if the hardware-accelerated OS allows such configurability by design. This is not always true, as various accelerators in the literature are tailored to a specific application or OS. The challenges above hinder the adoption rate of hardware-accelerated OSs in the IoT market. These challenges stem from the developer’s unfamiliarity and inexperience with hardware acceleration in the IoT ecosystem. Therefore, the ideal way to overcome these roadblocks is to minimize the required knowledge to use the accelerators and allow developers to implement their applications as they are used to while transparently deploying hardware acceleration. ChamelIoT provides a framework for accelerating kernel services in hardware in an agnostic fashion, allowing applications from different IoT OSs to run unmodified. To do so, ChamelIoT presents the following solutions: • Regarding the Software Interface , ChamelIoT offers a minimalist set of APIs that implement lowlevel communication with the hardware accelerator to execute well-defined kernel services. Each function can be mapped to a kernel service in software and is replaced at compile-time, providing the benefits of hardware acceleration to any IoT OS. Since only kernel internals are modified, the application-level code is kept intact. Considering this, developers can leverage ChamelIoT without the need to learn any new set of APIs or the workings of an OS, thus making it easier to use hardware acceleration. • The Target Architectures of ChamelIoT are architectures deployed in reconfigurable logic. Leveraging RISC-V, an open-source ISA, and its available implementations allows ChamelIoT to explore multiple avenues of hardware acceleration, like providing the same accelerator as both tightly- and loosely-coupled. Furthermore, with RISC-V gaining popularity in the IoT industry, there is inherent scalability for hardware accelerators implemented with the same foundation as these emerging platforms. • Lastly, ChamelIoT offers multiple configurability points to ensure Application Suitability . The user can opt to: (1) have the accelerator either tightly- or loosely-coupled, (2) modify multiple kernel parameters, e.g., number of threads, priorities, and states, (3) configure feature-specific implementations like the type of semaphores or if mutexes have priority inheritance and (4) add or remove components like mutexes, semaphores, or message queues as needed. All these configurations are made before the synthesis and deployment of the accelerator, enabling the user to fully customize the system and avoid unnecessary resource consumption. 47 CHAPTER 5. CHAMELIOT FRAMEWORK 5.1.2 Goals Considering the challenges faced by hardware-accelerated OSs, ChamelIoT provides hardware acceleration to several kernel services, which can replace the existing services of three different software IoT OSs without requiring modifications to the application’s interface. The main goals and benefits of the ChamelIoT encompass: Real-Time and Determinism: As one of the main requirements of low-end IoT devices, ChamelIoT must provide hard real-time guarantees and bounded Worst-Case Execution Time (WCET). Moreover, predictability shall not be affected by any configuration on the hardware accelerator, e.g., the number of priorities, the total number of mutexes, or any application-specific detail like the number of waiting threads or their priorities. Performance: A hardware-accelerated system must perform better than its software-centric implementation. ChamelIoT must ensure higher performance, regardless of coupling approach or configuration, by executing kernel services faster than their respective standard software version, independent of the accelerated IoT OS. Flexibility: Without enough customization, it is impossible to guarantee that a hardware accelerator is not using unnecessary resources. The framework must provide several configurability points to modify ChamelIoT so that the accelerator behaves precisely like the target IoT OS while minimizing resource consumption. Agnosticism: In order to lessen the learning curve associated with hardware-accelerated OSs, the ChamelIoT framework must allow the user to transparently run unmodified applications of any supported IoT OS. This is achieved by only modifying the kernels’ internals and leaving the user interface untouched when using the hardware accelerator. 5.1.3 Scope ChamelIoT’s goal is to accelerate kernel services in hardware and explore various coupling approaches. As such, it requires a platform with reconfigurable technology and a CPU architecture that enables accelerators to be integrated in both loosely- and tightly-coupled fashion. While most platforms enable a loosely-coupled approach, adopting a tightly-coupled approach requires a solution that allows for CPU modifications, which makes RISC-V-based platforms the ideal solution. Considering this, the ChamelIoT framework was developed for the Arty A7-100T board, which was one of the few available with direct support for the Rocket Core, and some IoT OSs already supported it. The Arty A7-100 board comprises a open-source SiFive E300 [132], featuring an E31 Coreplex RISC-V core (RV32-IMAC), which supports atomic (A) and compressed (C) instructions for higher performance and better code density, respectively. This core was created using the Rocket Chip generator. Its main characteristics include a single-issue in-order 32-bit pipeline (with a peak sustained execution rate of one instruction per clock cycle) and a single L1 instruction cache. The E300 platform also includes a 48 5.1. OVERVIEW Platform-Level Interrupt Controller (PLIC), a debug unit, several peripherals, and two TileLink interconnection interfaces (used to interface custom accelerators). Supported by the Chapter 4 conclusions, the OSs available for low-end IoT systems present a wide variety of them regarding implementation details and features supported. ChamelIoT currently supports RIOT, Zephyr, and FreeRTOS, as they present enough variability regarding the main design points and extensive popularity and applicability in IoT applications. The three OSs share similar design principles, e.g., they implement a preemptive priority-based scheduler and multi-queue thread management, which are also common characteristics of other low-end IoT OSs [26, 120, 121, 133]. Nonetheless, the accelerator needs to accommodate several distinctions in their design choices, as summarized in Table 7. Table 7: Key features of each supported OS. OS RIOT Zephyr FreeRTOS Thread States 14 8 4 Running State 11 6 3 Ready State 12 7 2 Priority Scheme Descending Descending Ascending Mutexes Yes Yes (with Priority Inheritance) Yes (with Priority Inheritance) Semaphores Yes Yes Yes Message Queues Yes Yes Yes Mailboxes Yes Yes No Lastly, the kernel services implemented by the ChamelIoT framework are present across most IoT OSs. They can be implemented and deployed as hardware accelerators without changing the behavior of the software OS. On the other hand, some OS services, already deployed in hardware by works in the literature, require more intrusive implementations capable of changing the OS execution. Consequently, forcing the developer to adapt the application code, compelling the developer towards a steeper learning curve. These services are not within the scope of the ChamelIoT framework and include the following: • Interrupt Management - The most common approach to manage interrupts in hardware is to trap and process them in the accelerator, interrupting the processor through a single interface when needed. This approach reduces the priority spaces of interrupts and threads to a single one, i.e., the accelerator becomes responsible for managing both interrupts and threads sharing the same priority rules. This approach has proven to bring several benefits to performance and memory footprint [134, 135]. Notwithstanding, it heavily modifies the OS behavior and requires the developer to understand several implementation details. Thus, the agnostic characteristics of ChamelIoT would be invalidated, as applications would need to be developed while considering the unified priority space. 49 CHAPTER 5. CHAMELIOT FRAMEWORK • Time Management - Most IoT OSs rely on timers provided by the platform, e.g., system tick or general purpose timers, to manage time features like the system tick, delays, or periodic events. Migrating time-related operations to hardware would require replicating the timer logic in the FPGA fabric [31, 32], resulting in redundancy and waste of FPGA resources. Furthermore, it would also require redirecting the system timer interrupt to a different source, adding a priority space solely for the timer. It could lead developers to mistakenly assign priority to their interrupts, thus breaking the system’s expected behavior and compromising ChamelIoT’s agnosticism. • Context Switching - As the most architecture-dependent feature, implementing the context switching in hardware would require extensive modifications to the CPU datapath to accommodate the different register files and other data that need to be saved and loaded when a new thread is scheduled. Even though the migration of this feature to hardware has proven to bring performance and determinism benefits [34], a highly tailored core limits its flexibility and adaptability. A custom-built core is not easily adapted to other platforms, consequently limiting its reusability and adoption. • Memory Management - Implementing heap and thread stack management in hardware is a great ordeal that requires a vast amount of FPGA resources. Considering the constrained nature of IoT devices, especially the FPGA-based ones, this feature is ideally handled in software. 5.2 Architecture In order to achieve the goals mentioned previously, the proposed ChamelIoT framework architecture is composed of three main components: (1) a tightly- or loosely-coupled Hardware Accelerator where the kernel services are implemented in hardware; (2) an Abstraction Layer that enables the interface between the software and hardware elements in the system; and (3) a Configuration and Building tool to customize the whole system stack and abstract the user from low-level implementation details. Figure 13 depicts the three components of the ChamelIoT framework incorporated in a system based on a RISC-V reconfigurable platform, as mentioned before. Each of these components is further detailed in the following sections. 5.2.1 Hardware Accelerator This component is the central piece of the framework since it is responsible for the primary goal of ChamelIoT, the acceleration of OS kernel services in hardware. Designed with flexibility in mind, the Hardware Accelerator supports both its deployment following a loosely- or tightly-coupled approach. The tightly-coupled approach assumes that the accelerator is integrated into the core’s datapath, while the loosely-coupled approach is achieved by connecting the accelerator to the available system bus. Apart from the interfaces with the CPU and the slight modifications in the control unit, the Hardware Accelerator architecture is the same regardless of the coupling approach. Figure 14 depicts the architecture highlighting the kernel services implemented by the accelerator. These include a Scheduler, Thread Manager, 50 5.2. ARCHITECTURE IoT Operating System Abstraction Layer Unmodified Application Hardware Accelerator System bus Configuration and Building Tool CPU Reconfigurable Platform Figure 13: ChamelIoT framework overview. Mutexes, Semaphores, and Message Queues. Each kernel service is connected to a Control Unit that ensures the execution of the intended services. The following subsections further detail each kernel service and the Control Unit, while the CPU interface and major differences between coupling approaches are discussed in upcoming chapters. Control Unit Thread Manager Interfaces Hardware Accelerator Scheduler Mutexes Semaphores Message Queues CPU Memory Figure 14: ChamelIoT hardware accelerator architecture. 5.2.1.1 Control Unit The Control Unit is the main component of the Hardware Accelerator, as it ensures that all the other elements work as intended. Among its responsibilities, the Control Unit manages the interfaces with the processing system available to the accelerator. It involves processing software requests by decoding internal instruction opcodes, collecting the input data from the correct sources, commanding other modules to execute the proper functions, and outputting results in a timely fashion. Considering the limited nature of FPGA resources, the number of kernel services that can be deployed in hardware is limited. Mutexes, semaphores, and message queues are kernel elements that the software 51 CHAPTER 5. CHAMELIOT FRAMEWORK can use in multiple instances. Therefore, the maximum number of these modules available in hardware is a parameter configured by the user, and the Control Unit is responsible for managing which modules are free or busy in run time. Lastly, regardless of the coupling approach, only a single interface performs memory operations. Consequently, whenever another module, e.g., message queue, needs to execute any memory transaction, it must request the Control Unit to execute that operation. Thus making it impossible to have multiple modules concurrently trying to access the system’s memory. Additionally, the Control Unit has an internal memory buffer used by the message queues to store data that the software has not yet requested. Given that some message queue operations require direct transfer between buffer and system memory, it also becomes part of the Control Unit’s responsibility to manage the buffer to avoid concurrency in any access. 5.2.1.2 Thread Manager The Thread Manager is mainly responsible for storing and managing each thread’s data used by the software application. Intending to minimize FPGA resource utilization, the total amount of active threads allowed in the system is a configurable parameter at compile time. This configuration is one of the most impacting on resource usage because it forces the internal Thread Identifier (TID) to have a field size capable of holding the highest number of threads. Considering that the TID is a field propagated throughout the accelerator, it naturally increases resource consumption, especially considering that most of the accelerator is implemented with combinational logic. The Thread Manager uses the TID to address each thread the software application adds. It represents an index in an array of Thread Nodes , which are structures that contain thread data required by most hardware modules, as depicted in Figure 15. The data field stores a pointer to the TCB provided by the software OS. The accelerator uses this pointer to enable multiple ways for the software to access a thread, either through a TID or TCB address. Furthermore, some context in the TCB has yet to be migrated to hardware, e.g., memory management details, allowing the software OS not to be limited by what ChamelIoT implements. The scheduling algorithm uses the state and priority fields, which have variable field sizes according to additional configurability points. A single-bit field, dirty , indicates whether or not that index is available. When a thread is added to the system, the software should provide the previous fields, and the hardware determines which index is free, then sets the dirty bit and outputs its index. The Thread Manager must only clear the dirty bit to remove a thread. The last field in the Thread Node is named next , and it is used to implement linked lists utilized in the queue of threads ready to be scheduled, henceforth referred to as ready queue. Since all thread data is stored and handled by the Thread Manager, it is also part of this component’s responsibility to manage the state of each thread and the ready queue. The ready queue implemented in hardware follows a multiqueue system, with a circular linked list for each priority level, leveraging the next field in each node to point to the following thread with execution rights with the same priority. 52 6.1. LOOSELY-COUPLED HARDWARE ACCELERATOR Control Unit Thread Manager TileLink Reg Map Node Hardware Accelerator Scheduler Mutexes Semaphores Message Queues TileLink DMA Node CPU Memory Figure 17: Loosely-coupled hardware accelerator architecture. In the TileLink Register Map node, a memory address range has to be assigned to the accelerator, which determines the addresses the software can use to communicate with the hardware. In this range, a register file is defined according to the inputs and outputs required for each kernel service. Each register is composed of a 32-bit word and has a specific address accessible through load and store instructions. Additionally, the TileLink DMA node grants the accelerator access to the system memory through burst operations. These operations are done in bursts with predefined sizes, always in powers of two (2n) numbers, which limits finer-grained memory transactions. Figure 18 depicts the Register Map available in the Hardware Accelerator. Once the software writes the instruction register, the Control Unit starts processing the input and outputs. As such, the inputs (highlighted in green) must be written before the instruction is issued. Otherwise, the outputs (highlighted in blue) would not be correct. Consequently, the total number of software instructions required to execute a kernel service is proportional to the number of inputs and outputs plus one (writing the instruction register). On the other hand, the number of inputs and outputs of each instruction is not limited by hardware. The only step required to add more is making more registers available. Instruction I_Priority I_TCB I_TID I_State I_Mutex_ID I_Sem_ID I_MQ_ID I_MQ_addr I_MQ_size O_Priority O_TCB O_TID O_State O_Active_TID O_Active_TCB O_next_thread O_next_TCB O_Mutex_ID O_Mutex_Free O_Mutex_Error O_Sem_ID O_Sem_Free O_Sem_Error O_MQ_ID O_MQ_Free O_MQ_Error O_MQ_Busy 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x40 0x44 0x48 0x4C 0x50 0x54 0x58 0x5C 0x60 0x64 0x68 0x70 0x74 0x78 0x80 0x84 0x88 0x8C Offset Offset Register Register Figure 18: ChamelIoT loosely-coupled register map. 59 CHAPTER 6. CHAMELIOT: LOOSELY-COUPLED HARDWARE ACCELERATOR 6.2 Loosely-Coupled Abstraction Layer As mentioned above, when the accelerator is deployed loosely-coupled, it is integrated with the Rocket Core through a TileLink Register Map node. Consequently, the Hardware Accelerator is viewed as a memorymapped device with a well-defined range of addresses. The base address is a Hardware Accelerator configurability point, and the offset of each register is depicted in Figure 18. Considering this, the software application accesses the hardware accelerator via load and store instructions. An example of code used to execute these instructions is depicted in Listing 6.1, where a read and write to specific accelerator registers. In this case, the accelerator base address is 0x1001A000, and the register offsets are 0x0C and 0x48. 1#define CHAMELIOT_I_TID 0x1001A00C 2#define CHAMELIOT_O_TID 0x1001A048 3 4*(unsigned in t *) ( CHAMELIOT_I_TID ) = data ; 5value = *(unsigned i n t *) (CHAMELIOT_O_TID) Listing 6.1: Memory access example to interact with the loosely-coupled accelerator. Listing 6.2 shows the implementation of the Thread Create API, which requires two inputs (priority and TCB) and results in a single output (TID). This example illustrates how all the functions available in ChamelIoT’s Abstraction Layer are implemented for the loosely-coupled hardware accelerator. The main differences to the other functions are the registers being written and read, and the value written in the instruction register, as depicted in line 5 of Listing 6.2. The values reserved for each instruction are listed in Table 10. These values are used for both hardware accelerators regardless of the coupling approach. 1static inline unsigned long ChamelIoT_add ( unsigned long prio , unsigned long tcb ) 2{ 3reg_write32 ( CHAMELIOT_I_PRIORITY , prio ) ; 4reg_write32 ( CHAMELIOT_I_TCB , tcb ) ; 5reg_write32 ( CHAMELIOT_INST , CHMIOT_INST_ADD) ; 6 7return reg_read32 (CHAMELIOT_O_TID) ; 8} Listing 6.2: Write and read data to the loosely-coupled accelerator. 6.3 Loosely-Coupled Evaluation The ChamelIoT framework was integrated with three IoT OSs: RIOT, Zephyr, and FreeRTOS. This enabled the evaluation of the hardware accelerator’s impact on multiple systems. To assess performance and determinism, the latency of most kernel services APIs was measured through a series of microbenchmark experiments that measured the clock cycles required by the kernel services implemented by the hardware accelerator. The overall system’s performance was also evaluated using the Thread Metric benchmark suite, which provides a set of synthetic benchmarks stressing kernel features like scheduling and synchronization. 60 6.3. LOOSELY-COUPLED EVALUATION Table 10: Instruction values of each service function. Kernel Service API Instruction Value Thread Manager Create Thread 0x00 Delete Thread 0x01 Set Thread State 0x06 Get TCB 0x04 Get TID 0x07 Active TCB 0x02 Active TID 0x05 Get Data 0x03 Scheduler Schedule 0x05 Mutex Init Mutex 0x12 Lock Mutex 0x10 Unlock Mutex 0x13 Semaphore Init Semaphore 0x20 Give Semaphore 0x21 Take Semaphore 0x22 Message Queues Init Message Queue 0x30 Put Message 0x31 Get Message 0x32 Set Message Size 0x34 Each experiment was performed for the three OSs using two configurations available with the ChamelIoT framework: •SW: the software-based approach without using the hardware accelerator available, i.e., the vanilla software implementation of each OS; •LC: the loosely-coupled approach, where the multiple OSs leverage the memory-mapped hardware accelerator through memory operations. Additionally, an evaluation was performed regarding the impact of ChamelIoT on the hardware resources and power estimation required by different threads and priorities configurations, which (from empirical experiments) are the most impactful configurability points. Lastly, the memory footprint of each OS for both ChamelIoT configurations was also measured. 6.3.1 Experimental Setup The ChamelIoT Hardware Accelerator was deployed and evaluated on an Arty A7-100T, which features a Xilinx XC7A100TCSG324-1 FPGA running with a clock speed of 65MHz. The hardware accelerator is integrated into an E31 Coreplex RISC-V core (RV32-IMAC). Both the RISC-V core and ChamelIoT’s accelerator were implemented using the SiFive Freedom E300 Arty FPGA Dev Kit and synthesized in Vivado 2020.2. 61 CHAPTER 6. CHAMELIOT: LOOSELY-COUPLED HARDWARE ACCELERATOR The performance evaluation experiments targeted the RIOT v6ae67, FreeRTOS v10.2.1, and Zephyr v2.6.0-577. All software was compiled with the GNU RISC-V Toolchain (version 9.2.0), with optimizations for size enabled (-Os). Apart from OS-specific configurations such as the priority order, the hardware accelerator was kept with the same configurations for the three OSs: a maximum of 16 threads with 16 unique priorities, four different mutexes, semaphores, and messages queues (each with 16-word size, and a list of four messages). 6.3.2 API Latency The number of clock cycles required to execute the most common OS services for the two setups mentioned above was measured to assess determinism and performance. Each experiment was repeated 10,000 times for each kernel service. The results are presented by the average number of cycles, i.e., arithmetic mean (M), along with the standard deviation (SD) measured across all repetitions. Furthermore, the WCET measured across all the experiments is presented for each API. The results are discussed below. 6.3.2.1 Thread Manager and Scheduler Table 11 presents the results regarding the latency of three different APIs implemented by the Thread Manager and Scheduler: Thread Suspend , Thread Resume , and Schedule . The first two functions modify the thread state, i.e., from ready to suspended state in Thread Suspend and the other way around in Thread Resume . Whenever one of these functions is executed by a kernel, it implies adding or removing a thread from the ready queue. The system included two threads with different priorities to test these functions, where the higher-priority thread suspends itself, and the low-priority thread resumes the highpriority thread. Lastly, the Schedule function is executed at every scheduling point to select the next executing thread. In order to test this function, two threads with the same priority constantly yielded their execution time to trigger an explicit scheduling point. The LC setup on RIOT shows better performance on the Schedule API, decreasing its latency by 62.02%. Although the Thread Suspend API requires the same number of clock cycles on average, it demonstrates slightly better determinism on the LC setup. On the other hand, the Thread Resume API performs better in the SW setup compared to the hardware accelerator. Nonetheless, the LC setup offers greater determinism for this API. The number of cycles required to perform a Thread Resume on the LC configuration is over double the number required on the SW configuration. This is justified by the fact that the Abstraction Layer for the loosely-coupled accelerator requires multiple registers to be written to perform a service or access a value from the accelerator, e.g., thread priority or state. In this particular case, the original software API requires multiple accesses to the thread’s data, translating into an increasing amount of instructions in the LC setup. For the Zephyr OS, the LC configuration only shows a performance increase on the Schedule API. The latency decreased by 19.94% using the hardware accelerator, and the standard deviation was reduced to near zero. The Thread Suspend and Thread Resume APIs present significant performance decreases on 62 6.3. LOOSELY-COUPLED EVALUATION the LC setup. This happens for the same reason as in the previous OS: the Abstraction Layer for LC setup requires multiple instructions to execute a single function. Lastly, FreeRTOS has improved considerably using hardware acceleration on all three APIs. The TC setup decreases the latency by 51,70% on Thread Suspend , 43,93% on Thread Resume , and 85,08% on Schedule . Table 11: Thread Manager and Scheduler API latency. Thread Suspend Thread Resume Schedule M±SD WCET M±SD WCET M±SD WCET RIOT SW 57,06±0,68 66 59,08±1,03 75 78,99±0,37 82 LC 57,06±0,57 63 123,96±0,50 127 30,00±0,00 30 Zephyr SW 132,98±0,64 138 110,00±0,00 110 39,98±1,22 48 LC 212,04±0,63 226 293,02±0,38 299 32,01±0,19 35 FreeRTOS SW 221,67±3,09 240 107,06±0,65 113 462,35±1,68 464 LC 107,06±0,42 110 60,03±0,44 67 69,00±0,00 69 6.3.2.2 Mutexes Table 12 summarizes the results gathered for the two APIs related to Mutexes in three different scenarios. The Lock function is used when a thread attempts to acquire the mutex before entering a critical section of code. Whenever this function executes, three different scenarios can occur: (i) the mutex is successfully locked, and the current thread continues to execute; (ii) the mutex is already locked, and the priority inheritance mechanism is triggered; and (iii) the API fails to lock the mutex for external reasons, e.g., uninitialized or invalid mutex. The Unlock API is used when a thread is leaving a critical code section to release the mutex ownership. Likewise, this service can result in three different scenarios: (i) a successful unlock, where the thread keeps execution rights; (ii) the thread had its priority raised by the priority inheritance mechanism, and consequently, its priority has to be reverted, and a scheduling point is forced; and (iii) the Unlock fails due to external reasons, e.g., the mutex was not previously locked. In order to test the three scenarios, first, a single thread successfully locks and unlocks the same mutex and then tries to lock and unlock an uninitialized mutex, leading to failed attempts on both operations. Lastly, to validate the priority inheritance scenario, the following steps are executed in a loop: (1) a low-priority thread locks a mutex and resumes a high-priority thread; (2) the high-priority thread attempts to lock the mutex, triggering the priority inheritance mechanism, forcing the other thread to execute; (3) the first thread has its priority raised and unlocks the mutex, once again triggering the priority inheritance to revert its priority and schedule the next thread; and (4) the high-priority thread unlocks the mutex and suspends itself. The results for this scenario were collected in the Lock function in step 2 and the Unlock in step 3. RIOT does not support for priority inheritance in its mutex implementation, thus no results are available for this scenario. Only the fail scenario on the Lock API shows performance improvements with the 63 CHAPTER 6. CHAMELIOT: LOOSELY-COUPLED HARDWARE ACCELERATOR LC setup, with a latency reduction of 18.64% and a standard deviation reduced to zero. The success case for the Lock API and both the success and fail scenarios for the Unlock API show performance degradation with the LC configuration. In these cases, the degradation happens because, as mentioned previously, ChamelIoT’s Abstraction Layer for the LC configuration imposes an overhead on executing simple functions. For instance, locking the mutex requires four instructions, while the RIOT implementation requires only two steps if the lock is successful. The mutex APIs on Zephyr has scenarios where the execution performance is worse when using the LC hardware accelerator and Abstraction Layer. The cases are: (1) successful Lock; (2) failed Lock ; and (3) failed Unlock . Nonetheless the LC setup decreases the latency by 42.32% for the Unlock API in a successful scenario. Whenever the priority inheritance mechanism is triggered, the LC configuration performs better than the SW approach. The priority inheritance scenario shows a decrease of 21,46% and 48,68% in the latency of the Lock and Unlock functions. The priority inheritance algorithm is more computationally intensive than a regular mutex operation, which naturally will benefit more from hardware acceleration. Unlike the previous two OSs, FreeRTOS benefits from hardware acceleration in all scenarios except on failed Unlocks . In all the other scenarios, a performance increase is observed with the LC setup. In the successful and failed locks, the latency is decreased by 9.11% and 11.41%, respectively. In a successful unlock, there is a latency decrease of 11.82%. Lastly, when a mutex operation requires the priority inheritance mechanism, the LC setup shows a significant positive impact on the API performance. In these scenarios, there is a latency decrease of 89.14% in the Lock function and 64.75% in the Unlock . FreeRTOS software kernel implements its ready queues in a fashion that requires the iterative traversing of linked lists whenever a TCB is accessed. This results in longer times on functions that need to modify thread priorities and states multiple times, like the priority inheritance algorithm on mutexes. Consequently, it results in better results when the hardware accelerator is used. Table 12: Mutexes API latency. Mutex Lock Mutex Unlock Success Priority Inherit. Fail Success Priority Inherit. Fail M±SD WCET M±SD WCET M±SD WCET M±SD WCET M±SD WCET M±SD WCET RIOT SW 22,00±0,00 22 - - 65,14±3,25 72 23,96±0,33 24 - - 17,04±0,48 24 LC 49,00±00 49 - - 53,00±00 53 49,99±0,19 50 - - 50,00±0,00 50 Zephyr SW 30,02±0,27 33 70,03±0,37 75 33,03±0,21 35 78,04±0,63 88 88,96±0,58 89 12,01±0,19 15 LC 55,00±0,00 55 45,01±0,84 49 59,00±0,00 59 45,01±0,84 49 45,65±1,06 50 45,07±0,48 49 FreeRTOS SW 100,12±1,29 115 939,07±1,78 955 107,23±1,02 126 123,09±0,98 137 303,51±1,56 309 75,20±1,28 88 LC 91,00±0,00 91 102,03±0,27 105 95,00±0,00 95 90,02±0,27 93 107,03±0,29 110 90,02±0,27 93 6.3.2.3 Semaphores The Semaphores API consists of mainly two functions: Give and Take . The Give function is used by a thread to signal a semaphore that new data or resources are now available. Whenever this function 64 6.3. LOOSELY-COUPLED EVALUATION executes, it can result in two different scenarios. The first where another thread previously tried to take from the semaphore, and the current thread has to yield the execution after the Give . The second scenario is where no thread is waiting, and the current thread continues execution. The Take function is used by a thread attempting to access a resource, and similarly to the previous function, it can also result in two different scenarios: (1) the resource is already available in the semaphore, allowing the current thread to access it and keep executing; and (2) no resources are available, forcing the current thread to yield until other threads signal the semaphore. Two experiments were devised to test these APIs. One involved a single thread repeatedly using the Give and Take functions, leading to no yields being required. The other experiment required two threads, where the first attempts to take from a semaphore without resources, yielding the execution to the other thread, which signals the semaphore and yields the execution to the waiting thread. The results collected are presented in Table 13. For the RIOT OS, the LC setup performs similarly to the SW approach. Across all scenarios, the average latency differs by only three clock cycles, representing a 7% change. Nonetheless, the LC configuration decreases the standard variation on all APIs, presenting better determinism. In the Zephyr OS, the LC setup decreases the latency on Gives with threads waiting by 0,12% and 75,23% on Gives with no thread waiting. On the Take API, the latency increased to over double. The software implementation of semaphores on Zephyr is considerably optimized, especially for the Take API, to the point that hardware acceleration mostly offers better determinism. Lastly, the LC setup increases the performance in all cases for the semaphores API in FreeRTOS, except in a Take scenario with available resources. This is most evident in the scenarios that require the thread to yield execution, e.g., Gives with threads waiting where the latency decreases by 49,67% on LC setup, and Takes with no resource available where the latency decreases by 87,07% on LC setup. As mentioned previously, this is due to the fact that FreeRTOS uses more complex logic to access the ready queues. Table 13: Semaphores API latency. Semaphore Give Semaphore Take Thread Waiting No Thread Waiting Resource Available No Resource Available M±SD WCET M±SD WCET M±SD WCET M±SD WCET RIOT SW 44,06±0,68 54 45,05±0,76 57 39,02±0,38 42 39,02±0,38 42 LC 44,98±0,27 45 42,05±0,52 49 42,03±0,34 49 42,08±0,27 49 Zephyr SW 55,05±0,54 61 210,02±0,3 214 23,00±0,00 23 22,01±0,22 24 LC 54,99±0,19 55 52,02±0,27 55 50,00±0,00 50 50,02±0,27 53 FreeRTOS SW 181,03±0,44 188 102,18±1,64 119 84,99±0,06 85 758,14±1,37 773 LC 91,12±1,10 104 91,08±0,49 94 95,01±0,13 97 98,02±0,20 101 65 CHAPTER 6. CHAMELIOT: LOOSELY-COUPLED HARDWARE ACCELERATOR 6.3.2.4 Message Queues There are two main operations regarding message queues, i.e., Send and Receive . Both functions may cause threads to be suspended or resumed, depending on whether there is a thread waiting for the message or if there is a message ready. However, for the purpose of isolating memory-related operations and evaluating their performance, scenarios where threads had to yield execution were not considered. As such, the conducted experiment consisted of one thread sending a message through a message queue and another thread receiving it through the same queue. After each iteration of this process, the sending thread modifies the message contents, and the receiving thread checks the content to ensure correctness. The results are depicted in Figure 19, where the same experiment was repeated to multiple message sizes. RIOT defines a structure to represent a message which contains a pointer to the data sent/received. However, unlike standard message queue implementations, the contents of this structure are copied from the sending thread to the receiving thread, including the original pointer. Thus giving direct access to (a) Send API latency. (b) Receive API latency. Figure 19: Message queues API latency by message size. 66 6.3. LOOSELY-COUPLED EVALUATION the memory location of the original data to the receiving thread. Nonetheless, intending to maintain agnosticism, the ChamelIoT framework uses the same mechanism of copying only the structure contents on message queue operations. This results in identical results across the board, i.e., the two setups on both APIs, as the message size is always the structure size. The LC configurations on Zephyr show that up to message sizes of 16 words, the hardware setup performs better on both Send and Receive APIs. However, for longer messages, the latency is increased by 11,61% on Sends of 64 words and 10,76% on Receives of 64 words. On FreeRTOS, the LC setup shows a similar behavior where longer message sizes induce performance degradation. This setup only decreases latency for messages up to four words on both the Send and Receive functions. On longer messages, the latency increase reaches 135,25% on Sends and 145,82% on Receives . On LC setups, the performance degradation observable for bigger message sizes can be justified by the fact that the memory operations are made through a TileLink DMA node. To the best of our knowledge, this node had lesser priority in the interconnects closer to the system memory, delaying this node’s requests whenever bus contention happens. 6.3.3 Thread-Metric Benchmark Suite The Thread-Metric Benchmark Suite was used to evaluate the impact of using the ChamelIoT framework fully integrated into different IoT OSs. This synthetic suite implements several benchmarks that stress a singular kernel service separately, allowing us to understand the influence of each service when used in runtime by an IoT application. Contrarily to the latency evaluation reported previously, this benchmark suite results take into consideration all other moving parts in the system, e.g., the tick system or context switching, despite a singular service being emphasized in each experiment. The Thread-metric Benchmark Suite, as detailed in a previous chapter, contains several experiments that test different features of RTOSs. Only the benchmarks that utilize the kernel services implemented in hardware were utilized to evaluate the ChamelIoT. These include the following: 1. Basic Processing: A single thread performing mathematical operations in a loop. 2. Cooperative Scheduling: Five threads with the same priority executing concurrently, yielding in a loop. 3. Preemptive Scheduling: Five threads with increasing priorities, each resuming the next thread with a higher priority and suspending themselves in a loop. 4. Message Processing: A single thread sending a message to itself through a message queue in a loop. 5. Synchronization: A single thread giving and taking a semaphore in a loop. Thread-Metric benchmarks count the number of times each loop is repeated, presenting this count as a score after a period of time. For each experiment, the higher score means that the loop was executed 67 CHAPTER 6. CHAMELIOT: LOOSELY-COUPLED HARDWARE ACCELERATOR more times. Thus, less time was wasted in the service under test, i.e., a higher count indicates better performance. Table 14 summarizes the results gathered from running each benchmark in periods of 30 seconds. The values presented correspond to the average of 100 samples for a specific benchmark. The same experiments were performed for the two configurations (SW and LC) on each OS (RIOT, Zephyr, and FreeRTOS). RIOT performance is improved using ChamelIoT’s hardware acceleration. The Preemptive Scheduling benchmark was the only experiment where the performance was degraded. However, the performance decreased by only 1.05%. On the other benchmarks, the performance significantly improved despite the latency increase observed in earlier experiments. For instance, the LC setup increases the latency on semaphore operations. However, it presents a 25,02% performance increase. The same is true for the Message Processing benchmark, where the results obtained are 102,91% better. According to previous results, it was expected that Zephyr’s benchmarks on the LC setup would present lower scores than the SW approach because a majority of APIs showed worse performance with the hardware accelerated configuration. However, this is only true for the Preemptive Scheduling test, which has a performance degradation of 13.21%. All the others have better results, particularly the Message Processing and Synchronization benchmarks, which improve the performance by 38,60% and 11,81%. Lastly, the FreeRTOS is the only OS where the hardware configuration improves the Basic Processing benchmark. This happens because FreeRTOS scheduling is tick-based, and at every tick, the kernel executes and tries to schedule the following thread. Therefore, the Schedule API is used at every tick, unlike the other two OSs that use a tickless scheduler. Regarding the other benchmarks, the LC setup also improves the system’s performance. The performance on the Cooperative Scheduling benchmark is increased by 184,85%, and on the Preemptive Scheduling benchmark is increased by 144,19%. Despite the Message Queue APIs performing worse with the hardware accelerator, there was a performance improvement of 2.42% on the Message Processing benchmark. There are several APIs where the microbenchmark results from the previous section show latency Table 14: Thread Metric benchmark results. Basic Processing Cooperative Scheduling Preemptive Scheduling Message Processing Synchronization RIOT SW 67 902 4 014 564 1 989 564 2 154 840 7 116 828 LC 67 902 5 399 884 1 968 619 4 372 335 8 897 766 % 0.00 34.51 -1.05 102.91 25.02 Zephyr SW 63 404 1 140 718 705 373 2 827 900 6 863 450 LC 63 402 1 146 146 612 182 3 919 407 7 674 172 % 0.00 0.48 -13.21 38.60 11.81 FreeRTOS SW 59 223 1 614 329 756 498 2 293 793 3 868 494 LC 63 165 4 598 353 1 847 286 2 349 219 3 867 702 % 6.66 184.85 144.19 2.42 -0.02 68 7.2. TIGHTLY-COUPLED ABSTRACTION LAYER The opcode field identifies the coprocessor, and according to the RoCC specification, it can only contain one of four predefined values, thus limiting the number of coprocessors. The fields rd , rs1 , and rs2 specify the destination (rd) and source (rs1 and rs2) CPU registers used to transfer data with the coprocessor. The xd , xs1 , and xs2 are auxiliary fields identifying which of the previous registers have valid data. Lastly, the field funct7 is used as a user-defined opcode for each coprocessor that indicates which function has to be executed. funct7 rs2 rs1 xd xs1 xs2 rd opcode 31 25 24 20 19 15 14 13 12 11 7 6 0 Figure 22: RoCC instruction format. Listing 7.1 demonstrates how the RoCC instruction is translated into a C macro. This macro is then used in the implementation of kernel service APIs by having function arguments directly mapped to the source registers rs1 and rs2 and the return value coming from the rd register. The funct7 is used to determine which function the accelerator must execute and follows the same values as the instruction register on the loosely-coupled accelerator, as detailed in Table 10. In order to keep every service available through a single instruction, the interaction between the CPU and accelerator becomes limited to: (1) two 32-bit words being received on the coprocessor; (2) a single 32-bit word response; and (3) a maximum of 128 distinct operations. 1#define ChamelIoT_opcode 0b1011011 2#define ROCC_INSTRUCTION( rd , rs1 , rs2 , func7 ) \ 3__asm__ v o l a t i l e (” . insn r ” STR( ChamelIoT_opcode ) ” , \ 4”STR(0x7 ) ” , ” STR( funct7 ) ” , %0, %1, %2” \ 5:”=r ” ( rd ) \ 6:” r ” ( rs1 ) , ” r ” ( rs2 ) ) Listing 7.1: C macro for the RoCC instruction. Using the same example as in the previous chapter, Listing 6.2 shows the implementation of the Thread Create API. This function requires two inputs (priority and TCB) and has a single output (TID). The ChamelIoT’s Abstraction Layer for the tightly-coupled accelerator only requires a single RoCC instruction to execute the kernel service, as depicted in Listing 6.2. With all the functions in the Abstraction Layer being inline and the RoCC instruction being a C macro, each API only takes a single clock cycle to execute. 1static inline unsigned long ChamelIoT_add( unsigned long p r i o r i t y , unsigned long TCB) 2{ 3unsigned long value ; 4ROCC_INSTRUCTION( value , pr i o ri ty , TCB, CHMIOT_INST_ADD) ; 5return value ; 6} Listing 7.2: Write and read data to the tightly-coupled accelerator. 75 CHAPTER 7. CHAMELIOT: TIGHTLY-COUPLED HARDWARE ACCELERATOR 7.3 Tightly-Coupled Evaluation Following the same evaluation principles and strategy used in the previous chapter, the tightly-coupled version of the ChamelIoT framework was also integrated with three IoT OSs: RIOT, Zephyr, and FreeR- TOS. With the goal of evaluating the trade-offs between both coupling approaches, all the experiments realized for the loosely-coupled Hardware Accelerator were also reproduced in the tightly-coupled version. These experiments include the microbenchmark evaluation of several kernel services APIs, a system-wide benchmark using the Thread Metric Benchmark Suite, and measuring the hardware resource consumption, memory footprint, and power consumption. Moreover, the experimental setup described in Section 6.3.1 was used to minimize any variable and emphasize the comparison between approaches. The following sections present the results gathered for the tightly-coupled accelerator, combined with all the results from the previous chapter, to facilitate the comparison between all the OS configurations. As such, the three configurations tested were: •SW: the software-based approach without using the hardware accelerator available, i.e., the vanilla software implementation of each OS; •LC: the loosely-coupled approach, where the multiple OSs leverage the memory-mapped hardware accelerator through memory operations; •TC: the tightly-coupled approach where the hardware accelerator is connected to the core through the RoCC interface, and each OS uses the hardware acceleration through specific instructions. 7.3.1 API Latency The clock cycles required to execute the most common OS services were measured to assess determinism and performance. Each experiment was repeated 10,000 times for each kernel service. The results are presented by the average number of cycles, i.e., arithmetic mean (M), along with the standard deviation (SD) measured across all repetitions. Furthermore, the WCET measured across all the experiments is presented for each API. The following sections discuss the results collected, and, for clarity purposes, the results for the tightly-coupled setup are highlighted. 7.3.1.1 Thread Manager and Scheduler Table 18 presents the results regarding the latency of three different APIs implemented by the Thread Manager and Scheduler: Thread Suspend , Thread Resume , and Schedule . To test the two former functions, two threads with different priorities consecutively yielded execution to the other, one using the Thread Suspend function and the other using the Thread Resume . Lastly, the Schedule function was measured at every scheduling point between two threads with the same priority yielding the execution. The TC setup on RIOT presents latency decreases and improved determinism on all three APIs compared to the SW setup. The latency is decreased by 43,92% on Thread Suspend , 40,73% on Thread 76 7.3. TIGHTLY-COUPLED EVALUATION Resume , and 62,02% on Schedule . The standard deviation is also closer to zero on all kernel services, indicating better determinism. Furthermore, for the Thread Resume API, where the LC setup proved worse than the original software version, the TC configuration presents a latency decrease of 71.76% over the LC version. This performance improvement is justifiable because only a single instruction is required to execute kernel service in the hardware accelerator. Similarly, the results gathered for Zephyr also show that the TC setup can increase the performance over the SW setup. The latency is decreased by 13,51%, 1,81%, and 49,94% in Thread Suspend , Thread Resume , and Schedule , respectively. Furthermore, the standard deviation is also lower. The LC setup negatively impacted both Thread Suspend and Thread Resume APIs, whereas the TC configuration showed positive results. The TC approach decreased the latency of these two APIs in the LC setup by 45.76% and 63.14%, respectively. Despite the LC setup offering better performance than the SW version for FreeRTOS, the TC setup can further enhance the performance for all three APIs. On the TC setup, the latency is decreased by 64,30% on Thread Suspend , 60,75% on Thread Resume , and 88,10% on Schedule . Table 18: Thread Manager and Scheduler API latency comparison between approaches. Thread Suspend Thread Resume Schedule M±SD WCET M±SD WCET M±SD WCET RIOT SW 57,06±0,68 66 59,08±1,03 75 78,99±0,37 82 LC 57,06±0,57 63 123,96±0,50 127 30,00±0,00 30 TC 32,00±0,00 32 35,01±0,19 38 12,00±0,00 12 Zephyr SW 132,98±0,64 138 110,00±0,00 110 39,98±1,22 48 LC 212,04±0,63 226 293,02±0,38 299 32,01±0,19 35 TC 115,02±0,27t118 108,00±0,00 108 20,01±0,19 23 FreeRTOS SW 221,67±3,09 240 107,06±0,65 113 462,35±1,68 464 LC 107,06±0,42 110 60,03±0,44 67 69,00±0,00 69 TC 79,14±0,87 85 42,02±0,38 48 55,02±0,27 58 7.3.1.2 Mutexes Table 19 details the results gathered for the two main APIs regarding mutexes in three scenarios. These scenarios include: (1) success, where the thread locks or unlocks the mutex and keeps executing; (2) a priority inheritance mechanism is triggered to avoid a priority inversion condition; and (3) fail, where, for instance, the thread attempts locking a previously locked mutex or unlocking a free mutex. To test the success and fail scenarios, a thread successfully locked and unlocked the same mutex and then tried to lock and unlock an uninitialized mutex. Lastly, to evaluate the priority inheritance scenario, the system was configured with two threads with distinct priority levels and forcefully attempted to create a priority 77 CHAPTER 7. CHAMELIOT: TIGHTLY-COUPLED HARDWARE ACCELERATOR inversion situation. The OSs that implement priority inheritance were capable of preventing a system halt and kept executing as intended. RIOT does not support priority inheritance in its mutex implementation. As such, no results are available for this scenario. The TC configuration performs better than the LC configuration in all scenarios and better than the SW approach in all cases except the failed unlock. Compared to the SW version, the tightly-coupled accelerator presents latency decreases of 13,58% on successful Locks , 70,81% on failed Locks , and 24,79% on successful Unlocks . On average, this setup shows a minimal latency increase on failed Unlocks of three clock cycles, and presents a lower standard deviation and a better WCET. Nevertheless, failed Unlocks attempts are uncommon on most applications and usually happen due to coding mistakes. Lastly, the TC setup decreases the latency by 61.22% and 60.38% on successful and failed Locks and by 63.95% and 58.1% on successful and failed Unlocks compared to the LC setup. The TC setup on Zephyr improves the performance on both APIs and all scenarios compared to the SW setup. The Lock operations shows performance decreases of 23,35%, 67,14%, and 67,16% for the successful, priority inheritance, and fail scenarios, respectively. On the Unlock function, the latency is decreased by 84,59%, 86,50%, and 0,10% in the same scenarios. For this OS, the LC setup presented negative results for all scenarios that did not require priority inheritance. As such, the latency decrease offered by the TC setup ranges from 48.90% to 73.69%. As shown in the previous chapter, FreeRTOS benefited extensively from loosely-coupled hardware acceleration on mutex operations, especially in priority inheritance scenarios. The TC configuration further enhanced the performance, presenting latency decreases of 34.02% and 36.58% on successful and failed Locks and decreases of 46.36% and 8.35% on successful and failed Unlocks. Compared to the LC setup, the most improved case was the priority inheritance one, where the latency was reduced by 32.34% and 34.61% for the Lock and Unlock APIs, respectively. From the results gathered, TC setup improves the performance and enhances the system’s predictability. Notably, when looking at the results for each OS, the average count of clock cycles is nearly the same regardless of API or scenario. It can be very beneficial to have any function consistently executing within the same time range, regardless of outcome. Table 19: Mutexes API latency comparison between coupling approaches. Mutex Lock Mutex Unlock Success Priority Inherit. Fail Success Priority Inherit. Fail M±SD WCET M±SD WCET M±SD WCET M±SD WCET M±SD WCET M±SD WCET RIOT SW 22,00±0,00 22 - - 65,14±3,25 72 23,96±0,33 24 - - 17,04±0,48 24 LC 49,00±00 49 - - 53,00±00 53 49,99±0,19 50 - - 50,00±0,00 50 TC 19,00±0,00 19 - - 21,00±0,00 21 18,02±0,27 21 - - 20,95±0,38 21 Zephyr SW 30,02±0,27 33 70,03±0,37 75 33,03±0,21 35 78,04±0,63 88 88,96±0,58 89 12,01±0,19 15 LC 55,00±0,00 55 45,01±0,84 49 59,00±0,00 59 45,01±0,84 49 45,65±1,06 50 45,07±0,48 49 TC 23,00±0,00 23 23,00±0,00 23 24,00±0,00 24 12,02±0,27 15 12,01±0,19 15 12,00±0,00 00 FreeRTOS SW 100,12±1,29 115 939,07±1,78 955 107,23±1,02 126 123,09±0,98 137 303,51±1,56 309 75,20±1,28 88 LC 91,00±0,00 91 102,03±0,27 105 95,00±0,00 95 90,02±0,27 93 107,03±0,29 110 90,02±0,27 93 TC 66,06±0,62 73 69,03±0,45 76 68,00±0,00 68 66,02±0,27 69 69,98±1,12 75 68,92±0,68 75 78 7.3. TIGHTLY-COUPLED EVALUATION 7.3.1.3 Semaphores Regarding the Semaphore API, Table 20 presents the results for the two main functions, Give and Take , in two different scenarios each. For the Give function, the two cases depend on whether a thread is already waiting for the resource. Similarly, for the Take function, the scenarios depend on whether a resource is already available. The different scenarios on each API can result in the active thread continuing or yielding execution. These APIs were tested by having a thread repeatedly using Give and Take , leading to no yields being required. In a different experiment, two threads were used, where the first attempts to take from a semaphore without resources, yielding the execution to the other thread, which signals the semaphore and yields the execution to the waiting thread. For RIOT OS, the TC setup improves the performance on all test scenarios, unlike the LC setup that presented performance degradation, even if minimal, in three of the four experiments. The tightly-coupled accelerator decreased the latency by 72.70% and 73.30% for Gives with and without threads waiting, respectively. Regarding the Take scenarios, the latency was decreased by 66.69% and 69.16% for Takes with and without resources available, respectively. As the average count of clock cycles taken in each case was very similar between the SW and LC setups, the improvements presented by the TC configuration over the LC are also similar to the ones over the SW configuration. On Zephyr, the TC configuration improves the performance in the Give API and performs similarly in the Take API compared to the SW setup. Despite having identical times on average for the Take function, the TC setup still overperforms the LC setup. The Give API in the SW setup had the latency decreased by 63.65% and 89.05% when a thread was waiting and when it was not, respectively. Lastly, the TC setup presented latency decreases of nearly 60% across all scenarios compared to the LC configuration. Lastly, both hardware-based setups increase the performance of the semaphores API in FreeRTOS in all cases. Nonetheless, the TC setup is still a step above the LC setup in terms of performance. Compared to the LC configuration, the latency was decreased by 11.11% and 18.26% for Gives with and without threads waiting, and by 24.94% and 24.04 % for Takes with and without resources available. Table 20: Semaphores API latency comparison between coupling approaches. Semaphore Give Semaphore Take Thread Waiting No Thread Waiting Resource Available No Resource Available M±SD WCET M±SD WCET M±SD WCET M±SD WCET RIOT SW 44,06±0,68 54 45,05±0,76 57 39,02±0,38 42 39,02±0,38 42 LC 44,98±0,27 45 42,05±0,52 49 42,03±0,34 49 42,08±0,27 49 TC 12,03±0,44 19 12,03±0,44 19 13,00±0,00 13 12,04±0,33 15 Zephyr SW 55,05±0,54 61 210,02±0,3 214 23,00±0,00 23 22,01±0,22 24 LC 54,99±0,19 55 52,02±0,27 55 50,00±0,00 50 50,02±0,27 53 TC 20,01±0,19 23 23,00±0,00 23 22,00±0,00 22 22,01±0,19 24 FreeRTOS SW 181,03±0,44 188 102,18±1,64 119 84,99±0,06 85 758,14±1,37 773 LC 91,12±1,10 104 91,08±0,49 94 95,01±0,13 97 98,02±0,20 101 TC 82,01±0,19 85 77,02±0,32 82 76,04±0,48 83 79,02±0,32 84 79 CHAPTER 7. CHAMELIOT: TIGHTLY-COUPLED HARDWARE ACCELERATOR 7.3.1.4 Message Queues The testing process for the APIs concerning Message Queues involved measuring the average number of clock cycles required to Send and Receive messages of varying sizes. Figure 23 presents the results obtained when successfully sending and receiving messages between two threads through queues, validating its contents on both ends. The experiments were repeated on the three OSs and the different configurations for multiple message sizes. As mentioned in the previous chapter, RIOT does not send the message contents through the Message Queue. Instead, it copies a structure that contains a pointer to the message contents. As such, to keep the agnosticism and avoid changing the OS behavior, ChamelIoT also sends the structure via message queue. Consequently, the results are the same regardless of message size. However, the TC setup shows better performance than the other two configurations. The latency is decreased by 32.10% compared to the SW approach and by 67.24% compared to Sends on the LC setup. On the other hand, for Receives , (a) Send API latency. (b) Receive API latency. Figure 23: Message queues API latency by message size in both coupling approaches. 80 7.3. TIGHTLY-COUPLED EVALUATION the latency is decreased by 33.35% and 56.02% compared to the SW and LC setups, respectively. On Zephyr, the TC configuration shows consistent performance improvement, whereas for message sizes over 16 words, the LC performs worse than the SW configuration. On the Send API, the latency decrease ranges from 64.16% to 67.59%, and on the Receive API, it ranges from 65.33% to 71.40%. Notably, the performance improvement offered by the TC setup is uniform throughout the different message sizes. Since the hardware issues each memory access in a later stage of the pipeline, there is no instruction fetching and decoding, resulting in improvements proportional to the message size. Finally, the TC configuration on FreeRTOS offers a consistent latency decrease to both functions on message sizes up to 16 words. For bigger messages, the latency decrease goes from an average of 45,33% to 16,92% on Sends of 64 words and from an average of 44,09% to 14,31% on Receives of 64 words. While the performance improvements provided by the TC started diminishing for message sizes over 32 words, the latency still decreased for longer messages. These results are far better than the ones from the LC setup, where messages longer than four words negatively impacted performance. 7.3.2 Thread-Metric Benchmark Suite The Thread-Metric Benchmark Suite was used to evaluate the system-wide impact of the ChamelIoT framework. This suite offers several benchmarks that focus on stressing a single kernel service. Nonetheless, the score attributed to each experiment considers the application as a whole since all the kernel services require others to execute. Considering the services available in hardware, the following benchmarks were evaluated: Basic Processing, Cooperative Scheduling, Preemptive Scheduling, Message Processing, and Synchronization. Thread-Metric benchmarks count the number of times each loop is repeated. Therefore, a higher score indicates better performance. Table 21 summarizes the results obtained from running each benchmark 100 times in intervals of 30 seconds. The same experiments were performed on the supported OSs, RIOT, Zephyr, and FreeRTOS and the results regarding the TC setup are highlighted. Reflecting the microbenchmark results, the TC configuration improves the performance of RIOT when compared to the other two setups. For the Cooperative and Preemptive Scheduling benchmarks, TC setup improves performance by 46.18% and 43.95%, respectively, compared to the original software approach. The Synchronization tests show the best results for RIOT OS, where the TC improves the system by 327.17%. Furthermore, in the Preemptive Scheduling experiment, the LC setup negatively impacted the performance, while the TC configuration improved the results by 45.48%. The TC configuration on Zephyr improves the system performance up to 157.20% and 100.01% on the Message Processing and Synchronization benchmarks. For both Scheduling experiments, this configuration only offers small increments in the results, which aligns with the average latency comparison on the Thread Suspend and Thread Resume APIs. Notably, the LC setup underperformed in the Preemptive Scheduling test, while by comparison, the TC setup performed 17.03% better. 81 CHAPTER 7. CHAMELIOT: TIGHTLY-COUPLED HARDWARE ACCELERATOR Table 21: Thread Metric benchmark results comparison between coupling approaches. Basic Processing Cooperative Scheduling Preemptive Scheduling Message Processing Synchronization RIOT SW 67 902 4 014 564 1 989 564 2 154 840 7 116 828 LC 67 902 5 399 884 1 968 619 4 372 335 8 897 766 TC 67 902 5 868 623 2 863 945 9 204 934 20 295 651 Zephyr SW 63 404 1 140 718 705 373 2 827 900 6 863 450 LC 63 402 1 146 146 612 182 3 919 407 7 674 172 TC 63 403 1 248 817 716 462 7 273 403 13 727 347 FreeRTOS SW 59 223 1 614 329 756 498 2 293 793 3 868 494 LC 63 165 4 598 353 1 847 286 2 349 219 3 867 702 TC 63 166 4 834 809 2 084 595 3 641 817 4 539 084 Lastly, the FreeRTOS is the only OS where the hardware configurations improve the Basic Processing benchmark since it uses tick-based scheduling. As for the other experiments, the TC setup significantly improves the performance on the Cooperative Scheduling benchmark by 199.49% and the Preemptive Scheduling benchmark by 175.56%. Regarding the Message Processing and Synchronization experiments, the LC setup performed similarly to the SW approach. However, the TC configuration improved the performance by 58.77% and 17.33% for the two benchmarks, respectively. The TC configuration significantly improved the performance of all three IoT OSs. Compared to the loosely-coupled accelerator, on the Scheduling benchmarks, the TC setup offered an average increase of 24% across the three OSs. However, the benchmark that improved the most was the Message Processing, where the TC setup results were 83.71% better on average. Lastly, on the Synchronization benchmark, the performance was improved by 74.78%. 7.3.3 Hardware Resources The FPGA size directly impacts the system’s form factor and power consumption. Evaluating and minimizing the FPGA resource allocation is imperative for reconfigurable IoT devices. On the ChamelIoT framework, the most impactful factor on resource consumption is the total number of threads supported, as depicted in Section 6.3.4. To better understand how the two coupling approaches influence resource consumption. Tables 22 and 23 show the FPGA resource distribution for the two setups in different scenarios, one with a maximum of eight threads and eight unique priorities and the other with 16 threads and priorities. For both cases, the remaining system configurations were kept the same. For the scenario with eight threads, albeit very close, the TC setup uses fewer LUTs than the LC setup. As depicted in Table 22, the TC setup uses fewer Logic LUTs, but on the other hand, it also uses LUTs as RAM (LUTRAMs), which the LC setup does not require. The number of LUTs, including Shift-Register LUTs (SRLs), used by TC setup is 27.93% of the total amount of LUTs used by the whole 82 7.3. TIGHTLY-COUPLED EVALUATION system, identified as E300ArtyDevKitFPGAChip on the following tables. Regarding FFs usage, the TC configuration also consumes less than the LC setup, amounting to 25.82% of the system total for the TC setup and 32.98% for the LC one. The resource distribution differences in both setups are justified by their different interfaces with the CPU and the required modifications to the Control Unit to accommodate these interfaces. Furthermore, the remaining hardware elements, namely the CPU and memory, also have to adapt to the accelerator coupling approach, consequently having minimal changes to the resource allocation. The experiment with 16 threads shows increased resource utilization, as depicted in Table 23. The TC setup uses 56.70% of the system’s total LUTs, and the LC setup uses 58.54%. This was the most impacted resource by the increasing number of threads and priorities. In particular, Logic LUTs were the only resource that significantly increased its consumption. This fact reflects the effect of incrementing the TID bit size, which extensively increases the logic across the entire accelerator. Table 22: FPGA resource consumption for a system allowing 8 threads and 8 priorities. Module Logic LUTS LUTRAMS SRLs FFs RAM Blocks DSP blocks TC E300ArtyDevKitFPGAChip 21191 868 60 14430 24 2 ChamelIoT HW Accel. 5987 190 0 3726 0 0 % 28.25% 21.89% 0.00% 25.82% 0.00% 0.00% LC E300ArtyDevKitFPGAChip 22679 728 60 15635 25 2 ChamelIoT HW Accel. 7094 0 0 5156 1 0 % 31.28% 0.00% 0.00% 32.98% 4.00% 0.00% Table 23: FPGA resource consumption for a system allowing 16 threads and 16 priorities. Module Logic LUTS LUTRAMS SRLs FFs RAM Blocks DSP blocks TC E300ArtyDevKitFPGAChip 34272 868 60 12655 24 2 ChamelIoT HW Accel. 19767 190 0 2274 0 0 57.68% 21.89% 0.00% 17.97% 0.00% 0.00% LC E300ArtyDevKitFPGAChip 40875 728 60 16399 25 2 ChamelIoT HW Accel. 24388 0 0 5917 1 0 % 59.66% 0.00% 0.00% 36.08% 4.00% 0.00% 7.3.4 Power Consumption The same experimental setup from the previous chapter was used to evaluate the effect of ChamelIoT on the system’s power consumption. Using the tools provided by Vivado Design suite, it is possible to have a clearer understanding of the power consumption percentage used by the ChamelIoT Hardware Accelerator isolated from the application and its peripherals. 83 CHAPTER 7. CHAMELIOT: TIGHTLY-COUPLED HARDWARE ACCELERATOR Table 24 summarizes the results gathered for the following system configurations: (1) Rocket Core without ChamelIoT’s hardware accelerator, (2) ChamelIoT tightly-coupled to the core, and (3) ChamelIoT loosely-coupled. Both setups with ChamelIoT were evaluated while supporting 8 and 16 threads, with a corresponding number of unique priorities. The hardware-accelerated setups increase the dynamic power consumption and leave the static consumption intact. The TC setup presents a power consumption increase of 1.69% for the 8-thread configuration and 7.46% for the 16-thread configuration. With the increased number of supported threads, there is also an increase in the utilization of FPGA resources (as depicted in the previous section), which consequently leads to an increase in power consumption. Remarkably, the TC setup presents lower power usage than the LC configuration. This can be explained by the different distribution of hardware resources or by the smaller code footprint, which will be detailed in the following section. Table 24: ChamelIoT power estimation comparison between coupling approaches. Rocket ChamelIoT-TC ChamelIoT-LC 8T8P 16T16P 8T8P 16T16P Static (W) 0.099 0.099 0.099 0.099 0.099 Dynamic (W) 0.196 0.201 0.218 0.212 0.24 % 2.55% 11.22% 8.16% 22.45% Total (W) 0.295 0.3 0.317 0.311 0.339 % 1.69% 7.46% 5.42% 14.92% 7.3.5 Memory Footprint The code size plays a major role in deciding the system’s memory chip, thus becoming imperative to compare the memory footprints of both ChamelIoT configurations. To ensure a fair evaluation, the same application from the previous chapter, the Preemptive Scheduling benchmark from the Thread-Metric Benchmark Suite, was used. Table 25 outlines the results gathered for the three IoT OSs supported by ChamelIoT on all three setups (SW, LC, and TC). These values were gathered using the GNU RISC-V Toolchain, including the amount of ROM and RAM required. Since ChamelIoT’s Abstraction Layer does not initialize any variables, the RAM used remains unchanged, regardless of the coupling approach. Additionally, the hardware-based approaches resort to dedicated instructions or memory accesses to execute most kernel services. Therefore, the TC and LC setups have smaller code sizes. While RIOT presents a 5.82% decrease in the code size for the TC setup and 3.12% for the LC setup, Zephyr shows a decrease of 3.47% and 1.82% for the TC and LC setups, respectively. Moreover, FreeRTOS presents code size decreases of 4.57% on the TC setup and 3.45% on the LC setup. The TC setup offers smaller memory footprints for all experiments than the LC setup. This happens because the Abstraction 84 8.2. EVALUATION 8.2.1 Throughput The throughput in IoT networks is a important performance metric that defines data transfer efficiency within the network infrastructure. Often measured in bits per second (bps) or other relevant units, it indicates the rate at which data is successfully transmitted from source to destination across the IoT ecosystem. Achieving robust throughput is imperative for ensuring timely and reliable communication, which is vital for applications such as real-time monitoring, industrial automation, and healthcare [152]. Only the IIoT controller and the temperature sensor node were used to test the throughput on the IIoT controller, as depicted in Figure 26. Within the experiments, the IIoT controller was configured to send messages with fixed size to the sensor node and to measure the time required to send each message successfully. The time measurement was done in the controller in the pkt_handler thread. With this configuration, the medium interference on the measured time is removed, making this metric accounting for the process of creating the entire packet and all the correct headers. Lastly, several experiments were performed with multiple payload sizes. The payload is incremented in steps of five bytes up to a maximum of 90 bytes, which is close to the maximum payload for a single UDP packet in an IEEE 802.15.4 network. Temp. Sensor IIoT Controller Figure 26: Network nodes used to test the throughput. To better understand the IIoT controller throughput, the maximum packets sent per second and the total bits sent per second were measured. Figure 27 summarizes the average number of packets sent per second from the IIoT controller, according to the payload size. This metric provides a better perception of the number of messages sent from the controller to a different node, which is not often clear from an abstract metric like bits per second. As for the impact of ChamelIoT, both setups using hardware acceleration increase the average amount of packets sent regardless of payload size. The LC setup offers improvements of 5.76% to the average packets sent, gradually decreasing, with the payload increase, to a minimum of 3.98%. In absolute values, these percentages translate to sending two more packets per second in the best case and a single additional packet in the worst. On the other hand, the TC setup improves the average number of packets sent by 15.16% for bigger payloads and by 24.57% for smaller payloads. These improvements translate into sending 12 more packets per second in the best case scenario and five more in the worst. Lastly, independently of the configuration, the average amount of packets sent decreases while the payload size increases. This occurrence is justified by the increased time spent copying the payload across the network stack and sending bigger packets to the radio via SPI. Figure 28 depicts the traditional throughput measure, bits per second. It describes the effective amount of information sent through the network, disregarding the concept of message or packet, which 91 CHAPTER 8. CHAMELIOT IN AN INDUSTRIAL IOT CONTROLLER Payload Size (bytes) Packets/second 0 10 20 30 40 50 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 SW LC TC Packets sent from the IIoT controller Figure 27: Average packets per second sent according to the payload size. is helpful since the packets rarely have a constant size. The values presented are derived from the same results as the packets per second experiments. As such, the improvements ChamelIoT offers in both setups are precisely the same. However, unlike the average number of packets sent, the throughput increases with bigger payloads. Since the payload does not have to be split into multiple packets, this phenomenon is attributed to the reduction in overhead associated with transmitting a larger amount of data in fewer packets. Overheads, such as header information, acknowledgment signals, and processing time, constitute a relatively fixed portion of each packet’s size. Therefore, as the payload size increases, the ratio of data transmitted compared to the overall packet size becomes more favorable, improving throughput efficiency. Payload Size (bytes) bits/second 10000 12000 14000 16000 18000 20000 22000 24000 26000 28000 30000 32000 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 SW LC TC Throughput Figure 28: Throughput according to the payload size. 92 8.2. EVALUATION 8.2.2 Packet Delivery Ratio The Packet Delivery Ratio (PDR) is a fundamental metric used to assess the reliability of data transmission within IoT networks. The PDR is commonly defined as the ratio of successfully delivered packets to the total number of packets transmitted [153]. A high PDR signifies a robust and dependable network performance, which is crucial for applications requiring seamless and timely data delivery. In systems with limited resources, i.e., IoT edge devices, the network’s traffic heavily impacts the PDR since each packet detected and accepted by the radio will often trigger a software interrupt, disrupting the normal application execution. The Temperature Sensor node was used to send packets in fixed periods to the IIoT controller in order to test this metric, as depicted in Figure 29. The experiments realized consisted of sending a known amount of packets from the Sensor node at a fixed rate and having the IIoT controller count the packets successfully received in the pkt_handler thread. Considering that each packet will cause the radio to trigger an interrupt, increasing the frequency of packets sent to the controller can cause the system to halt. As such, evaluating the PDR with increasing transmission rates is imperative. Temp. Sensor IIoT Controller Figure 29: Network nodes used to test the PDR. The graph in Figure 30 shows the PDR for the three system configurations following an increasing transmission rate. All configurations have nearly 100% PDR up to a point where increasing the packets sent per second causes the PDR to drop abruptly. The original SW approach starts losing packets when receiving 37 packets/second and stops working at 39 packets/second. Hardware acceleration allows the system to process each packet faster, making the controller available to receive other packets sooner. Considering this, the PDR on the LC setup starts decreasing at 40 packets/second and decreases after 42 packets/second on the TC setup. The execution on these setups halts when receiving 42 and 44 packets/second, respectively. In low-end devices without much processing power, like the IIoT controller under test, unexpected interrupts can easily disrupt the expected system behavior. For the experiments realized, after the thresholds mentioned above, the system is interrupted to start receiving a new packet before finishing processing the current one. While the OS and network stack have measures to deal with occasional exceptions, consecutive interruptions can lead to cases where the system crashes entirely. For instance, when the system is interrupted while the packet is being processed by a layer in the middle of the network stack, the memory that was allocated to the packet is not freed, leading to overflows later. Therefore, reducing the time processing each packet improves the PDR. 93 CHAPTER 8. CHAMELIOT IN AN INDUSTRIAL IOT CONTROLLER Packets per second 0,00% 25,00% 50,00% 75,00% 100,00% 10 20 30 40 SW LC TC Packet Delivery Ratio Figure 30: Packet Delivery Ratio according to packet transmission rate. 8.2.3 Response Time Response time in the domain of IoT networks is an important metric characterizing the temporal efficiency of data communication processes. This metric quantifies the duration between the initiation of a request and the reception of a corresponding response, directly influencing the real-time performance of applications reliant on timely data interactions. Multiple factors can influence the response time from any system, for example, latency, physical distance, network traffic, and software and hardware heterogeneity, among others [154]. To measure the IIoT controller response time, efforts were made to minimize the impact of external elements. Consequently, the setup involved the controller and sensor node communicating with each other, while a packet analyzer captured all network packets, as illustrated in Figure 31. This setup minimizes the latency by having the nodes communicate directly and reduces network traffic because each request is issued only once per second. The physical distance between the three elements is less than a meter, which makes the time each packet spends in the physical medium negligible. A packet analyzer was used to measure the time between request and response to remove any bias toward either the controller or sensor node. Therefore, with this setup, the software application is the main element that impacts response time. The packet received must be processed and accepted by the entire network stack, and a new packet must be created and sent to the sensor node. The experiments realized consisted of periodic communications initiated by the sensor node. The IIoT controller had to receive the packet, accept and process it up to the pkt_handler thread, where a response was prepared and sent to the source node. The packet analyzer captured the communication between 94 8.3. DISCUSSION Temp. Sensor IIoT Controller 1 2 Packet Analyzer Figure 31: Network nodes used to test the response time. these two nodes, leading to the measurement of the response time through the difference between the detection of both packets. Table 27 presents the average response time from the results gathered with these experiments. Both setups using ChamelIoT result in shorter response times. The LC setup decreases the response time from 70.02 ms to 68.89 ms, an improvement of 1.61%. The TC setup further decreases the response time by 4.41%, up to 66.93 ms. Notably, both configurations with hardware acceleration also decrease the jitter in the response time, as observed by the decreasing standard deviation. Table 27: Average response time. SW LC TC Average (ms) 70.02 68.69 66.93 Standard Deviation 0.87 0.78 0.63 % - 1.61% 4.41% 8.3 Discussion This chapter presented an IIoT controller for an industrial motor machine, where the ChamelIoT framework was integrated to understand its impact at the application level. As the core of any IoT device, connectivity was the main evaluation target. Several experiments were performed to measure the throughput, packet delivery ratio, and response time. The results revealed that both the loosely- and tightly-coupled approaches on the hardware accelerator improve the system’s baseline performance. Further corroborating the results gathered in the previous chapter, the tightly-coupled approach outperformed the looselycoupled one. The system under evaluation uses RIOT, which in turn resorts to its own implementation of a network stack. This implementation uses one thread per stack layer, communicating with the neighbor layer through message queues. Contrary to a monolithic network stack, this approach is more resourceintensive regarding kernel services. Therefore, the benefits provided by the ChamelIoT framework suit the software application. Lastly, the IIoT controller is mainly used for predictive maintenance, which is 95 CHAPTER 8. CHAMELIOT IN AN INDUSTRIAL IOT CONTROLLER seeing considerable efforts to be moved to the edge in reconfigurable logic. Thus, making the hardware application also suitable for ChamelIoT. Using the ChamelIoT framework to deploy OS hardware acceleration in a preexisting application proved to be extremely easy. From the application developer’s standpoint, it only required knowledge about the application itself, i.e., the number of threads, mutexes, semaphores, and message queues being used. With this information, the developer only needs to implement a descriptive Nix recipe, and the whole system stack is built and ready to be deployed. The effortless and transparent implementation and deployment of a hardware-accelerated system, as shown in the chapter, demonstrated that ChamelIoT can be used without increasing development time and delaying the time to market. Regarding the results obtained, it is essential to recognize that the platform used plays a major role in the system’s performance. The Arty A7-100T board was running at a clock speed of 65MHz. The results obtained for the three metrics are considerably lower than the ones obtained by other systems with more powerful processors running at higher clock speeds. Nonetheless, the ChamelIoT framework was capable of providing benefits when used. Notably, the tightly-coupled approach improved the throughput performance by up to 24.57%. Furthermore, the transmission rate threshold where the PDR starts dropping was also increased. In systems that perform time-sensitive and critical operations, the capacity to receive more messages is crucial because dropping a packet could cause critical information to be lost. Thus, moving the threshold upwards is an excellent achievement for ChamelIoT. 96 9 Conclusions Accelerating kernel services in hardware is a technique with proven benefits to the performance and realtime for reconfigurable devices. Nonetheless, the applicability to industry settings has been hindered by several barriers, namely related to often targeting a single application and imposing steep learning curves on developers. Taking this into consideration, this doctoral dissertation proposes ChamelIoT, a framework that brings agnostic hardware acceleration to kernel services of IoT OSs and aims for widespread adoption and scalability. This chapter summarizes the work detailed throughout this document and draws conclusions and insights based on the achieved results and identified limitations. Section 9.1 starts by summarizing the development of the ChamelIoT framework, answering the initial research question, and outlining the major research outcomes. Section 9.2 enumerates the major academic contributions achieved with the development of ChamelIoT, while Section 9.3 discusses a set of limitations identified during this journey. Lastly, Section 9.4 points out possible directions for future research. 9.1 Summary and Conclusions With the advent of reconfigurable technology at lower costs in terms of price, resources, and energy consumption, hardware acceleration started becoming increasingly attractive in more resource-constrained devices. In the context of IoT, where there are billions of resource-constrained devices, a solution capable of bringing the benefits of hardware acceleration could be particularly disruptive. However, this technology is only available in platforms with reconfigurable fabric and often requires developers to learn advanced concepts to modify their applications. Imposing new and steeper learning curves for the system developers and integrators is not appealing to the IoT industry, where time-to-market is paramount. The main arguments presented in this dissertation were that accelerating kernel services in hardware can be done requiring modifications to application-level code, and the ubiquity of OSs among embedded systems would allow hardware acceleration to reach more devices. With this in mind, the main question that motivated the work presented in this dissertation was: How to engineer OS hardware acceleration to maximize its adoption in the IoT ecosystem? 97 CHAPTER 9. CONCLUSIONS This doctoral project presents ChamelIoT, an agnostic framework for hardware acceleration of kernel services in reconfigurable IoT devices. This framework capitalizes on the increasing penetration of reconfigurable devices in the IoT market by targeting RISC-V platforms, a hot trend in all market segments. Furthermore, ChamelIoT implements the hardware acceleration of kernel services in such a way that multiple OSs can use it, maximizing the number of systems that benefit from ChamelIoT. Lastly, the framework minimizes the learning curve by providing a set of APIs and tools that enable the port, configuration, and build of the entire system stack in an easy-to-use fashion. The first steps in developing this doctoral project were studying, analyzing, and evaluating several IoT OSs. The main goal was to determine the most widely used IoT OSs, their similarities, what kernel services are commonly implemented, and which services would benefit the most from hardware acceleration. Chapter 4 detailed a series of experiments performed on RIOT, Zephyr, and Contiki, where these were evaluated across the most prominent IoT metrics: performance, real-time, memory footprint, and power consumption. From this analysis, it was concluded that thread management, scheduling, synchronization mechanisms, and inter-process communication were the ideal kernel services to offload to hardware. Furthermore, it was concluded that the benefits of accelerating Contiki would be marginal, and thus, the well-established FreeRTOS in the overall selection of RTOS became a target to be accelerated by ChamelIoT. Secondly, the ChamelIoT framework was designed to provide hardware acceleration to the three selected IoT OSs (RIOT, Zephyr, and FreeRTOS). The framework is composed of three main components, described in Chapter 5: (1) the Hardware Accelerator, which communicates with the RISC-V core and implements kernel services identified in previous research; (2) the Abstraction Layer, which integrates with the three OSs by replacing internal service calls to communicate with the accelerator; and (3) a Configuration and Building Tool that eases the process of building the whole system stack, minimizing the knowledge required to use the hardware acceleration. These three components working in tandem must ensure that an unmodified application can be execute seamlessly and that the kernel behavior is kept intact, regardless of the OS being used. After the implementation of the ChamelIoT framework, an extensive set of experiments was realized to evaluate its impact on the three IoT OSs. Chapter 6 describes how ChamelIoT uses the infrastructure provided by the Rocket Core to integrate the Hardware Accelerator in a loosely-coupled fashion. This approach resorts to having the accelerator as a memory-mapped device, which the software can interact with using load-store instructions. The evaluation process consisted of performing several microbenchmarks on multiple kernel APIs, executing a system-wide benchmark suite (Thread-Metric Benchmark Suite), and assessing the power consumption and memory footprint. The evaluation revealed that, although some APIs did not show significant latency improvements, ChamelIoT succeeded in enhancing the performance of all three evaluated OSs. To explore the trade-offs between different coupling approaches, the ChamelIoT framework was also adapted to support the hardware accelerator in a tightly-coupled approach. Chapter 7 describes the use of the RoCC interface provided by the Rocket Core to integrate ChamelIoT’s Hardware Accelerator directly in the processor’s datapath. The results gathered show that the tightly-coupled approach performs 98 9.2. CONTRIBUTIONS considerably better across all the evaluated metrics. Nevertheless, by providing two coupling approaches, ChamelIoT increases the range of target devices. As a result, the developer is left with the decision of which configuration better suits their application by evaluating the trade-off between performance and scalability provided by the two approaches. Lastly, to demonstrate the use of ChamelIoT in a preexisting application and understand its impact at the application level, an IIoT controller was used as a case study. Chapter 8 describes the controller used and how ChamelIoT was integrated with it. The evaluation focused on measuring networking metrics (throughput, packet delivery ratio, and response time), as connectivity is the core of any IoT system. The results obtained showed that both ChamelIoT coupling approaches improve the application performance. This was achieved without any modifications to the original application code, and thus, it demonstrated the validity and applicability of ChamelIoT in a real-world application. 9.2 Contributions The work presented in this dissertation advances the state-of-the-art in several directions. The following list summarizes the most relevant contributions: •Systematic and empirical evaluation of IoT OSs: A comprehensive examination and comparative analysis of OSs for low-end IoT devices was conducted, comprising the evaluation of several metrics, including performance, determinism, power consumption, and memory footprint. The results from this evaluation revealed the strengths and limitations of popular IoT OS choices and offered valuable insights into the selection and optimization of such OSs for deployment on resource-constrained IoT devices. •Agnostic hardware acceleration of OSs: The literature suggests that OS acceleration has mainly targeted a single software OS, limiting its range of applications and possible adoption. ChamelIoT advances the state of the art by implementing several kernel services in hardware in such a way that the accelerator can be easily adapted to accelerate multiple IoT OSs with simple configurations. This approach provides extra scalability to ChamelIoT, given that several other IoT OSs follow similar design and implementation principles to the ones contemplated in this doctoral dissertation. •Multiple coupling approaches available on the same hardware accelerator: Traditionally, the existing hardware-accelerated OSs are highly tailored to a specific software OS and hardware platform, with little to no configurability available. ChamelIoT not only provides configuration points to all kernel services but also allows the user to deploy the accelerator in two different approaches, loosely- and tightly-coupled. The two setups enable developers to explore the trade-offs between scalability and performance, where the loosely-coupled approach offers better adaptability 99 CHAPTER 9. CONCLUSIONS to other platforms and architectures, and the tightly-coupled approach provides better performance at the cost of limited supported processors. •A highly configurable, adaptable, and portable framework for OS hardware acceleration: As mentioned above, most works on OS hardware acceleration are custom-made to their target application. In order to maximize the adoption of OS acceleration in hardware, ChamelIoT aims at providing multiple configurability points for the hardware accelerator, allowing the user to properly fit the accelerator to the target application. Additionally, the developed framework offers a minimalistic Abstraction Layer that can easily be used to integrate ChamelIoT with new IoT OSs. Lastly, the ChamelIoT framework provides an all-in-one solution that enables developers to build the whole system stack, from the hardware accelerator to the OS application, without requiring additional knowledge about hardware acceleration. In this context, ChamelIoT minimizes the entry barrier and lessens the learning curve imposed on developers. 9.3 Limitations Despite the contributions to the state-of-the-art, this doctoral project presents some limitations can be address with future work. The following list discusses the main limitations identified in the ChamelIoT framework: • Considering the results gathered in Chapters 6 to 8, the performance of ChamelIoT does not always justify its utilization. Using hardware acceleration comes at the cost of requiring an FPGA-based platform, and due to cost, power or size constraints, not all IoT systems can move from traditional MCUs to reconfigurable platforms. In these cases, opting for a more powerful processor can solve the performance problem at a lower cost. Furthermore, despite the improvement in performance and determinism by ChamelIoT, there are some cases where the improvement is marginally small. Despite being particularly true for the loosely-coupled accelerator, this is offset by the scalability provided by this approach as it resorts to a standard peripheral bus to be integrated with the CPU. • The Hardware Accelerator provided by the ChamelIoT framework is currently limited to Rocketbased platforms as it resorts to the Tilelink and RoCC interfaces for the loosely- and tightly-coupled approaches. Since ChamelIoT’s main goal is widespread adoption in the IoT, supporting a single architecture (Rocket Core) poses significant limitations. Nevertheless, it must be noted that Rocket Core stands out as a prominent RISC-V implementation and provides several components that could be used to easily adapt ChamelIoT to other implementations or architectures. • The IoT world is filled with a plethora of different OSs. While ChamelIoT supports the three most used OSs, countless others could be supported to extend its reach in the IoT ecosystem. However, not all OSs follow the same design principles or implement the same kernel services. For instance, 100 BIBLIOGRAPHY [39] M. Elnawawy et al. “Role of FPGA in Internet of Things Applications”. In: 2019 IEEE International Symposium on Signal Processing and Information Technology (ISSPIT) . 2019 (cit. on pp. 2, 11). [40] M. Valdés, J. Rodriguez-Andina, and M. Manic. “The Internet of Things: The Role of Reconfigurable Platforms”. In: IEEE Industrial Electronics Magazine (2017) (cit. on pp. 2, 25). [41] I. Skliarova. “A Survey of Network-Based Hardware Accelerators”. In: Electronics (2022) (cit. on pp. 2, 12). [42] X. Inc. MicroBlaze Processor Reference Guide . Version 2023.1. 2023. url: https : / / www . xilinx.com/support/documentation/sw%5C%5Fmanuals/xilinx2023%5C%5F1 /ug984-vivado-microblaze-ref.pdf (cit. on p. 3). [43] Arm. AMBA® AXI Protocol Specification . Tech. rep. Non-Confidential. Arm, 2011. url: https: //developer.arm.com/-/media/Arm%20Developer%20Community/PDF/IHI0022 H%5C%5Famba%5C%5Faxi%5C%5Fprotocol%5C%5Fspec.pdf?revision=71bd7c57- 2ed7-487b-bc3e-68c4ab56fa5f&la=en&hash=6325311012DDADF238C35A6C0FD7 34E520754F82 (cit. on p. 4). [44] SiFive TileLink Specication . Version 1.8.1. SiFive. 2018 (cit. on p. 4). [45] E. Lübbers and M. Platzner. “ReconOS: Multithreaded Programming for Reconfigurable Computers”. In: ACM Transaction on Embedded Computing System (2009) (cit. on pp. 5, 25, 103). [46] L. Pezzarossa et al. “Can real-time systems benefit from dynamic partial reconfiguration?” In: 2017 IEEE Nordic Circuits and Systems Conference (NORCAS): NORCHIP and International Symposium of System-on-Chip (SoC) . 2017 (cit. on p. 5). [47] H. Sundmaeker et al. “Vision and Challenges for Realizing the Internet of Things”. In: Cluster of European Research Projects on the Internet of Things, EU Commision (2010) (cit. on pp. 9, 11). [48] P. Malhotra et al. “Internet of Things: Evolution, Concerns and Security Challenges”. In: Sensors (2021) (cit. on p. 9). [49] A. Al-Fuqaha et al. “Internet of Things: A Survey on Enabling Technologies, Protocols, and Applications”. In: IEEE Communications Surveys Tutorials (2015) (cit. on pp. 9, 12). [50] B. Paul. “Internet of Things (IoT), Three-Layer Architecture, Security Issues and Counter Measures”. In: ICT Analysis and Applications . 2022 (cit. on p. 9). [51] B. Al-athwari and M. A. Hossain. “IoT Architecture: Challenges and Open Research Issues”. In: International conference on smart computing and cyber security: strategic foresight, security challenges and innovation . 2021 (cit. on p. 9). [52] P. Fraga-Lamas, S. I. Lopes, and T. M. Fernández-Caramés. “Green IoT and Edge AI as Key Technological Enablers for a Sustainable Digital Transition towards a Smart Circular Economy: An Industry 5.0 Use Case”. In: Sensors (2021) (cit. on p. 10). 107 BIBLIOGRAPHY [53] S. Hamdan, M. Ayyash, and S. Almajali. “Edge-Computing Architectures for Internet of Things Applications: A Survey”. In: Sensors (2020) (cit. on p. 10). [54] T. Vo et al. “Edge, Fog, and Cloud Computing: An Overview on Challenges and Applications”. In: arXiv preprint arXiv:2211.01863 (2022) (cit. on p. 10). [55] K. Dolui and S. K. Datta. “Comparison of edge computing implementations: Fog computing, cloudlet and mobile edge computing”. In: 2017 Global Internet of Things Summit (GIoTS) . 2017 (cit. on p. 10). [56] A. Biondi et al. “A Framework for Supporting Real-Time Applications on Dynamic Reconfigurable FPGAs”. In: 2016 IEEE Real-Time Systems Symposium (RTSS) . 2016 (cit. on p. 10). [57] A. M. Gharehbaghi, T. Maruoka, and M. Fujita. “A New Reconfigurable Architecture with Applications to IoT and Mobile Computing”. In: First IFIP International Cross-Domain Conference, IFIPIoT 2018 . 2019 (cit. on p. 10). [58] X. Tang et al. “A RRAM-based FPGA for Energy-efficient Edge Computing”. In: 2020 Design, Automation and Test in Europe: Conference and Exhibition (DATE) . 2020 (cit. on p. 10). [59] Microchipe. Low-Power FPGAs . url: https://www.microchip.com/en-us/products/ fpgas-and-plds/low-power (visited on 2023-12-20) (cit. on p. 10). [60] M. O. Ojo et al. “A Review of Low-End, Middle-End, and High-End Iot Devices”. In: IEEE Access (2018) (cit. on p. 11). [61] G. Verma et al. “Analysis of low power consumption techniques on FPGA for wireless devices”. In: Wireless Personal Communications (2017) (cit. on p. 11). [62] L. Ye et al. “The Challenges and Emerging Technologies for Low-Power Artificial Intelligence IoT Systems”. In: IEEE Transactions on Circuits and Systems I: Regular Papers (2021) (cit. on p. 11). [63] J. Ding et al. “IoT Connectivity Technologies and Applications: A Survey”. In: IEEE Access (2020) (cit. on p. 12). [64] J. Day and H. Zimmermann. “The OSI reference model”. In: Proceedings of the IEEE (1983) (cit. on p. 12). [65] S. Ziegler et al. “The Case for IPv6 as an Enabler of the Internet of Things”. In: IEEE Internet of Things (2015) (cit. on p. 12). [66] T. Watteyne et al. “OpenWSN: A Standards-Based Low-Power Wireless Development Environment”. In: Wiley Transactions on Emerging Telecommunications Technologies (2012) (cit. on p. 12). [67] A. Dunkels. “Design and implementation of the lwIP TCP/IP stack”. In: Swedish Institute of Computer Science (2001) (cit. on p. 12). 108 BIBLIOGRAPHY [68] T. Gomes et al. “CUTE mote, a Customizable and Trustable End-device for the Internet of Things”. In: IEEE Sensors Journal (2017) (cit. on p. 12). [69] S. Shukla et al. “Improving latency in Internet-of-Things and cloud computing for real-time data transmission: a systematic literature review (SLR)”. In: Cluster Computing (2021) (cit. on p. 13). [70] S. Abolhassani Khajeh, M. Saberikamarposhti, and A. M. Rahmani. “Real-Time Scheduling in IoT Applications: A Systematic Review”. In: Sensors (2023) (cit. on pp. 13, 14). [71] Y. Badr, X. Zhu, and M. N. Alraja. “Security and privacy in the Internet of Things: threats and challenges”. In: Service Oriented Computing and Applications (2021) (cit. on p. 13). [72] R. W. Anwar et al. “Security Threats and Challenges to IoT and its Applications: A Review”. In: 2020 Fifth International Conference on Fog and Mobile Edge Computing (FMEC) . 2020 (cit. on p. 13). [73] J. Granjal, E. Monteiro, and J. S. Silva. “Security for the Internet of Things: A Survey of Existing Protocols and Open Research Issues”. In: IEEE Communications Surveys Tutorials (2015) (cit. on p. 13). [74] X. Yang et al. “Physical Security and Safety of IoT Equipment: A Survey of Recent Advances and Opportunities”. In: IEEE Transactions on Industrial Informatics (2022) (cit. on p. 13). [75] B. Sá, J. Martins, and S. Pinto. “A First Look at RISC-V Virtualization From an Embedded Systems Perspective”. In: IEEE Transactions on Computers (2022) (cit. on pp. 13, 20). [76] J. Cheng et al. “Securing FPGAs in IoT: a new run-time monitoring technique against hardware Trojan”. In: Wireless Networks (2023) (cit. on p. 13). [77] O. Ali et al. “A Comprehensive Review of Internet of Things: Technology Stack, Middlewares, and Fog/Edge Computing Interface”. In: Sensors (2022) (cit. on p. 14). [78] A. Milinković, S. Milinković, and L. Lazić. “Choosing the right RTOS for IoT platform”. In: Infoteh Jahorina (2015) (cit. on p. 14). [79] J. Donga and M. Holia. “An analysis of scheduling algorithms in real-time operating system”. In: Inventive Computation Technologies 4 . 2020 (cit. on p. 14). [80] D. Zmaranda et al. “Using Fixed Priority Pre-emptive Scheduling in Real-Time Systems”. In: International Journal of Computers Communications & Control (2011) (cit. on p. 15). [81] S. K. Muller et al. “Responsive Parallelism with Synchronization”. In: Proceedings of the ACM on Programming Languages (2023) (cit. on p. 17). [82] N. Chong and B. Jacobs. “Formally verifying FreeRTOS’interprocess communication mechanism”. In: (2021) (cit. on p. 18). [83] K. Asanovic and D. A. Patterson. Instruction Sets Should Be Free: The Case For RISC-V . Tech. rep. EECS Department, University of California, Berkeley, 2014 (cit. on p. 19). 109 BIBLIOGRAPHY [84] A. S. Waterman. “Design of the RISC-V Instruction Set Architecture”. PhD thesis. UC Berkeley, 2016 (cit. on pp. 20, 21). [85] K. Asanović et al. “The Rocket Chip Generator”. In: 2016 (cit. on p. 20). [86] C. Celio, D. A. Patterson, and K. Asanovic. “The berkeley out-of-order machine (boom): An industrycompetitive, synthesizable, parameterized risc-v processor”. In: EECS Department, University of California, Berkeley, Tech. Rep. UCB/EECS-2015-167 (2015) (cit. on p. 20). [87] A. Garofalo et al. “PULP-NN: accelerating quantized neural networks on parallel ultra-low-power RISC-V processors”. In: Philosophical Transactions of the Royal Society A (2020) (cit. on p. 20). [88] J. Balkind et al. “OpenPiton+ Ariane: The first open-source, SMP Linux-booting RISC-V system scaling from one to many cores”. In: Workshop on Computer Architecture Research with RISC-V (CARRV) . 2019 (cit. on p. 20). [89] A. Waterman et al. “The RISC-V instruction set manual”. In: Volume I: User-Level ISA’, version (2014) (cit. on p. 21). [90] J. Bachrach et al. “Chisel: constructing hardware in a scala embedded language”. In: Proceedings of the 49th Annual Design Automation Conference . 2012 (cit. on p. 21). [91] K. H. Almotairi. “Application of internet of things in healthcare domain”. In: Journal of Umm Al-Qura University for Engineering and Architecture (2023) (cit. on p. 24). [92] L. C. Him, Y. Y. Poh, and L. W. Pheng. “IoT-based Predictive Maintenance for Smart Manufacturing Systems”. In: 2019 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA ASC) . 2019 (cit. on p. 24). [93] P. Gupta et al. “Industrial internet of things in intelligent manufacturing: a review, approaches, opportunities, open challenges, and future directions”. In: International Journal on Interactive Design and Manufacturing (IJIDeM) (2022) (cit. on pp. 24, 86). [94] M. A. Fabrício, F. H. Behrens, and D. Bianchini. “Monitoring of Industrial Electrical Equipment using IoT”. In: IEEE Latin America Transactions (2020) (cit. on p. 24). [95] D. Wang, H. Wang, and Y. Fu. “Blockchain-based IoT device identification and management in 5G smart grid”. In: EURASIP Journal on Wireless Communications and Networking (2021) (cit. on p. 24). [96] A. Ziane et al. “IoT Platform For Online Monitoring Of Renewable Energy Systems”. In: 2022 3rd International Conference on Embedded and Distributed Systems (EDiS) . 2022 (cit. on p. 24). [97] J. Liu et al. “Optimizing IoT Energy Efficiency on Edge (EEE): A Cross-Layer Design in a Cognitive Mesh Network”. In: IEEE Transactions on Wireless Communications (2021) (cit. on p. 24). [98] L. Özgür et al. “An IoT based smart thermostat”. In: 2018 5th International Conference on Electrical and Electronic Engineering (ICEEE) . 2018 (cit. on p. 24). 110 BIBLIOGRAPHY [99] P. A. Abdalla and C. Varol. “Testing IoT Security: The Case Study of an IP Camera”. In: 2020 8th International Symposium on Digital Forensics and Security (ISDFS) . 2020 (cit. on p. 24). [100] A. K. Kaiborta and S. Samal. “IoT based Voice Assistant for Home Automation”. In: 2022 4th International Conference on Smart Systems and Inventive Technology (ICSSIT) . 2022 (cit. on p. 24). [101] D. Oliveira et al. “The Future of Low-End Motes in the Internet of Things: A Prospective Paper”. In: Electronics (2020) (cit. on p. 24). [102] Á. Verdejo Espinosa et al. “Application of IoT in Healthcare: Keys to Implementation of the Sustainable Development Goals”. In: Sensors (2021) (cit. on p. 24). [103] A. Karmakar et al. “Industrial Internet of Things: A Review”. In: 2019 International Conference on Opto-Electronics and Applied Optics (Optronix) . 2019 (cit. on p. 24). [104] B. K. Sovacool and D. D. Furszyfer Del Rio. “Smart home technologies in Europe: A critical review of concepts, benefits, risks and policies”. In: Renewable and Sustainable Energy Reviews (2020) (cit. on p. 24). [105] M.-Y. Chen and H.-T. Wu. “Real-time intelligent image processing for the internet of things”. In: Journal of Real-Time Image Processing (2021) (cit. on p. 24). [106] C. Ye. “Real-time Image Edge Detection System Design and Algorithms for Artificial Intelligence FPGAs”. In: 2022 International Conference on Artificial Intelligence of Things and Crowdsensing (AIoTCs) . 2022 (cit. on p. 24). [107] J. J. Rodríguez-Andina, M. D. Valdés-Peña, and M. J. Moure. “Advanced Features and Industrial Applications of FPGAs—A Review”. In: IEEE Transactions on Industrial Informatics (2015) (cit. on pp. 24, 87). [108] R. Narayanan and C. S. R. Murthy. “A Probabilistic Framework for Protocol Conversions in IIoT Networks With Heterogeneous Gateways”. In: IEEE Communications Letters (2017) (cit. on p. 24). [109] N. Kumar, M. Rawat, and K. Rawat. “Software-Defined Radio Transceiver Design Using FPGA- Based System-on-Chip Embedded Platform With Adaptive Digital Predistortion”. In: IEEE Access (2020) (cit. on p. 25). [110] N. Marriwala, O. P. Sahu, and A. Vohra. “FPGA-Based Software-Defined Radio and Its Real-Time Implementation Using NI-USRP”. In: Field-Programmable Gate Array . IntechOpen, 2017 (cit. on p. 25). [111] N. P. Ghanathe et al. “MAFIA: Machine learning acceleration on FPGAs for IoT applications”. In: 2021 31st International Conference on Field-Programmable Logic and Applications (FPL) . 2021 (cit. on p. 25). [112] R. Chen et al. “MLoF: Machine Learning Accelerators for the Low-Cost FPGA Platforms”. In: Applied Sciences (2022) (cit. on p. 25). 111 BIBLIOGRAPHY [113] T. Gomes et al. “FAC-V: An FPGA-Based AES Coprocessor for RISC-V”. In: Journal of Low Power Electronics and Applications (2022) (cit. on p. 25). [114] A. Shrivastava et al. “High performance FPGA based secured hardware model for IoT devices”. In: International Journal of System Assurance Engineering and Management (2022) (cit. on p. 25). [115] E. Flamand et al. “GAP-8: A RISC-V SoC for AI at the Edge of the IoT”. In: 2018 IEEE 29th International Conference on Application-specific Systems, Architectures and Processors (ASAP) . 2018 (cit. on p. 25). [116] M. Costa et al. “Shifting capsule networks from the cloud to the deep edge”. In: ACM Transactions on Intelligent Systems and Technology (TIST) (2022) (cit. on pp. 25, 86). [117] T. Fritzmann, G. Sigl, and J. Sepúlveda. “RISQ-V: Tightly coupled RISC-V accelerators for postquantum cryptography”. In: IACR Transactions on Cryptographic Hardware and Embedded Systems (2020) (cit. on p. 25). [118] P. D. Schiavone et al. “Slow and steady wins the race? A comparison of ultra-low-power RISC-V cores for Internet-of-Things applications”. In: 2017 27th International Symposium on Power and Timing Modeling, Optimization and Simulation (PATMOS) . 2017 (cit. on p. 25). [119] N. Maruyama, T. Ishihara, and H. Yasuura. “An RTOS in Hardware for Energy Efficient Softwarebased TCP/IP processing”. In: 2010 IEEE 8th Symposium on Application Specific Processors (SASP) . 2010 (cit. on pp. 26, 28). [120] O. Hahm et al. “Operating Systems for Low-End Devices in the Internet of Things: A Survey”. In: IEEE IoT Journal (2016) (cit. on pp. 31, 49). [121] T. B. Chandra, P. Verma, and A. K. Dwivedi. “Operating Systems for Internet of Things: A Comparative Study”. In: Proceedings of the Second International Conference on Information and Communication Technology for Competitive Strategies . 2016 (cit. on pp. 31, 49). [122] A. Dunkels, B. Gronvall, and T. Voigt. “Contiki - a lightweight and flexible operating system for tiny networked sensors”. In: 29th Annual IEEE International Conference on Local Computer Networks . 2004 (cit. on p. 32). [123] E. Baccelli et al. “RIOT: An Open Source Operating System for Low-End Embedded Devices in the IoT”. In: IEEE IoT Journal (2018) (cit. on pp. 32, 33). [124] Zephyr Project. Zephyr OS . url: https://www.zephyrproject.org/ (visited on 2019-02- 19) (cit. on pp. 32, 33). [125] M.-Y. Zhu. “Understanding FreeRTOS: A Requirement Analysis”. In: (2011) (cit. on p. 32). [126] A. Dunkels. uIP - A Free Small TCP/IP Stack . Tech. rep. 2002 (cit. on p. 32). [127] G. Oikonomou et al. “The Contiki-NG open source operating system for next generation IoT devices”. In: SoftwareX (2022) (cit. on p. 32). 112 BIBLIOGRAPHY [128] M. Hameed et al. “Performance investigation and optimization of IEEE802. 15.4 for industrial wireless sensor networks”. In: 2008 IEEE International Conference on Emerging Technologies and Factory Automation . 2008 (cit. on p. 35). [129] V. Deep and T. Elarabi. “Efficient IEEE 802.15.4 ZigBee standard hardware design for IoT applications”. In: 2017 International Conference on Signals and Systems (ICSigSys) . 2017 (cit. on p. 35). [130] J. Carbone. “Measuring Real-Time Performance of An RTOS”. In: Express Logic, inc. San Diego, CA (2003) (cit. on p. 36). [131] M. E. C. Bormann and A. Keranen. Terminology for Constrained-Node Networks . RFC. Internet Engineering Task Force (IETF), 2004. url: https://tools.ietf.org/html/rfc7228 #page-11 (cit. on p. 40). [132] SiFive Freedom E300 Platform . SiFive. 2016 (cit. on p. 48). [133] Y. B. Zikria et al. “Internet of Things (IoT): Operating System, Applications and Protocols Design, and Validation Techniques”. In: Future Generation Computer Systems (2018) (cit. on p. 49). [134] W. Hofer et al. “SLOTH: Threads as Interrupts”. In: 2009 30th IEEE Real-Time Systems Symposium . 2009 (cit. on p. 49). [135] T. Gomes et al. “Task-Aware Interrupt Controller: Priority Space Unification in Real-Time Systems”. In: IEEE Embedded Systems Letters (2015) (cit. on p. 49). [136] E. Dolstra, M. De Jonge, E. Visser, et al. “Nix: A Safe and Policy-Free System for Software Deployment.” In: 2004 (cit. on p. 57). [137] A. A. Mirani et al. “Key Challenges and Emerging Technologies in Industrial IoT Architectures: A Review”. In: Sensors (2022) (cit. on p. 86). [138] T. Ainsworth et al. “A Comprehensive Survey of Industry 4.0, IIoT and Areas of Implementation”. In: SoutheastCon 2021 . 2021 (cit. on p. 86). [139] M. Alabadi, A. Habbal, and X. Wei. “Industrial Internet of Things: Requirements, Architecture, Challenges, and Future Research Directions”. In: IEEE Access (2022) (cit. on p. 86). [140] K. S. H. Ong et al. “Predictive Maintenance Model for IIoT-Based Manufacturing: A Transferable Deep Reinforcement Learning Approach”. In: IEEE Internet of Things Journal (2022) (cit. on pp. 86, 87). [141] M. Compare, P. Baraldi, and E. Zio. “Challenges to IoT-Enabled Predictive Maintenance for Industry 4.0”. In: IEEE Internet of Things Journal (2020) (cit. on pp. 86, 87). [142] A. S. Punpale and P. Borole. “Water quality monitoring and control using IoT and industrial automation”. In: IJSTE (2018) (cit. on pp. 86, 87). 113 BIBLIOGRAPHY [143] R. M. M. Salem, M. S. Saraya, and A. M. T. Ali-Eldin. “An Industrial Cloud-Based IoT System for Real-Time Monitoring and Controlling of Wastewater”. In: IEEE Access (2022) (cit. on pp. 86, 87). [144] L. Zhao et al. “Design of an Industrial IoT-Based Monitoring System for Power Substations”. In: IEEE Transactions on Industry Applications (2019) (cit. on p. 86). [145] M. Ayala-Chauvin et al. “IoT Monitoring for Real-Time Control of Industrial Processes”. In: International Conference on Technologies and Innovation . 2022 (cit. on pp. 86, 87). [146] P. M. de Sant Ana et al. “Control-Aware Scheduling Optimization of Industrial IoT”. In: 2022 IEEE 95th Vehicular Technology Conference: (VTC2022-Spring) . 2022 (cit. on pp. 86, 87). [147] X. Liu et al. Optimization and management in manufacturing engineering: Resource collaborative optimization and management through the Internet of Things . 2017 (cit. on pp. 86, 87). [148] A. Marguglio et al. “A hybrid cloud-to-edge predictive maintenance platform”. In: Predictive Maintenance in Smart Factories: Architectures, Methodologies, and Use-cases (2021) (cit. on p. 86). [149] G. G. Samatas, S. S. Moumgiakmas, and G. A. Papakostas. “Predictive maintenance-bridging artificial intelligence and iot”. In: 2021 IEEE World AI IoT Congress (AIIoT) . 2021 (cit. on p. 86). [150] C. R. Banbury et al. “Benchmarking tinyml systems: Challenges and direction”. In: arXiv preprint arXiv:2003.04821 (2020) (cit. on p. 86). [151] E. Monmasson et al. “FPGAs in Industrial Control Applications”. In: IEEE Transactions on Industrial Informatics (2011) (cit. on p. 87). [152] S. A. Jyothi et al. “Measuring and understanding throughput of network topologies”. In: SC’16: Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis . 2016 (cit. on p. 91). [153] M. Jacobsson and C. Rohner. “Estimating Packet Delivery Ratio for Arbitrary Packet Sizes Over Wireless Links”. In: IEEE Communications Letters (2015) (cit. on p. 93). [154] C. Johns et al. “Effects of Utility Functions on Network Response Time and Optimization”. In: Software and Network Engineering (2012) (cit. on p. 94). [155] O. Group. CVA6 User Manual . 2024. url: https://docs.openhwgroup.org/projects/ cva6-user-manual/01_cva6_user/CVX_Interface_Coprocessor.html (cit. on p. 101). [156] AMBA AXI and ACE Protocol Specification . Version E. arm. 2013 (cit. on p. 101). [157] S. Inc. SiFive TileLink to AXI Bridge (TL2AXI) v1p0 . 2018 (cit. on p. 101). [158] Z. Guo et al. “Optimized generation of data-path from C codes for FPGAs”. In: Design, Automation and Test in Europe . 2005 (cit. on p. 102). 114 BIBLIOGRAPHY [159] S. Huda, M. Mallick, and J. H. Anderson. “Clock gating architectures for FPGA power reduction”. In: 2009 International Conference on Field Programmable Logic and Applications . 2009 (cit. on p. 102). Thisdocumentwascreatedwiththe(pdf/Xe/Lua)L A T E XprocessorandtheNOVAthesistemplate(v7.0.2). 115