Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sched/semaphore: Remove restriction to use nxsem_trywait from ISR #10199

Merged

Conversation

tmedicci
Copy link
Contributor

Summary

  • sched/semaphore: Remove restriction to use nxsem_trywait from ISR

It could be called from the interrupt handler because nxsem_trywait is non-blocking, although not recommended.

Impact

Enable applications to call this interface (with CONFIG_DEBUG_ASSERTIONS enabled) without problems. No impact for current implementations.

Testing

Internal CI testing + NuttX CI.

Copy link
Contributor

@pkarashchenko pkarashchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be reasonable

@xiaoxiang781216
Copy link
Contributor

need remove the idle check too, since interrupt may also happen in the idle thread.

@pkarashchenko
Copy link
Contributor

pkarashchenko commented Aug 12, 2023

Can we add a check to assert if not interrupt context and idle thread than?

@pkarashchenko
Copy link
Contributor

@xiaoxiang781216 do you any ideas about this failure?

2023-08-11T23:32:28.1448456Z make: *** [tools/Unix.mk:680: olddefconfig] Error 1

@xiaoxiang781216
Copy link
Contributor

Can we add a check to assert if not interrupt context and idle thread then?

no, it's legal to call sem_post from the normal thread context.

@pkarashchenko
Copy link
Contributor

This is not about sem_post, but about trywait. I mean to prohibit trywait from the idle task

@xiaoxiang781216
Copy link
Contributor

This is not about sem_post, but about trywait. I mean to prohibit trywait from the idle task

Sorry, it's my typo error. After more think, you can do the assert as your suggestion:

Can we add a check to assert if not interrupt context and idle thread than?

@PetervdPerk-NXP
Copy link
Contributor

This would fix #5142 as well

Considering that `nxsem_trywait` is non-blocking, although not
recommended, it could be called from the interrupt handler.
@tmedicci tmedicci force-pushed the improvement/sem_trywait_from_isr branch from c6163e9 to baaac91 Compare August 14, 2023 12:04
@tmedicci
Copy link
Contributor Author

Can we add a check to assert if not interrupt context and idle thread than?

Done! Could you please take a look if it makes sense?

@xiaoxiang781216 xiaoxiang781216 merged commit 98985f4 into apache:master Aug 14, 2023
26 checks passed
@jerpelea jerpelea added this to To-Add in Release Notes - 12.3.0 Sep 26, 2023
@jerpelea jerpelea moved this from To-Add to core in Release Notes - 12.3.0 Sep 27, 2023
@jerpelea jerpelea moved this from core to done in Release Notes - 12.3.0 Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

FlexCAN can_input() should not be called directly from interrupt handler
4 participants