[Tinyos-devel] Will safe protect this kind of code?
Eric Decker
cire831 at gmail.com
Wed Aug 13 15:11:56 PDT 2008
How does deputy handle the possibility of a NULL being erroneously enqueued
whichthen causes the variable current_thread to go null on the dqueue?
Is there something that give this kind of information about deputy and safe?
Where should I
start?
eric
On Wed, Aug 13, 2008 at 2:10 PM, John Regehr <regehr at cs.utah.edu> wrote:
> 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
>>
>>
--
Eric B. Decker
Senior (over 50 :-) Researcher
Autonomous Systems Lab
Jack Baskin School of Engineering
UCSC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-devel/attachments/20080813/19db0219/attachment.htm
More information about the Tinyos-devel
mailing list