[Tinyos-devel] Will safe protect this kind of code?
John Regehr
regehr at cs.utah.edu
Wed Aug 13 14:10:09 PDT 2008
Eric,
Sure, ensuring that a pointer never becomes NULL is an excellent use for
Deputy. However I don't think anyone has done Deputy annotations for the
code that implements threads. If you do this you may run into a few
problems since things like dispatchers inherently perform operations that
violate safety. I'd be interested to see how it goes...
John Regehr
On Wed, 13 Aug 2008, Eric Decker wrote:
> In particular, current_thread comes from either remove or dequeue. I've
> seen situations when we were messing with early thread code where
> current_thread actual got NULL and it wreck havoc.
>
> Will safe and deputy detect current_thread becoming NULL?
>
Alternatively, I could do something like:
>
> if (!current_thread)
> panic(...);
> else
> current_thread->state = TOSTHREAD_STATE_ACTIVE;
>
> but that is ugly.
>
> eric
>
>
> void scheduleNextThread() {
> if(tos_thread->state == TOSTHREAD_STATE_READY)
> current_thread = call ThreadQueue.remove(&ready_queue, tos_thread);
> else
> current_thread = call ThreadQueue.dequeue(&ready_queue);
>
> current_thread->state = TOSTHREAD_STATE_ACTIVE;
> }
>
>
> --
> Eric B. Decker
> Senior (over 50 :-) Researcher
> Autonomous Systems Lab
> Jack Baskin School of Engineering
> UCSC
>
More information about the Tinyos-devel
mailing list