diff options
author | Matti Linnanvuori <mattilinnanvuori@yahoo.com> | 2008-05-13 11:31:47 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-22 23:09:34 -0400 |
commit | 4d2e7d0d77e4e1e8a21cc990c607985fdba20e66 (patch) | |
tree | 4a5c3bd6c4e1f34d493146c1657d7fbeaa397cdc /Documentation | |
parent | 34e4e2fef4c7a2f7699b3d25e48d871d3ac4c3e7 (diff) |
doc: add a chapter about trylock functions [Bug 9011]
Add a chapter about trylock functions.
http://bugzilla.kernel.org/show_bug.cgi?id=9011
Signed-off-by: Matti Linnanvuori <mattilinnanvuori@yahoo.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (removed down_trylock)
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/DocBook/kernel-locking.tmpl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl index 77c42f40be5d..2510763295d0 100644 --- a/Documentation/DocBook/kernel-locking.tmpl +++ b/Documentation/DocBook/kernel-locking.tmpl | |||
@@ -703,6 +703,31 @@ | |||
703 | </sect1> | 703 | </sect1> |
704 | </chapter> | 704 | </chapter> |
705 | 705 | ||
706 | <chapter id="trylock-functions"> | ||
707 | <title>The trylock Functions</title> | ||
708 | <para> | ||
709 | There are functions that try to acquire a lock only once and immediately | ||
710 | return a value telling about success or failure to acquire the lock. | ||
711 | They can be used if you need no access to the data protected with the lock | ||
712 | when some other thread is holding the lock. You should acquire the lock | ||
713 | later if you then need access to the data protected with the lock. | ||
714 | </para> | ||
715 | |||
716 | <para> | ||
717 | <function>spin_trylock()</function> does not spin but returns non-zero if | ||
718 | it acquires the spinlock on the first try or 0 if not. This function can | ||
719 | be used in all contexts like <function>spin_lock</function>: you must have | ||
720 | disabled the contexts that might interrupt you and acquire the spin lock. | ||
721 | </para> | ||
722 | |||
723 | <para> | ||
724 | <function>mutex_trylock()</function> does not suspend your task | ||
725 | but returns non-zero if it could lock the mutex on the first try | ||
726 | or 0 if not. This function cannot be safely used in hardware or software | ||
727 | interrupt contexts despite not sleeping. | ||
728 | </para> | ||
729 | </chapter> | ||
730 | |||
706 | <chapter id="Examples"> | 731 | <chapter id="Examples"> |
707 | <title>Common Examples</title> | 732 | <title>Common Examples</title> |
708 | <para> | 733 | <para> |