---
name: "mutex_lock"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/mutex_lock"
---

# mutex\_lock(9)

acquire the mutex

## NAME

mutex\_lock - acquire the mutex

## SYNOPSIS

**void \_\_sched mutex\_lock(struct mutex \*** *lock***);**

## ARGUMENTS

*lock*

the mutex to be acquired

## DESCRIPTION

Lock the mutex exclusively for this task. If the mutex is not available right now, it will sleep until it can get it.

The mutex must later on be released by the same task that acquired it. Recursive locking is not allowed. The task may not exit without first unlocking the mutex. Also, kernel memory where the mutex resides must not be freed with the mutex still locked. The mutex must first be initialized (or statically defined) before it can be locked. **memset**-ing the mutex to 0 is not allowed.

( The CONFIG\_DEBUG\_MUTEXES .config option turns on debugging checks that will enforce the restrictions and will also do deadlock debugging. )

This function is similar to (but not equivalent to) **down**.

## AUTHOR

**Rusty Russell** \<rusty@rustcorp.com.au\>

Author.

## COPYRIGHT
