Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 97202
b: refs/heads/master
c: 4d2e7d0
h: refs/heads/master
v: v3
  • Loading branch information
Matti Linnanvuori authored and Rusty Russell committed May 23, 2008
1 parent c1a1105 commit a3c3a92
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 34e4e2fef4c7a2f7699b3d25e48d871d3ac4c3e7
refs/heads/master: 4d2e7d0d77e4e1e8a21cc990c607985fdba20e66
25 changes: 25 additions & 0 deletions trunk/Documentation/DocBook/kernel-locking.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,31 @@
</sect1>
</chapter>

<chapter id="trylock-functions">
<title>The trylock Functions</title>
<para>
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.
</para>

<para>
<function>spin_trylock()</function> 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 <function>spin_lock</function>: you must have
disabled the contexts that might interrupt you and acquire the spin lock.
</para>

<para>
<function>mutex_trylock()</function> 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.
</para>
</chapter>

<chapter id="Examples">
<title>Common Examples</title>
<para>
Expand Down

0 comments on commit a3c3a92

Please sign in to comment.