Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #631

Re: can pthread_mutex_trylock() give up the timeslice?

From Alexander Terekhov <terekhov@web.de>
Newsgroups comp.programming.threads
Subject Re: can pthread_mutex_trylock() give up the timeslice?
Date 2011-10-14 11:50 +0200
Organization A noiseless patient Spider
Message-ID <4E9805CF.8963F146@web.de> (permalink)
References <996e61f0-62c3-4960-9f1f-3926af713c34@b41g2000yqd.googlegroups.com>

Show all headers | View raw


Brendon wrote:
> 
> **context**
> I am working on a bit of code, where a thread has a queue of work to
> do and as it is starting to run out of work it asks for more work.
> This process of asking for more work requires a lock on a common task
> queue. However because the thread asks for more before running out if
> the thread is unable to obtain the lock it will continue doing more
> work and ask again in a little while. This right now uses a
> pthread_mutex_trylock()
> 
> If the thread runs out of work completely it blocks waiting for the
> lock as there is nothing more it can do and that just uses
> pthread_mutex_lock().
> 
> **question**
> My question is (i cant seem to find the definitive answer anywhere),
> is it POSSIBLE that pthread_mutex_trylock() can give up the current
> timeslice?

If you are not running in a hard realtime environment, a thread can give
up the current timeslice at any time.

regards,
alexander.

Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

can pthread_mutex_trylock() give up the timeslice? Brendon <brendon.j.costa@gmail.com> - 2011-10-13 16:05 -0700
  Re: can pthread_mutex_trylock() give up the timeslice? Alexander Terekhov <terekhov@web.de> - 2011-10-14 11:50 +0200
  Re: can pthread_mutex_trylock() give up the timeslice? Joshua Maurice <joshuamaurice@gmail.com> - 2011-10-14 13:43 -0700
    Re: can pthread_mutex_trylock() give up the timeslice? Brendon <brendon.j.costa@gmail.com> - 2011-10-14 16:56 -0700
      Re: can pthread_mutex_trylock() give up the timeslice? Alexander Terekhov <terekhov@web.de> - 2011-10-15 13:53 +0200
  Re: can pthread_mutex_trylock() give up the timeslice? David Schwartz <davids@webmaster.com> - 2011-10-15 21:41 -0700

csiph-web