Manage the process of resource acquisition and release
◆ HAP_compute_res_acquire()
static unsigned int HAP_compute_res_acquire |
( |
compute_res_attr_t * |
attr, |
|
|
unsigned int |
timeout_us |
|
) |
| |
|
inlinestatic |
Accepts a prepared attribute structure (attr) and returns a context ID for a successful request within the provided timeout (microseconds).
- Parameters
-
[in] | attr | Pointer to compute the resource attribute structure compute_res_attr_t. |
[in] | timeout_us | Timeout in microseconds; 0 specifies no timeout i.e., requests with unavailable resources immediately return failure. If nonzero, should be at least 200. |
- Returns
- Nonzero context ID upon success.
0 upon failure (i.e., unable to acquire requested resource in a given timeout duration).
◆ HAP_compute_res_acquire_cached()
static int HAP_compute_res_acquire_cached |
( |
unsigned int |
context_id, |
|
|
unsigned int |
timeout_us |
|
) |
| |
|
inlinestatic |
Acquires or reacquires the resources pointed to the context_id returned by a successful HAP_compute_res_acquire() call. If VTCM resource was requested, the VTCM address, size, and page configuration remain the same.
Supported from Lahaina.
- Parameters
-
[in] | context_id | Context ID returned by HAP_compute_res_acquire(). |
[in] | timeout_us | Timeout in microseconds; 0 specifies no timeout i.e., requests with unavailable resources immediately return failure. If nonzero, should be at least 200. |
- Returns
- 0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.
◆ HAP_compute_res_attr_set_release_callback()
static int HAP_compute_res_attr_set_release_callback |
( |
compute_res_attr_t * |
attr, |
|
|
int(*)(unsigned int context_id, void *client_context) |
release_callback, |
|
|
void * |
client_context |
|
) |
| |
|
inlinestatic |
Sets the release callback function in the attribute structure.
The compute resource manager calls the release_callback function when any of the resources reserved by the specified context are required by a higher priority client. Clients act on the release request by explicitly calling the release function HAP_compute_res_release() or HAP_compute_res_release_cached() to release all acquired resources of the given context_id.
Client-provided context (client_context) is passed to the release callback. On receiving a release request via the provided callback, clients should call the release function within 5 milliseconds. The release_callback function should not have any blocking wait.
Call this function after HAP_compute_res_attr_init().
Supported starting with Lahaina.
- Parameters
-
[in] | attr | Pointer to compute the resource attribute structure, compute_res_attr_t. |
[in] | release_callback | Function pointer to the registered callback to receive the release request. |
[in] | client_context | User-provided client context. |
- Returns
- 0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.
◆ HAP_compute_res_check_release_request()
static int HAP_compute_res_check_release_request |
( |
unsigned int |
context_id | ) |
|
|
inlinestatic |
Checks the release request status for the provided context. When a context is acquired by providing a release callback, the callback can be invoked by the compute resource manager when a high priority client is waiting for the resource(s). If a client defers a release request waiting for an outstanding work item, this API can be used to check if a release is still required before releasing the context once the work is done.
Note: It is not mandatory to call this API once a release request via the registered callback is received. The context can be released and reacquired if necessary. This API can be useful to avoid a release and reacquire in cases where the high priority client times out and is no longer waiting for the resource(s).
Supported starting with Lahaina.
- Parameters
-
[in] | context_id | Context ID returned by HAP_compute_res_acquire call(). |
- Returns
- 0 if the provided context need not be released.
Nonzero up on failure or if the context needs to be released.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.
◆ HAP_compute_res_release()
static int HAP_compute_res_release |
( |
unsigned int |
context_id | ) |
|
|
inlinestatic |
Releases all the resources linked to the given context ID.
Call this function with the context_id returned by a successful HAP_compute_res_acquire call().
- Parameters
-
[in] | context_id | Context ID returned by HAP_compute_res_acquire call(). |
- Returns
- 0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.
◆ HAP_compute_res_release_cached()
static int HAP_compute_res_release_cached |
( |
unsigned int |
context_id | ) |
|
|
inlinestatic |
◆ HAP_compute_res_update_priority()
static int HAP_compute_res_update_priority |
( |
unsigned int |
context_id, |
|
|
unsigned short |
priority |
|
) |
| |
|
inlinestatic |
Updates the priority of an allocated context reflecting the caller's thread priority. The compute resource manager uses the callers thread priority as the resource priority when acquired (HAP_compute_res_acquire() / HAP_compute_res_acquire_cached()). If the thread priority of the caller is changed after acquiring the resource, caller should intimate the compute resource manager of a priority change by invoking this API. Failing to do so will result in resource manager assuming an incorrect priority for the allocated resource which may result in unwanted release requests. For a cached allocation, this API should be called after a successful HAP_compute_res_acquire_cached() call.
Supported on latest chipsets(released after Palima).
- Parameters
-
[in] | context_id | Context ID returned by HAP_compute_res_acquire().. |
[in] | priority | 0 - The compute resource manager would use the caller thread priority 1..255 - priority value in terms of QuRT thread priority. Priority ceiling will be applied for unprivileged processes. |
- Returns
- 0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.