Skip to content
Snippets Groups Projects
Commit 82ed6ed6 authored by Ronan Desplanques's avatar Ronan Desplanques Committed by Marc Poulhiès
Browse files

ada: Tweak CPU affinity handling on Linux

Before this patch, the run-time assumed that not specifying a CPU
affinity mask when creating a thread was equivalent to specifying a
CPU affinity mask that included all CPUs.

As documented in the man pages for pthread_create and
pthread_setaffinity_np, this assumption is incorrect: a thread created
using pthread_create inherits the CPU affinity mask of the creating
thread by default. There was a comment in Set_Task_Affinity that
acknowledged this behavior, but the actual code made the erroneous
assumption mentioned above.

That assumption caused the run-time to behave incorrectly when tasks were
explicity assigned to Not_A_Specific_CPU: those tasks were assigned to
the same CPUs as their parents instead of being allowed to run on any
CPU. This patch fixes that behavior.

This patch has the negative effect of making the runtime issue
sched_setaffinity syscalls that are not necessary.

gcc/ada/

	* libgnarl/s-taprop__linux.adb (Set_Task_Affinity, Create_Task): Tweak
	handling of CPU affinities.
parent ae250f9e
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment