Problems with mutex
Hello folks,
I'm using Xenomai 2.0.1 with Linux 2.6.14 and ipipe. I've a strange problem using mutex-locks. Repeted calls to rt_mutex_lock with TM_NONBLOCK on the same mutex return always 0, which means lock successfully aquired, if I understand the API-documentation right. I've attached a small programm to test that behavior and the log-messages it produces on my machine. Perhaps anyone has a hint, what I'm doing wrong...
Greetings Kai Moritz
Nov 29 19:35:47 localhost kernel: mutex: module initialization... mutex: creating mutex... done! Nov 29 19:35:47 localhost kernel: mutex: initializing test thread... done. Nov 29 19:35:47 localhost kernel: mutex: starting rt timer (one shot mode)... done. Nov 29 19:35:47 localhost kernel: mutex: starting test thread... Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 0th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 1th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 2th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 3th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 4th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 5th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 6th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 7th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 8th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 9th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 10th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 11th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 12th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 13th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 14th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 15th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 16th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 17th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 18th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: locking mutex the 19th time...done: 0! Nov 29 19:35:47 localhost kernel: mutex: all tests done! Nov 29 19:35:47 localhost kernel: mutex: test thread successfully started. Nov 29 19:35:47 localhost kernel: mutex: module initialization done. Nov 29 19:35:47 localhost kernel: mutex: deleting mutex... done! Nov 29 19:35:47 localhost kernel: mutex: module cleanup done.
Quoted 9 lines · Kai Moritz
Hello folks,
I'm using Xenomai 2.0.1 with Linux 2.6.14 and ipipe. I've a strange problem using mutex-locks. Repeted calls to
rt_mutex_lockwithTM_NONBLOCKon the same mutex return always 0, which means lock successfully aquired, if I understand the API-documentation right. I've attached a small programm to test that behavior and the log-messages it produces on my machine. Perhaps anyone has a hint, what I'm doing wrong...
Does the same thread lock this mutex over and over again (I did not look at your code yet)? If so, note that mutexes can be acquired recursively by the original owner.
Jan
Quoted 5 lines · Jan Kiszka
Does the same thread lock this mutex over and over again (I did not look at your code yet)? If so, note that mutexes can be acquired recursively by the original owner.
Oh, yes!
That's the solution. I read over that in the API.
Thanks for the quick answer :)
Kai