0

I wanted to take a look at the manpage of pthread_mutex_trylock.

By typing man pthread_mutex_trylock, I got No manual entry for pthread_mutex_trylock.

Then I saw a post suggest doing sudo apt-get install manpages-posix manpages-posix-dev.

After that I see description like:

PTHREAD_MUTEX_LOCK(3POSIX)                               POSIX Programmer's Manual                              PTHREAD_MUTEX_LOCK(3POSIX)

PROLOG
       This manual page is part of the POSIX Programmer's Manual.  The Linux implementation of this interface may differ (consult the cor‐
       responding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
  1. What's the difference between this POSIX Programmer's Manual and the Linux Programmer's Manual that I usually see?

  2. What does it mean by saying:

The Linux implementation of this interface may differ (consult the cor‐responding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

So where can I find the manpage for The Linux implementation of pthread_mutex_trylock ? Can I use pthread_mutex_trylock on my system ? I am using Ubuntu.

  • Why downvoted? This is a fairly reasonable question. At least I didn't know I should install the the manual for the library that implements the interface. before someone told me so. – Rick Apr 9 at 8:43
  • Many thanks to @Kusalananda resolving my confusion. See discussion from chat.stackoverflow.com/rooms/191520/…, hope that also help you. – Rick Apr 9 at 11:30
4

It says that because there's no guarantee that the POSIX manuals (for anything) corresponds to the actual implementation of the corresponding thing on your particular system.

To get the manual for pthread_mutex_trylock(), install the the manual for the library that implements the interface.

On Ubuntu systems, the required manual seems to be part of the glibc-doc package (found by searching for the function name on the Ubuntu package search pages).

The POSIX manual are definitely not useless. The local Linux interface should be compatible with the interface described in the POSIX manual, but the implementation-specific manual may also mentions caveats and Linux-specific implementation details and extensions, and similar non-POSIX functions.

The POSIX manuals becomes extra important if you are concerned about the portability of your code to other Unix systems, in which case you would want to avoid relying on Linux-specific extensions to the POSIX specification.

  • Ok. Let me check that link. So I should never rely on the POSIX manuals but the manual for the library that implements the interface right? – Rick Apr 9 at 8:12
  • @Rick See updated answer. – Kusalananda Apr 9 at 8:19
  • Another question, why pthread_create is included in the Linux Programmer's Manual, while some other like pthread_mutex_lock is not? Why? – Rick Apr 9 at 8:22
  • @Rick Sorry, the package seems to be glibc-doc. I'll look at the followup question when I'm not on the phone. Could you make it part of the main question please? – Kusalananda Apr 9 at 8:30
  • @Rick the glibc manpages include one for pthread_mutex_lock: manpages.ubuntu.com/manpages/cosmic/en/man3/… – muru Apr 9 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.