'\" t .\" Title: mutex_trylock .\" Author: .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: July 2017 .\" Manual: Mutex API reference .\" Source: Kernel Hackers Manual 4.11.6 .\" Language: English .\" .TH "MUTEX_TRYLOCK" "9" "July 2017" "Kernel Hackers Manual 4\&.11\&" "Mutex API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" mutex_trylock \- try to acquire the mutex, without waiting .SH "SYNOPSIS" .HP \w'int\ __sched\ mutex_trylock('u .BI "int __sched mutex_trylock(struct\ mutex\ *\ " "lock" ");" .SH "ARGUMENTS" .PP \fIstruct mutex * lock\fR .RS 4 the mutex to be acquired .RE .SH "DESCRIPTION" .PP Try to acquire the mutex atomically\&. Returns 1 if the mutex has been acquired successfully, and 0 on contention\&. .SH "NOTE" .PP this function follows the \fBspin_trylock\fR convention, so it is negated from the \fBdown_trylock\fR return values! Be careful about this when converting semaphore users to mutexes\&. .PP This function must not be used in interrupt context\&. The mutex must be released by the same task that acquired it\&. .SH "AUTHOR" .PP \fBRusty Russell\fR <\&rusty@rustcorp.com.au\&> .RS 4 Author. .RE .SH "COPYRIGHT" .br