Skip to content

core:mutex: allow idle thread to use mutexes#859

Merged
Kijewski merged 1 commit intoRIOT-OS:masterfrom
Kijewski:mutex-trylock-error
Mar 19, 2014
Merged

core:mutex: allow idle thread to use mutexes#859
Kijewski merged 1 commit intoRIOT-OS:masterfrom
Kijewski:mutex-trylock-error

Conversation

@Kijewski
Copy link
Copy Markdown
Contributor

@Kijewski Kijewski commented Mar 5, 2014

mutex_t::val is an integral value where 0 means unlocked, and any other value means locked.
mutex_trylock writes the current thread id into this member to denote that it is locked.
The problem is that the idle thread 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.

@kaspar030
Copy link
Copy Markdown
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...

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Mar 5, 2014

@Kijewski
Copy link
Copy Markdown
Contributor Author

Kijewski commented Mar 5, 2014

Oops, that line too, of course.

@Kijewski
Copy link
Copy Markdown
Contributor Author

Ping.

@mehlis
Copy link
Copy Markdown
Contributor

mehlis commented Mar 19, 2014

@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?

@Kijewski
Copy link
Copy Markdown
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 mutex_t::val contains the pid of the last thread that wanted to claim it ...

Yes, the idle thread has pid 0.

@LudwigKnuepfer
Copy link
Copy Markdown
Member

ACK

Kijewski added a commit that referenced this pull request Mar 19, 2014
core:mutex: allow idle thread to use mutexes
@Kijewski Kijewski merged commit e6d8c6b into RIOT-OS:master Mar 19, 2014
@Kijewski Kijewski deleted the mutex-trylock-error branch March 19, 2014 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants