glob_lock: Lock and access synchronizable z/TPF global field or record
This function reserves exclusive write access to the specified z/TPF global field or record and forces refreshing of the core copy from the most current file copy. You should ensure that a lock is held for the shortest possible time because severe system degradation may result from other ECBs waiting for locks. This function is valid only for synchronizable z/TPF global fields and records.
Last updated
- Changed in 2021 (information only; no code change).
- Changed for PUT00.
Format
maketpf_env += system
#include <tpf/tpfglbl.h>
#include <tpf/c_globz.h>
void *glob_lock(unsigned int tagname); - tagname
- This argument, which is defined in header file c_globz.h, uniquely identifies the z/TPF global field or record to be locked.
Normal return
This function returns a pointer to the specified z/TPF global field or record's directory entry (for example, a pointer to the field or record's address).
Error return
Not applicable.
Programming considerations
- The argument coded as tagname must be defined in header file c_globz.h. Results will be unpredictable if this restriction is not heeded.
- Programs using this function should be prepared to call
glob_update,glob_syncorglob_unlockas soon as possible to prevent severe system degradation caused by other ECBs waiting for the lock. - After this function call is completed, the tpf_glmod function must be called to ensure that storage protection is set for accessing format-1 globals.
- Programs using this function should not have any pending I/O operations
outstanding because this function may perform the equivalent of a
waitcfunction. - This function performs the equivalent of the SYNCC macro. See z/TPF General Services for more information about the SYNCC macro.
- Use this function only with z/TPF format-1 globals. To lock z/TPF format-2 globals, use the tpf_glOpen function.
Examples
The following example locks and updates
a global field that can be synchronized.
#include <tpf/tpfglbl.h>
#include <tpf/c_globz.h>
⋮
{
/******************************************************************/
/* Increment data element mysdata in synchronizable global record */
/* _mysglob. */
/******************************************************************/
struct mysglbrec **msgrptrptr = glob_lock(_mysglob);
struct mysglbrec *msgrptr = *msgrptrptr;
long newdata = msgrptr->mysdata + 1;
msgrptr->mysdata = newdata;
glob_sync(_mysglob);
}