chibios_rt::Mutex no unlock methods

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 15 times
Been thanked: 24 times
Contact:

chibios_rt::Mutex no unlock methods

Postby Thargon » Tue Mar 24, 2015 4:32 pm

Hi,

I just tried to use the C++ wrapper for mutexes and was surprised when I didn't find any methods to unlock it.
It's no problem since the wrapper class just calls the chMtx... functions, but shouldn't a wrapper cover ALL the available functions?
Is there a reason why no unlock methods are provided?
If not, I will gladly create a patch ;)

Thargon

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: chibios_rt::Mutex no unlock methods

Postby Giovanni » Tue Mar 24, 2015 4:42 pm

Hi,

If I remember well it is a method of the thread object because it intrinsically operates on the last mutex taken.

Propose your patch, it is not set in stone.

Giovanni

colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

Re: chibios_rt::Mutex no unlock methods

Postby colin » Tue Mar 24, 2015 7:42 pm

Thargon, is this the code you are talking about?

Code: Select all

 void Mutex::unlock(void) {

    chMtxUnlock(&mutex);
  }

  void Mutex::unlockS(void) {

    chMtxLockS(&mutex);
  }


This code has been in ChibiOS ch.cpp/ch.hpp since Aug 2014.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: chibios_rt::Mutex no unlock methods

Postby Giovanni » Tue Mar 24, 2015 8:52 pm

I must be forgetting things.... :(

Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 15 times
Been thanked: 24 times
Contact:

Re: chibios_rt::Mutex no unlock methods

Postby Thargon » Wed Mar 25, 2015 1:34 pm

Strange...
In the online documentation there are no such methods.
In my cloned version (2.6.7) these are missing as well.

Maybe the code is included in 3.0 but missing for 2.x.x?

However, the snippet provided by colin should do the job.

colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

Re: chibios_rt::Mutex no unlock methods

Postby colin » Wed Mar 25, 2015 8:36 pm

colin wrote:Thargon, is this the code you are talking about?

Code: Select all

 void Mutex::unlock(void) {

    chMtxUnlock(&mutex);
  }

  void Mutex::unlockS(void) {

    chMtxLockS(&mutex);
  }


This code has been in ChibiOS ch.cpp/ch.hpp since Aug 2014.


Yikes, I think this is a bad bug: It seems that Mutex::unlockS() should call chMtxUnlockS() and not chMtxLockS() again.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: chibios_rt::Mutex no unlock methods

Postby Giovanni » Wed Mar 25, 2015 8:40 pm

Fixed.

Giovanni


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 6 guests