## 2 Materials and Methods
### Scheduler Implementation  
To achieve uniformly spaced sensor readings, we developed a custom cooperative periodic scheduler without task prioritization. This scheduler employs a round-robin execution model capable of handling a variable number of finite tasks, each of which must be completed within a predefined time slice. By utilizing a modular and transparent software architecture, our system prevents race conditions and CPU starvation through cooperative task scheduling without priorities. This implementation leverages a single timer interrupt, as illustrated in Figure 3. As shown in the figure, the system masks native Arduino interrupts during the execution of the timer interrupt and permits them only between the scheduled tasks. By imposing stringent constraints on the tasks supported by our system, we were able to simplify it to its bare minimum. As shown in Figure 3, tasks are executed in a strict round-robin fashion, and it is the user's responsibility to ensure that each task completes before the next timer interrupt occurs. Upon each interrupt, the scheduler simply retrieves the address of the next task to be executed and runs it. This approach imposes only about 3 \(\upmu\)s of overhead, which is significantly lower than the overhead imposed by any of the RTOS solutions mentioned in the Introduction. For comparison, lightweight RTOS solutions such as FreeRTOS typically incur a task switch overhead ranging from 5 to 15 \(\upmu\)s on ARM Cortex-M microcontrollers, with much higher delays on less capable platforms. Due to the deterministic nature of task execution, no conflicts or unexpected task delays were observed under normal operation, as long as each task adhered to its allocated time slice. This approach not only reduces the system complexity but also eliminates the need for additional fault tolerance mechanisms such as watchdog timers, as the risk of unanticipated system hangs or deadlocks is inherently minimized by design. The primary challenge arises in high-load scenarios where a transmitted packet is not successfully received due to network conditions or interference. This, however, is not a limitation of the scheduler itself; rather, it is handled at the communication protocol level, where the system simply requests a packet resend as needed. This ensures that data transmission remains reliable without disrupting the strict timing requirements of the real-time biofeedback process. As a direct consequence of the aforementioned simplification and overhead reduction, we were able to utilize a less powerful, energy-efficient microcontroller without compromising real-time performance. This design choice inherently contributes to lower power consumption, as the selected processor operates with reduced computational demands. (Although the expected average power draw of the selected ATSAMD21 controller is quite low (approximately 3 mA in active mode), certain other low-power models, such as the STM32L4 series, can achieve even lower active mode currents. However, these models are typically two to three times more expensive.) Additionally, the scheduler itself occupies less than 1 kB of the 256 kB of available flash memory, and its RAM usage is limited to just a few tens of bytes, primarily for maintaining task pointers and context, leaving sufficient capacity for the remaining program code and future extensions. In contrast, systems like FreeRTOS typically require 5 to 10 kB of flash memory and at least hundreds of bytes of RAM for task management and scheduling, even in their most basic configurations. The  
Figure 3: Implementation of a single timer interrupt serving as a periodic task scheduler. SRAM utilization in our system is similarly low, as this memory primarily serves as a buffer for sensor readings prior to transmission via the Wi-Fi interface. Since data are transmitted continuously with minimal buffering, the required SRAM remains well below 1 kB.