Recently, wireless sensor networks (WSNs) attract a great deal of research attention, and are envisioned to support a variety of applications, including military surveillance, habitat monitoring, and infrastructure protection, etc. Operating system (OS) support for WSNs plays a central role in building scalable distributed applications that are efficient and reliable. Over the years, we have seen a variety of OSes emerging in the sensornet community to facilitate developing WSN applications. Aside from the basic system implementations, there is also a large body of work devoted to improving OS capabilities in different dimensions. In this paper, we provide a comprehensive review of existing work in sensornet OS design. We first examine the challenges in the OS design space. We then introduce the major components of a sensornet OS. Next, we provide an overview of existing work, present a taxonomy of state-of-the-art OSes, and discuss various approaches to address the design challenges. Finally we discuss evaluations of a sensornet OS and present some recommendations from the perspectives of OS developers and OS users. We have also identified several open problems that need further investigation to make the OS provide stronger support for WSNs.