Man pthread_mutex_init or man pthread_mutex_lock no result solution, pthreadmutexinit

Source: Internet
Author: User

Man pthread_mutex_init or man pthread_mutex_lock no result solution, pthreadmutexinit

Problem:

In the newly installed Mint/Ubuntu, man pthread_mutex-related functions may not be returned,

No manual entry for pthread_mutex_init error is reported, as shown in figure



Solution:

Install manpages: manpages-posix-dev

Mint/Ubuntu: sudo apt-get install manpages-posix-dev


Result:

Try again with man.




Pthread_mutex_lock: Why is the following program not deadlocked ???

The loop wait is actually like this: if the check conditions are not met, unlock them if they are not met. Then, wait until the check is completed, lock them again, and then check. If the check conditions are not met, unlock them.
That is to say, after entering the pthread_cond_wait function, it releases the lock and waits on has_product. When has_product is triggered, it locks the lock and then outputs the function. After your consumer thread calls pthread_cond_wait, it releases the lock and does not return this function (this function will not run without returning your code). When has_product is triggered, this function gets the lock and returns it.
Let's explain that before you call this function, your thread gets the lock. When you get this function, your thread still gets the lock; but when this function is not available, your thread will release the lock.

Who can explain the features of pthread_mutex_t?

This is a thread. pthread_mutex_t is a defined variable. If a thread locks it, other threads cannot lock it, only when the first thread unlocks other threads can it continue... I don't know where your program came from.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.