If a task has already obtained a mutex will a calling xSemphoreTake on the same mutex in the same task (for example, in a function being called) succeed or fail?
A standard mutex can only be taken once, so nested calls to attempt to take a standard mutex will fail. This is quite easy for you to test, or determine from the code. If you want the possibility to obtain the same mutex twice (at once) then you will instead need to create a recursive mutex.
To be clear, do I need to give that mutex the same number of times I take it?
If it is a non-recursive mutex, if you already have it, you shouldn’t call take again. If it is a recursive mutex, you need to give it as many times as you took it. Note, recursive mutexes use xSemaphoreTakeRecursive/xSemaphoreGiveRecursive instead of the simple xSemaphoreTask and xSemaphoreGive.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.