The proliferation of Internet of Things (IoT) technology has spurred the need for efficient operating systems tailored to the constraints of IoT devices. This paper presents StateOS, a hybrid operating system designed to meet the demands of sensor-based IoT devices and wireless sensors. StateOS combines the memory efficiency of event-driven systems with the clarity of control flow provided by multithreaded approaches. By implementing a microkernel architecture, cross-layer network protocol design, and a hybrid task scheduler, StateOS offers real-time capabilities while minimizing memory footprint. Macro-based task APIs and state machine-based visual programming facilitate cooperative threaded programming, making StateOS suitable for both experienced developers and novices. The paper provides an in-depth overview of StateOS's architecture, kernel functionalities, code examples, implementation on various platforms, performance evaluation, and concludes by highlighting its potential as a valuable tool for modern IoT application development. Keywords — Hybrid operating system (OS), Internet of Things (IoT) and Memory efficiency.