core:mutex: allow idle thread to use mutexes#859
Merged
Kijewski merged 1 commit intoRIOT-OS:masterfrom Mar 19, 2014
Kijewski:mutex-trylock-error
Merged
core:mutex: allow idle thread to use mutexes#859Kijewski merged 1 commit intoRIOT-OS:masterfrom Kijewski:mutex-trylock-error
Kijewski merged 1 commit intoRIOT-OS:masterfrom
Kijewski:mutex-trylock-error
Conversation
Contributor
|
ACK. nice one. I used the pid to make sure the same thread doesn't lock a mutex twice in a very early version... |
Contributor
Author
|
Oops, that line too, of course. |
Contributor
Author
|
Ping. |
Contributor
|
@Kijewski is there any reason to have the thread pid as value for the mutex? its not use in any way? idle thread has the pid zero, right? |
Contributor
Author
|
@mehlis there is no need to store the pid in there. Currently any thread that wants to claim the mutex by means of trylock writes its pid into the mutex. That means Yes, the idle thread has pid 0. |
Member
|
ACK |
Kijewski
added a commit
that referenced
this pull request
Mar 19, 2014
core:mutex: allow idle thread to use mutexes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mutex_t::valis an integral value where 0 means unlocked, and any other value means locked.mutex_trylockwrites the current thread id into this member to denote that it is locked.The problem is that the
idlethread has the PID 0, and is therefore not able to sanely use this function.The reason why the idle thread might need to use mutexes is because it changes the low-power state of the board, and I see reasons why it might be useful to use a mutex in this circumstance.