Archived

This forum has been archived. Please start a new discussion on GitHub.

pthread_mutexattr_settype

Hi

What kind of problem can occur when pthread_mutexattr_settype do nothing and always return 0? :)
Because if this function is important, I must to modify the OS...

Thanks.

Comments

  • benoit
    benoit Rennes, France
    Hi,

    It's required by IceUtil::RecMutex to create Posix recursive mutexes. If recursive mutexes aren't available on your platform, you'll need to re-implement IceUtil::RecMutex using regular mutexes. It's also used by IceUtil::Mutex to create "error check" mutexes. If not available on your platform, you can just use "normal" mutexes instead.

    See the pthread_mutexattr_init specification for more information on the different types of mutexes.

    Cheers,
    Benoit.
  • Hi,

    I think if I return 0 (in pthread_mutexattr_settype) when kind == PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_ERRORCHECK the OS run with non-recursive threads and ICE run correctly. No?

    Otherwise, for PTHREAD_MUTEX_RECURSIVE I can add a case RECURSIVE_THREAD in lock and unlock functions of OS, with a counter.
    But for PTHREAD_MUTEX_ERRORCHECK I don't know.

    My goal is to modify the least possible the OS and ICE.

    Cheers,
    Sebastien.
  • benoit
    benoit Rennes, France
    Hi,

    Returning 0 for PTHREAD_MUTEX_ERRORCHECK should be fine. You should however implement PTHREAD_MUTEX_RECURSIVE as parts of the Ice core rely on recursive mutexes.

    Cheers,
    Benoit.