Function: notify_get_export_key
Applicability
Product |
Supported (√/x) |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
x |
Function Usage
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. Before calling this API, call acl.rt.device_enable_peer_access to enable data exchange between two 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 acl.rt.create_notify to create a Notify.
- Call acl.rt.notify_get_export_key to export the key (Notify share name).
- Obtain the ID of process B and call acl.rt.notify_set_import_pid to add the ID of process B to the trustlist.
- Call acl.rt.wait_and_reset_notify to deliver a wait task.
- Call acl.rt.destroy_notify to destroy the Notify. All processes involving IPC Notify need to release Notify. The release occurs only when every involved process finishes its part of the operation.
- In process B:
- Call acl.rt.device_get_bare_tgid to obtain the ID of process B. This API adapts to both PMs 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 acl.rt.notify_import_by_key to obtain the key information and return the Notify pointer that can be used by the current process. Before calling acl.rt.notify_import_by_key, ensure that IPC Notify cannot be released in advance.
- Call acl.rt.record_notify to deliver a record task.
- Call acl.rt.destroy_notify to destroy the Notify.
Prototype
- C Prototype
aclError aclrtNotifyGetExportKey(aclrtNotify notify, char *key, size_t len, uint64_t flag)
- Python Function
1key, ret = acl.rt.notify_get_export_key(notify, len, flags)
Parameter Description
Parameter |
Description |
|---|---|
notify |
Int, pointer address of the Notify. |
len |
Int, length of the Notify share name. The minimum value is 65. |
flags |
Int, whether to enable process trustlist verification. The values are as follows:
|
Return Value Description
Return Value |
Description |
|---|---|
key |
Str, Notify share name. |
ret |
Int, 0 on success; else, failure. |
Restrictions
This operation is not supported in the Ascend virtual instance scenario.