simple_lock or simple_lock_try Kernel Service

Purpose

Locks a simple lock.

Syntax

#include <sys/lock_def.h>

void simple_lock ( lock_addr)
simple_lock_t lock_addr;

boolean_t simple_lock_try ( lock_addr)
simple_lock_t lock_addr;

Parameter

Item Description
lock_addr Specifies the address of the lock word to lock.

Description

The simple_lock kernel service locks the specified lock; it blocks if the lock is busy. The lock must have been previously initialized with the simple_lock_init kernel service. The simple_lock kernel service has no return values.

The simple_lock_try kernel service tries to lock the specified lock; it returns immediately without blocking if the lock is busy. If the lock is free, the simple_lock_try kernel service locks it. The lock must have been previously initialized with the simple_lock_init kernel service.

Note: When using simple locks to protect thread-interrupt critical sections, it is recommended that you use the disable_lock kernel service instead of calling the simple_lock kernel service directly.

Execution Environment

The simple_lock and simple_lock_try kernel services can be called from the process environment only.

Return Values

The simple_lock_try kernel service has the following return values:

Item Description
TRUE Indicates that the simple lock has been successfully acquired.
FALSE Indicates that the simple lock is busy, and has not been acquired.