The increasing significance of operating systems (OSs) in the development of the internet of things (IoT) has emerged in the last decade. An event-driven OS is memory efficient and suitable for resource-constrained IoT devices and wireless sensors, although the program's control flow, which is determined by events, is not always obvious. A multithreaded OS with sequential control flow is often considered clearer. However, this approach is memory-consuming. A hybrid OS seeks to combine the strengths of the event-driven approach with multithreaded approach. An eventdriven cooperative threaded OS represents a hybrid approach that supports concurrency by explicitly yielding control to another thread. Although this approach is memory efficient, as cooperative threads are not preemptive, it may not provide sufficient real-time performance.This article proposes a memory-efficient hybrid OS, called StateOS, for resource-constrained IoT devices. It is an event-driven cooperative threaded OS with partial real-time performance. StateOS implements a hybrid task scheduler that combines two cooperative threaded subsystems as kernel processes on a prioritybased preemptive scheduler. This approach provides adequate real-time performance for IoT devices at a low memory cost.Index Terms-cooperative programming, internet of things, IoT OS, hybrid operating system, wireless sensor network operating system, WSN OS
I. INTRODUCTIONInternet of things (IoT) research has been very active over the past decade. This technology is expected to change people's daily lives by becoming part of the surrounding ambient objects [1]. In 2020, the number of IoT connections exceeded that of non-IoT connections for the first time by 12 billion [2].Most of the deployed IoT devices are based on wireless sensors. These devices share similar restrictions as the nodes of wireless sensor networks (WSN), such as restricted resources, distant deployment, unreliable network connections, and dynamic network topology. Therefore, existing WSN operating systems (OSs), such as TinyOS [3] and Contiki [4], are also utilized in IoT devices.The typical OS for resource-constrained IoT or WSN devices supports either an event-driven or a thread-based programming model. In an event-driven model, programs are collections of event handlers, and the execution of an event handler is triggered by events. This approach is well-suited for data-centric IoT applications. Event-driven OSs are memory efficient and,