gtpc2m4iC/C++ Language Support User's Guide

lockc-Lock a Resource

This function is used to lock a resource from access by another I-stream. If the lock is held by this I-stream, a dump is taken and the lock updated to show this occurrence. If the lock is held by another I-stream, the code will spin for a second or return a condition code depending on the t_lock_opt value. If the spin ends successfully, a catastrophic dump is taken. If the lock is free, this code will lock it.

Format

#include   <tpfapi.h>
int        lockc(void *lockword, enum t_lock_opt opt);

lockword
A pointer to a lock made up of 2 consecutive fullwords used for lock and trace.

opt
One of 2 possible values directing the lockc function to either spin or return a condition code when the lock is held by another I-stream. The possible values of the enumeration type t_lock_opt are LOCK_O_SPIN and LOCK_O_RETN.

Normal Return

Zero.

Error Return

4 Lock is being held by another I-stream (for LOCK_O_RETN only)

Programming Considerations

Examples

The following example attempts to lock an area in which the lock field is pointed to by table_lock_ptr. The return condition is checked.

#include <tpfapi.h>

  ·
  ·
  ·
if (lockc(table_lock_ptr,LOCK_O_RETN)!=0)
  ·
  ·
  ·

Related Information

unlkc-Unlock a Resource.