LCK_pend
2-180
C Interface
Syntax
status = LCK_pend(lock, timeout);
Parameters
LCK_Handle lock;
/* lock handle */
Uns
timeout;
/* return after this many system clock ticks */
Return Value
Bool
status;
/* TRUE if successful, FALSE if timeout */
Description
LCK_pend acquires ownership of lock, which grants the current task
exclusive access to the corresponding resource. If lock is already owned
by another task, LCK_pend suspends execution of the current task until
the resource becomes available.
The task owning lock can call LCK_pend any number of times without risk
of blocking, although relinquishing ownership of the lock requires a
balancing number of calls to LCK_post.
LCK_pend results in a context switch if this LCK timeout is greater than
0 and the lock is already held by another thread.
LCK_pend returns TRUE if it successfully acquires ownership of lock,
returns FALSE if a timeout occurs before it can acquire ownership.
LCK_pend returns FALSE if it is called from the context of a SWI or HWI,
even if the timeout is zero.
Note: RTS Functions Callable from TSK Threads Only
Many run-time support (RTS) functions use lock and unlock functions
to prevent reentrancy. However, DSP/BIOS SWI and HWI threads
cannot call LCK_pend and LCK_post. As a result, RTS functions that
call LCK_pend or LCK_post
must not be called in the context of a SWI
or HWI thread
.
To determine whether a particular RTS function uses LCK_pend or
LCK_post, refer to the source code for that function shipped with Code
Composer Studio. The following table lists some RTS functions that call
LCK_pend and LCK_post in certain versions of Code Composer Studio:
LCK_pend
Acquire ownership of a resource lock
fprintf
printf
vfprintf
sprintf
vprintf
vsprintf
clock
strftime
minit
malloc
realloc
free
calloc
rand
srand
getenv