Compute resource manager
Compute resource manager API
section for autonomous thread id preemption

Functions

static int HAP_compute_res_tid_preemption_lock (void)
 
static int HAP_compute_res_tid_preemption_unlock (void)
 

Detailed Description

API to enter and exit critical section to prevent autonomous thread identifiers based preemption (HAP_COMPUTE_RES_THREADS_FOR_AUTONOMOUS_PREEMPTION) from resource manager when acquiring global mutexes (used in I/O, standard library functions like printf, user implemented serialization etc.)

Function Documentation

◆ HAP_compute_res_tid_preemption_lock()

static int HAP_compute_res_tid_preemption_lock ( void  )
inlinestatic

API to enter critical section to prevent autonomous thread identifiers based preemption (HAP_COMPUTE_RES_THREADS_FOR_AUTONOMOUS_PREEMPTION) from resource manager when acquiring global mutexes (used in I/O, standard library functions like printf, user implemented serialization etc.)

On architectures supporting HAP_COMPUTE_RES_THREADS_FOR_AUTONOMOUS_PREEMPTION, holding global mutexes can lead to deadlocks within the preempted task's user process. The critical section exposed by this API should be implemented by users around I/O, logging or any standard libraries/user implementations which acquires global mutexes.

Implementation uses a per-process global mutex, callers of this API will be serialized across threads within the caller user process on NSP.

NOTE: The critical section implementation should only be done when,

  • HAP_COMPUTE_RES_THREADS_FOR_AUTONOMOUS_PREEMPTION is supported
  • Applications with different priorities co-exist in a single user process exposing the risk of deadlock between a running and preempted application.
Returns
0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.

◆ HAP_compute_res_tid_preemption_unlock()

static int HAP_compute_res_tid_preemption_unlock ( void  )
inlinestatic

Releases the critical section acquired by HAP_compute_res_tid_preemption_lock().

Returns
0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.