gtpc2m0zC/C++ Language Support User's Guide

corhc-Define and Hold a Resource

This function requests exclusive control over a resource. For example, to update a storage area such as a global record that is shared across processors in a multiprocessing environment, obtaining a pointer to the global and requesting corhc against it forces serialization on the global record during update.

Format

#include   <tpfapi.h>
void       corhc(void *resource);

resource
A pointer to type void representing the resource over which exclusive control is being requested.

Normal Return

Void. Control is not returned to the issuing ECB until exclusive control over the resource is obtained.

Error Return

Not applicable.

Programming Considerations

When finished with the resource, the ECB must call coruc to free the resource. The pointer value (not the referenced value) passed to coruc must be the same as the pointer value passed to corhc. The pointer value is not required to reference a storage location.

Examples

The following example obtains a hold on global record _q05met based on the address of the record.

#include <tpfapi.h>
#include <tpfglbl.h>
#include <c$globz.h>
struct msgexp *q05met;

  ·
  ·
  ·
q05met = *(struct msgexp **) glob(_q05met); corhc(q05met);

The following example obtains a lock on the resource name ABCD.

#include <tpfapi.h>
#define RESOURCE_KEY ((void *) 0xC1C2C3C4)

  ·
  ·
  ·
corhc(RESOURCE_KEY);

Related Information