Go Down

Topic: Suggestion: don't call yield() in delay() (Read 1 time) previous topic - next topic


Changing delay to call yield will introduce subtle bugs.  Even coop schedulers will have problems.

For example, a library that calls delay while accessing a device on the SPI bus may inadvertently yield to another thread that also accesses the SPI bus.

Introduce another weak function like yield and call it something like "sleep".

The weak version of sleep() would call the unmodified version of delay().

Schedulers and preemptive RTOSs could implement appropriate behavior for yield() and sleep().  Library writers will have more control of thread execution.

A coop scheduler would call yield() in its version of sleep().

A preemptive RTOS like ChibiOS would call chThdSleep() or chThdYield() as replacements for sleep() and yield().

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131