|
From: Joakim E. <jo...@si...> - 2009-02-10 16:23:25
|
You should also get a better behavior if you avoid scheduling
timers with more than half the maximum timer interval between
each other. The current macro assumes that the times you compare
is in the future and maximum half an interval into the future
(e.g. max $7fff / 321767 tick using a 16-bit timer).
Best regards,
-- Joakim
Joakim Eriksson skrev:
> Hello,
>
> I believe that the problem comes from the picking of the next
> rtimer. The RTIMER_CLOCK_LT needs to take into account the current
> time to get a correct sorting when picking the next timer to
> schedule since there is no static ordering of timers when time
> can wrap.
>
> We are planning on replacing the rtimer system, but I guess a fix
> of this should also be done so that it is possible to use more than
> one rtimer.
>
> Try changing (in rtimer.c)
>
> if(RTIMER_CLOCK_LT(rtimers[i]->time, rtimers[n]->time)) {
> n = i;
> }
>
> to something like:
>
> rtimer_clock_t now = RTIMER_NOW();
> if(rtimers[i]->time - now < rtimers[n]->time - now){
> n = i;
> }
>
> This comparison would compare the actual time left before it should be
> triggered instead of "absolute" time.
>
>
> Best regards,
> -- Joakim Eriksson, SICS
>
>
> Farnaz Moradi wrote:
>> Hi,
>>
>> I almost solved my problem by sorting the rtimers queue in the
>> rtimer.c code. I'm not sure whether it will work for all situation or
>> not.
>> In my code one function schedules a rtimer at time 65535. In another
>> function I set an rtimer to interrupt at times 4915, 21299, ....
>> Since the rtimer for 65535 is further in time than 4915 and it has
>> been scheduled first, the interrupt for 4915 is missed and the time
>> will pass. When setting time 21299, since 4915 is still in the queue,
>> the rtimer_set function returns a value indicating that the rtimer is
>> already scheduled.
>>
>> Best Regards,
>> Farnaz
>>
>>
>> Adam Dunkels wrote:
>>> Hi,
>>>
>>> not sure exactly what happens from your description, but if you could
>>> post a list of clock values for which this happens, it would be helpful.
>>>
>>> Best regards,
>>>
>>> /adam
>>>
>>> Farnaz Moradi wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to use two instances of rtimer in my code. I want to set
>>>> one
>>>> of them using rtimer_set() function to interrupt when the clock wraps
>>>> around (clock value is changed from 65535 to 0), and the other one
>>>> when a
>>>> random time slot arrives.
>>>> I tried this scenario with netsim and it works, but when
>>>> implementing it
>>>> on msb430 motes, the second rtimer_set() returns value 3 which means
>>>> the
>>>> task is already scheduled.
>>>> Could you please tell me the reason for this and what can I do to
>>>> solve it?
>>>>
>>>> Regards,
>>>> Farnaz
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>>
>>>> Create and Deploy Rich Internet Apps outside the browser with
>>>> Adobe(R)AIR(TM)
>>>> software. With Adobe AIR, Ajax developers can use existing skills
>>>> and code to
>>>> build responsive, highly engaging applications that combine the
>>>> power of local
>>>> resources and data with the reach of the web. Download the Adobe AIR
>>>> SDK and
>>>> Ajax docs to start building applications
>>>> today-http://p.sf.net/sfu/adobe-com
>>>> _______________________________________________
>>>> Contiki-developers mailing list
>>>> Con...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/contiki-developers
>>>>
>>>>
>>>
>>>
>>
>> ------------------------------------------------------------------------------
>>
>> Create and Deploy Rich Internet Apps outside the browser with
>> Adobe(R)AIR(TM)
>> software. With Adobe AIR, Ajax developers can use existing skills and
>> code to
>> build responsive, highly engaging applications that combine the power
>> of local
>> resources and data with the reach of the web. Download the Adobe AIR
>> SDK and
>> Ajax docs to start building applications
>> today-http://p.sf.net/sfu/adobe-com
>> _______________________________________________
>> Contiki-developers mailing list
>> Con...@li...
>> https://lists.sourceforge.net/lists/listinfo/contiki-developers
>
|