Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the timing / delay mechanisms commonly used in VxWorks

Shulou Source: shulou.com Published: 2022-06-01 09:42:54 10月04日 Update

This article mainly introduces which timing / delay mechanisms are commonly used in VxWorks. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

Timing / delay mechanisms commonly used in VxWorks

TaskDelay ()

Sleep () / nanosleep ()

WatchDog

Auxiliary Clock

Timestamp

TaskDelay ()

When ticks is 0-moves the current task (executing in the ready queue) to the end of the task of the same priority (still in the ready queue)

When ticks is n (greater than 0)-moves the current task (executing in the ready queue) to the deferred queue and moves it back to the ready queue when the nth tick of the system clock is encountered. Therefore, the actual delay duration is (nmur1, n) tick, that is to say, taskDelay () has an error of 0-1 tick.

If the task is in the delay queue, if it encounters a non-blocking, non-negligible signal,taskDelay (), it returns ERROR and sets ERRNO to EINTR.

When a task returns to the ready queue, there may be high (or equivalent) priority tasks ahead, so the delay time may be longer

Sleep () / nanosleep ()

These are POSIX standard functions, which are also delay operations, which move the current task to the delay queue, and the bottom layer is the called taskDelay (), that is, its precision also depends on the system clock. Unlike taskDelay (),

The parameter is time.

When rmtp is not NULL-used to store the remaining time of sleep () / nanosleep () due to the early return of signal

When the timer is 0 (secs=0;rqtp- > tv_sec=rqtp- > tv_nsec=0)-do nothing

Timing is not 0 hours-delay at least parameter length (rounded up, cardinality is system clock) plus 1 system clock tick

As you can see, if sleep is 1 second, the result is 1 second plus 1 tick, which prevents the error of taskDelay () that is less than 1 tick.

Nanosleep () also operates in this way:

When each tick of the system clock is 1 millisecond, nanosleep () 1 nanosecond is actually rounded up to 1 millisecond (base is 1 millisecond of tick) plus 1 tick (1 millisecond), that is, 2 milliseconds. When nanosleep () is slightly more than 1 millisecond (for example, 1000001), it is actually rounded up (2 milliseconds) plus one tick (1 millisecond), that is, 3 milliseconds.

WatchDog

Its timing accuracy also depends on the system clock, but the difference from taskDelay () / sleep () / nanosleep () is that the operation after WatchDog timing is performed in the form of an interrupt and will not be disturbed by other high-priority tasks.

Auxiliary Clock

Timing accuracy can be much higher than that of WatchDog, and timing is periodic.

Timestamp

Timing accuracy is the highest, up to nanosecond, but only polling mode is supported in most boards.

These are all the contents of this article entitled "what are the timing / delay mechanisms commonly used in VxWorks?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Tasks queues clocks systems precision commonly used mechanisms priority duration content parameters depending on cardinality time current article nanosecond error movement different Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Apple Huawei macOS Redmi