<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/IORecursiveLockTryLock",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@F@IORecursiveLockTryLock"
  },
  "title" : "IORecursiveLockTryLock"
}
-->

# IORecursiveLockTryLock

```
bool IORecursiveLockTryLock(struct IORecursiveLock *lock);
```

## Parameters

`lock`

Pointer to the allocated lock.

## Return Value

True if the lock is now locked by the caller, otherwise false.

## Discussion

\abstract Attempt to lock a recursive lock.
\discussion Lock the lock if it is currently unlocked, or held by the calling thread, and return true. If the lock is held by another thread, return false. Successful calls to IORecursiveLockTryLock should be balanced with calls to IORecursiveLockUnlock.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)