Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > cf93d8a8acdcc6fe2225039da0502495 > files > 2219

kernel-doc-2.6.32-131.17.1.el6.centos.plus.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter&#160;6.&#160;The trylock Functions</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Unreliable Guide To Locking" /><link rel="up" href="index.html" title="Unreliable Guide To Locking" /><link rel="prev" href="ch05.html" title="Chapter&#160;5.&#160;Cheat Sheet For Locking" /><link rel="next" href="ch07.html" title="Chapter&#160;7.&#160;Common Examples" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;6.&#160;The trylock Functions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch07.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter&#160;6.&#160;The trylock Functions"><div class="titlepage"><div><div><h2 class="title"><a id="trylock-functions"></a>Chapter&#160;6.&#160;The trylock Functions</h2></div></div></div><p>
   There are functions that try to acquire a lock only once and immediately
   return a value telling about success or failure to acquire the lock.
   They can be used if you need no access to the data protected with the lock
   when some other thread is holding the lock. You should acquire the lock
   later if you then need access to the data protected with the lock.
  </p><p>
    <code class="function">spin_trylock()</code> does not spin but returns non-zero if
    it acquires the spinlock on the first try or 0 if not. This function can
    be used in all contexts like <code class="function">spin_lock</code>: you must have
    disabled the contexts that might interrupt you and acquire the spin lock.
  </p><p>
    <code class="function">mutex_trylock()</code> does not suspend your task
    but returns non-zero if it could lock the mutex on the first try
    or 0 if not. This function cannot be safely used in hardware or software
    interrupt contexts despite not sleeping.
  </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="ch07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;5.&#160;Cheat Sheet For Locking&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Chapter&#160;7.&#160;Common Examples</td></tr></table></div></body></html>