apache / apache/nuttx

[HELP] Use cases for different sleep/delay functions

Open
#16,259 2 comments 0 reactions 0 assignees View on GitHub
Community: Question
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

### Description

I am hoping to get some clarification on when it is appropriate to use each of the sleep/delay functions provided in NuttX.
- `up_delay`, `up_udelay` and `up_mdelay`
- `nxsig_sleep`, `nxsig_usleep`

If my understanding is correct, the `up_xdelay` functions are blocking and won't release the task during long blocks whereas the `nxsig_sleep` functions will release control so other tasks can run. I guess I am struggling to find a situation in which `up_delay` or `up_mdelay` should be used instead of `nxsig_usleep` in arch peripheral drivers. Are there side effects of `nxsig_` sleeps that I am missing?

Background for why I am asking this question: The STM32 ethernet drivers use both `nxsig_usleep` and `up_udelay`/`up_mdelay`. In one of our H7 applications, the blocking delays (`up_mdelay`) in `stm32_phyinit` has caused issues. While I work on adding STM32H5 peripheral drivers, I want to make sure I am using the correct functions for sleep/delays.

### Verification

- [x] I have verified before submitting the report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.