Go Down

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

fat16lib

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
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview