| Recently, wireless sensor networks (WSNs) have become increasingly popular in real society. The availability of cheap and small wireless sensor node and low power wireless communication help enhancing the development of wireless sensor application. When programmers develop WSNs application without any operating system, the development process is very difficult. In order to facilitate ease and rapidity in the development of sensor network applications, a sensor operating system is necessary for providing software infrastructure. But sensor nodes have restricted RAM and energy, which challenges the research of sensor operating system.In this paper, we design and implement an operating system for wireless sensor networks, and the operating system is lightweight, low-power and preemptive multithreading. Our operating system enables wireless sensor networks nodes to natively interleave complex tasks with time-sensitive tasks, thereby mitigating the bounded buffer producer-consumer problem. And the interleaved concurrency of multithreading is useful in sensor systems to prevent one long-lived task from blocking execution of a second time-sensitive task.To achieve energy efficiency, we propose a low power scheduling model which is based on equipment energy management. The scheduler sleeps the microcontroller after all threads except idle thread are not active. As a result, dormancy mechanism is realized in multithreading system, and energy efficiency is achieved in our system. Then, we also run the operating system prototype in our wireless sensor node, the results show that the design of operating system offers new idea and reference to the research. |