aclrtNotifyGetExportKey
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
☓ |
|
√ |
|
√ |
Description
Sets a specified Notify object in the current process as an inter-process communication (IPC) one, and returns the key (Notify share name) to synchronize tasks between processes on multiple devices.
This API must be used together with the key APIs described below. The following uses process A on device 0 and process B on device 1 as an example to describe the API call sequence for synchronizing tasks between the two processes.
- In process A:
- Call aclrtCreateNotify to create a Notify object.
- Call aclrtNotifyGetExportKey to export the key (Notify share name).
Call aclrtNotifyGetExportKey to specify whether to enable process trustlist verification. If the verification is enabled, call aclrtNotifySetImportPid separately to add the ID of process B to the trustlist. If the verification is disabled, there is no need to call aclrtNotifySetImportPid.
- Call aclrtWaitAndResetNotify to deliver a wait task.
- Call aclrtDestroyNotify to destroy the Notify object.
All processes involving an IPC Notify object need to release the object. This object is completely released only after all processes have released it.
- In process B:
- Call aclrtDeviceGetBareTgid to obtain the ID of process B.
This API adapts to both physical machines and VMs when obtaining the process ID. You only need to call this API to obtain the process ID and use the API with other APIs to share memory. If you obtain the process ID without calling this API, an exception may occur when you use the process ID.
- Call aclrtNotifyImportByKey to obtain the key information and return the Notify pointer that can be used by the current process.
Before calling aclrtIpcMemImportByKey, ensure that the IPC Notify object cannot be freed in advance.
- Call aclrtRecordNotify to deliver a record task.
- Call aclrtDestroyNotify to destroy the Notify object.
- Call aclrtDeviceGetBareTgid to obtain the ID of process B.
Prototype
aclError aclrtNotifyGetExportKey(aclrtNotify notify, char *key, size_t len, uint64_t flags)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
notify |
Input |
Notify object. |
key |
Output |
Share name of the Notify object. |
len |
Input |
Length of the Notify share name. The minimum length is 65. |
flags |
Input |
Whether to enable process trustlist verification. The value can be either of the following macros:
The macros are defined as follows: #define ACL_RT_NOTIFY_EXPORT_FLAG_DEFAULT 0x0UL #define ACL_RT_NOTIFY_EXPORT_FLAG_DISABLE_PID_VALIDATION 0x02UL |
Returns
0 on success; else, failure. For details, see aclError.
Restrictions
This operation is not supported in the Ascend virtual instance scenario.