From: june.tune.sea@gmail.com (ishare)
To: kernelnewbies@lists.kernelnewbies.org
Subject: pthread_lock
Date: Wed, 13 Mar 2013 12:10:48 +0800 [thread overview]
Message-ID: <20130313041048.GA2519@debian.localdomain> (raw)
In-Reply-To: <CACPKTAMpYs5aNMUdmduA-j=yxP1_+i05u8+VoMW5maqZFuDwrg@mail.gmail.com>
On Tue, Mar 12, 2013 at 06:18:02PM +0530, Prabhu nath wrote:
> I guess we should not mix mutex and condition variable. Both have their own
> respective semantics.
> *mutex* is used to serialize access to a shared resource among competing
> threads.
> *condition variable* is used to notify a* state change* of a resource to
> the interested thread.
>
> In case of condition variable there is provision to explicitly notify a
> single thread(pthread_cond_signal) or all the threads waiting on a
> condition (or a state change) (pthread_cond_broadcast)
>
> Question was on pthread_mutex_unlock() that whether this function
> invocation will trigger the movement of all the threads in the wait queue
> to the ready queue.
After pthread_mutex_unlock() is called , the mutex is release , then ,which stuff
will reshcedule the threads in the waitqueue ?
If do pthread_cond_signal() after each pthread_mutex_unlock() ,does it raise up the performence ?
thanks!
> If all the threads are of equal priority, then the first thread waiting for
> the lock will be put to READY queue.
> If there are variable priority threads waiting for the lock, then the
> thread with highest priority would be woken up
next prev parent reply other threads:[~2013-03-13 4:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-05 4:44 pthread_lock ishare
2013-03-05 5:32 ` pthread_lock Mandeep Sandhu
2013-03-05 6:02 ` pthread_lock Valdis.Kletnieks at vt.edu
2013-03-05 8:09 ` pthread_lock Mandeep Sandhu
2013-03-05 10:05 ` pthread_lock ishare
2013-03-12 12:48 ` pthread_lock Prabhu nath
2013-03-13 4:10 ` ishare [this message]
2013-03-13 5:20 ` pthread_lock Prabhu nath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130313041048.GA2519@debian.localdomain \
--to=june.tune.sea@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).