A wireless sensor network is characterized as a massively distributed and deeply embedded system. Such a system requires concurrent and asynchronous event handling as a distributed system and resource-consciousness as an embedded system. State machine based software design techniques are capable of satisfying exactly these requirements. In this paper, we present how to design a compact and efficient operating system for wireless sensor nodes based on a finite state machine. We describe how this operating system can operate in an extremely resource constrained sensor node while providing the required concurrency, reactivity, and reconfigurability. We also show some important benefits implied by this architecture.