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?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Alexander Terekhov <terekhov@web.de>
Newsgroups comp.programming.threads
Subject Re: can pthread_mutex_trylock() give up the timeslice?
Date Fri, 14 Oct 2011 11:50:07 +0200
Organization A noiseless patient Spider
Lines 26
Message-ID <4E9805CF.8963F146@web.de> (permalink)
References <996e61f0-62c3-4960-9f1f-3926af713c34@b41g2000yqd.googlegroups.com>
Reply-To terekhov@web.de
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Injection-Info mx04.eternal-september.org; posting-host="MCbSEzW5qwGLFMNXJh39IQ"; logging-data="4765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EszwOqubEWwm/V2KVRcZ3E0PXLAb1sqM="
X-Mailer Mozilla 4.77 [en] (Windows NT 5.0; U)
X-Accept-Language en
Cancel-Lock sha1:YbwJgM2wkOGPVbfeyzouOSnSYhE=
Xref x330-a1.tempe.blueboxinc.net comp.programming.threads:631

Show key headers only | 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