linuxscheduled-tasksschedulingada

What are the semantics of Ada task priorities on Linux?


Background: I'm working on porting an Ada project from Vxworks to a Linux platform. The project heavily relies on usage of Ada's dynamic task priorities.

I've done a couple experiments which have left me confused. Ada task priorities seem to have no effect on the underlying Linux priority/niceness. Two identical tasks with different priorities take equally long to complete, even when pinned to one CPU core.

Question: What are the semantics of Ada tasks on Linux? Why am I seeing no effect from setting task priorities?


Solution

  • Question: What are the semantics of Ada tasks on Linux? Why am I seeing no effect from setting task priorities?

    The first question has bascially been answered by Shark8. I figured I'd post the answer to my second question.

    Answer: Using Ada task priorities on Linux requires using a Linux "real time" scheduling algorithm. The default is typically SCHED_OTHER. pragma Time_Slice (0.0) or pragma Task_Dispatching_Policy (FIFO_Within_Priorities) will set the scheduling algorithm to SCHED_FIFO. This requires running the application as root.

    Note: I had tried setting SCHED_FIFO manually using chrt on the running process, which did not work.

    Details: https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/platform_specific_information.html#index-10