OpenTP1 Version 7 Programming Reference C Language
dc_lck_get - Enable locking of a resource
Format
ANSI C, C++
#include <dclck.h> int dc_lck_get (char *name, DCLONG lockmode, DCLONG ownerflag, DCLONG flags) |
K&R C
#include <dclck.h> int dc_lck_get (name, lockmode, ownerflag, flags) char *name; DCLONG lockmode; DCLONG ownerflag; DCLONG flags; |
Description
The function dc_lck_get() specifies lock for resources to be used by UAPs. Lock is managed in global transactions which are managed by the OpenTP1 transaction manager.
The lock specified by the function dc_lck_get() is released by lock release function (dc_lck_release_all() or dc_lck_release_byname()). The lock is also released when the synchronization point of the global transaction that called the function dc_lck_get() is acquired.
Arguments whose values are set in the UAP
name
Specify the name of the resource for which lock is to be specified. The name can be specified with up to 16-byte alphanumeric characters. The OpenTP1 lock service manages the lock on the basis of the specified resource name. If a value less than 16 bytes is specified and a null character appears, the value before the null character is regarded as the resource name. If a value exceeding 16 bytes is specified, the value up to 16 bytes is regarded as the resource name. The excess bytes are truncated.
The lock service does not check the contents of the character string. Specify a logically correct name. If a value other than alphanumeric characters is used for a resource name, the deadlock information, the timeout information, and the lckls command might not be displayed normally.
lockmode
Specify a lock mode. The lock mode must be DCLCK_PR or DCLCK_EX. They cannot be specified at the same time.
flags
Specify a flag concerning lock for the resource. The following values can be specified:
Return values
Return value | Return value (numeric) | Explanation |
---|---|---|
DC_OK | 0 | Normal termination. |
DCLCKER_PARAM | -401 | The value specified for the argument is invalid. |
DCLCKER_WAIT | -450 | Another UAP is using the resource specified for name. |
DCLCKER_DLOCK | -452 | A deadlock occurred. |
DCLCKER_TIMOUT | -453 | The resource could not be acquired because a timeout occurred (the wait time specified in the OpenTP1 lock service definition was exceeded). |
DCLCKER_MEMORY | -454 | The table for lock is insufficient. |
DCLCKER_OUTOFTRN | -455 | The specification was made by a UAP which was not operating as a transaction. |
DCLCKER_VERSION | -457 | The OpenTP1 library version does not match the lock service version. |
All Rights Reserved. Copyright (C) 2006, 2010, Hitachi, Ltd.