Skip to content

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

@jphickey

Description

@jphickey

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions