I am creating two threads in audio primary Hal with SCHED_FIFO policy but is failing to create the thread, it seems it require SYS_NICE capability. So how to provide CAP_SYS_NICE capability for audio primary Hal. Thanks in advance for the response
I see the code for creating SCHED_FIFO thread in audio hal:
//create rx task, use real time thread.
schParam.sched_priority = 3;
adev->b_sco_rx_running = true;
ret = pthread_create(&tid_sco_rx, &attr, sco_rx_task, (void *)adev);
It should be fine to imitate this code
In our android audio hal, 2 threads with SCHED_FIFO type will be also created.
SCHED_FIFO implements a simple, first-in-first-out scheduling algorithm, it does not use time slices.
The SCHED_FIFO level process is scheduled before any SCHED_NORMAL level process. Once a SCHED_FIFO level process is in an executable state, it will continue to execute until it blocks itself or explicitly releases the processor; it is not based on time slices and can be executed forever. Only the higher priority SCHED_FIFO or SCHED_RR task can preempt the SCHED_FIFO task. If there are two or more SCHED_FIFO-level processes, they will execute in turn, but will give up again when they are willing to give up the processor.
As long as a SCHED_FIFO-level process is executing, other lower-level processes can only have a chance to execute after it ends.
Hope this information is helpful to you.
Have a nice day!