Pumpkin User Forums
  Service Bulletins
  SB-22: Salvo: Timing Errors when Violating Timing Requirements

Post New Topic  
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   SB-22: Salvo: Timing Errors when Violating Timing Requirements
Salvo Tech Support
posted January 07, 2004 11:33     Click Here to See the Profile for Salvo Tech Support     Edit/Delete Message   Reply w/Quote
Applies To

All Salvo distributions.

Description of Problem

Salvo's timer requires that OSSched() be called at least once every system tick. In normal situations, this is easily accomplished -- a typical Salvo application calls OSSched() hundreds of times per system tick (i.e. per call to OSTimer()).

In situations where context-switching is delayed by more than a single tick, e,g, when a tight loop requiring thousands of instruction cycles is embedded in a Salvo task, the timer's delay performance will degrade. Specifically, the number of ticks of delay will be reduced by the number of ticks (Salvo's "lost ticks") during which OSSched() was unable to run.

For example:

void TaskBlink( void )
static int16_t someTime;

for (;;)
while (someTime < 20000);

PORT ^= 0x01;

OS_Delay(20, TaskBlink1);

In TaskBlink(), the do-while loop consumes several system ticks during which a context switch (and therefore a call to OSSched()) cannot occur. As a result, the time between successive PORT bit togglings is 20 system ticks, not 20 ticks + time(do-while loop). The delay of 20 ticks is achieved because Salvo (as of v3.2) tracks "lost ticks" that occur when OSSched() does not follow successive calls to OSTimer().

NOTE: In a Salvo application that does not violate the timing rules (i.e. context switches always occur within a system tick, or time(between tasks's context switches) << system tick), this timing error will not occur.

NOTE: This timing error applies to all types of delays, including those used when waiting on an event with a timeout.

Suggested Workaround

In Salvo tasks that do violate the timing rules, there are two solutions available:

1. Call OS_Yield() before calling OS_Delay(). This allows Salvo's timing system to "catch up", and a subsequent delay will have the standard (minimal) timing error.

2. Use saturation addition with OSlostTicks when passing the delay parameter to OS_Delay(), e.g.(for 8-bit delays):

OS_Delay((unsigned char)20+OSlostTicks<20 ? 255 : 20+OSlostTicks);

Either of these solutions will result in the task delay lasting the specified number of system ticks (+/- standard error). Note that when using method 2 above, desired delays near the upper limit may be "clipped" when OSlostTicks is large.

Fixed In

It is likely that a future release will include a service for performing the saturation addition, e.g. OS_Delay(OSXyz(20));

Salvo Technical Support
Please request all tech support through the Forums.


All times are ET

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  
Hop to:

Contact Us | Pumpkin Home Page

2000-2008 Pumpkin, Inc. All Rights Reserved. Pumpkin and the Pumpkin logo, Salvo and the Salvo logo, The RTOS that runs in tiny places, CubeSat Kit and the CubeSat Kit logo are all trademarks of Pumpkin, Inc. All other trademarks are the properties of their respective owners.

Ultimate Bulletin Board 5.46a