A wireless sensor node comprises a wireless transceiver to communicate
over a wireless communication link with at least one other node in a
wireless sensor network, a sensor interface to receive sensor data from a
sensor, and a programmable processor coupled to the sensor interface and
the wireless transceiver. The programmable processor executes program
instructions that implement a virtual machine for executing an event
program that is generated from a query. The event program comprises a
plurality of instructions, each instruction being associated with an
event. The virtual machine allocates a token data structure for each of
event and manages the execution of the plurality of instructions using
the token data structures.