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

Add OS_DEBUG warning if task locks a mutex multiple times #623

Closed
jphickey opened this issue Oct 15, 2020 · 0 comments · Fixed by #634 or #639
Closed

Add OS_DEBUG warning if task locks a mutex multiple times #623

jphickey opened this issue Oct 15, 2020 · 0 comments · Fixed by #634 or #639
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

Is your feature request related to a problem? Please describe.
As noted in nasa/cFE#948, there are cases in CFE where a mutex may be taken by the same task more than once. This is technically allowed because OSAL enables recursive mutexes for all supported OS types.

But my concern is that:

  • recursive mutexes aren't guaranteed to be provided - i.e. some minimal RTOS's might not have this facility at all.
  • if recursive mutexes are provided, they are slower than the normal (non-recursive) counterpart.
  • anything that depends on recursive mutexes generally indicates deeper code design flaws - i.e. insufficient separation of internal vs. external APIs, function loops, circular subsystem dependencies, etc.

Describe the solution you'd like
Start by introducing an OS_DEBUG warning if the same task takes a mutex more than once. This can help identify the issues, and it is very easy to add. It also won't be displayed unless OSAL is compiled with debug messages enabled.

Additional context
A future / follow up change, once dependencies on recursive mutexes are fix, could be to allow the user to optionally elect to use non-recursive/fast mutexes via an osconfig option.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

jphickey added a commit to jphickey/osal that referenced this issue Oct 23, 2020
if OS_DEBUG is enabled, this adds a message if mutex give/take
actions occur outside the expected sequence.  In particular,
this warns if a task takes a mutex more than once.
@jphickey jphickey self-assigned this Oct 27, 2020
astrogeco added a commit that referenced this issue Oct 30, 2020
Fix #623, add debug messages for mutex double locks
@astrogeco astrogeco added this to the 6.0.0 milestone Oct 30, 2020
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
…asa#624)

Co-authored-by: Gerardo E. Cruz-Ortiz <59618057+astrogeco@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants