diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-30 16:56:45 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-30 16:56:45 +0200 |
commit | c37cbdc310038863a55e9f4a4669dbba964f289e (patch) | |
tree | b835d16538f8d08c37359d2bcd6b1863c3b2195e /gcc/ada/s-taprop-linux.adb | |
parent | f8dd28d62d1d014c1599b1a345d7bab0ede255ab (diff) | |
download | gcc-c37cbdc310038863a55e9f4a4669dbba964f289e.zip gcc-c37cbdc310038863a55e9f4a4669dbba964f289e.tar.gz gcc-c37cbdc310038863a55e9f4a4669dbba964f289e.tar.bz2 |
[multiple changes]
2011-08-30 Jose Ruiz <ruiz@adacore.com>
* s-taskin.ads (Common_ATCB): Add field domain which contains the
dispatching domain to which the task belongs.
* s-taskin.adb (Initialize): Create the default system dispatching
domain and make the environment task part of it.
* s-mudido.ads: Add this new spec for standard Ada 2012 package
Ada.Multiprocessors.Dispatching_Domains.
* s-mudido.adb: Add this new body for targets not supporting
dispatching domains.
* s-mudido-affinity.adb: Add this new body for targets supporting
dispatching domains setting the affinity to a CPU set.
* bindgen.adb (Dispatching_Domain_Used, Check_Dispatching_Domains_Used,
Gen_Adainit): When package System.Multiprocessors.Dispatching_Domains
is used we call the procedure to signal that when we are about to call
the main subprogram no new dispatching domain can be created.
(Check_File_In_Partition): Factor out the common functionality used by
Check_System_Restrictions_Used and Check_Dispatching_Domains_Used.
* s-tassta.adb (Create_Task): Tasks inherit the dispatching domain of
their activators.
* s-taprop.ads (Set_Task_Affinity): Add this new procedure to set task
affinities.
* s-taprop-dummy.adb, s-taprop-hpux-dce.adb, s-taprop-irix.adb,
s-taprop-posix.adb, s-taprop-tru64.adb, s-taprop-vms.adb
(Set_Task_Affinity): Dummy null body for these targets not supporting
task affinities.
s-taprop-linux.adb, s-taprop-mingw.adb, s-taprop-solaris.adb,
s-taprop-vxworks.adb (Create_Task, Enter_Task, Initialize): Handle
dispatching domains and set the affinity of the environment task.
(Set_Task_Affinity): Procedure that uses the underlying CPU set
functionality to handle dispatching domains, pragma CPU and Task_Info.
s-winext.ads (SetThreadAffinityMask): Import this function needed to
set CPU masks.
* s-osinte-solaris.ads (psetit_t, pset_create, pset_assign, pset_bind):
Import the functionality to handle CPU set affinities.
* affinity.c: New file.
* s-osinte-vxworks.ads, s-vxwext.ads, s-vxwext-kernel.ads,
s-vxwext-rtp.ads (taskMaskAffinitySet): Add this new spec for setting
affinity masks.
* s-vxwext.adb, s-vxwext-kernel.adb, s-vxwext-rtp.adb
(taskMaskAffinitySet): Body returning an error indicating that task
affinities are not supported.
Makefile.rtl: Indicate that s-mudido is part of libgnarl.
* gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS for VxWorks SMP,
Solaris, Windows, and {x86,PowerPC, ia64,x86_64} Linux): Use the
s-mudido-affinity.adb body which supports task affinities.
2011-08-30 Thomas quinot <quinot@adacore.com>
* sem_ch13.adb: Minor reformatting.
2011-08-30 Vincent Celier <celier@adacore.com>
* vms_conv.adb (Process_Argument): When the qualifier
/UNCHECKED_SHARED_LIB_IMPORTS is for GNAT COMPILE, do not put the
corresponding switch --unchecked-shared-lib-imports after -cargs, as it
is for gnatmake, not for the compiler.
2011-08-30 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Analyze_Quantified_Expression): Analyze iterator
specification and condition only in Semantics_Only mode. Otherwise the
analysis is done after expression has been rewritten as loop.
* sem_ch5.adb (Analyze_Iterator_Specification): Always generate a
temporary for the iterator name (the domain of iteration) because it
may need finalization actions and these must be generated outside of
the loop.
* sem_res.adb (Resolve_Quantified_Expression): Resolve only in
Semantic_Only mode.
* exp_ch4.adb (Expand_Quantified_Expression): Analyze and resolve once
rewritten as loop.
* exp_ch5.adb (Expand_Iterator_Loop): Code clean-up, now that the
iterator is always an expression.
2011-08-30 Robert Dewar <dewar@adacore.com>
* par-ch4.adb (P_Unparen_Cond_Case_Quant_Expression): New function
(P_Expression_If_OK): New spec checks parens
(P_Expression_Or_Range_Attribute_If_OK): New spec checks parens
* par.adb (P_Expression_If_OK): New spec checks parens
(P_Expression_Or_Range_Attribute_If_OK): New spec checks parens
From-SVN: r178321
Diffstat (limited to 'gcc/ada/s-taprop-linux.adb')
-rw-r--r-- | gcc/ada/s-taprop-linux.adb | 103 |
1 files changed, 89 insertions, 14 deletions
diff --git a/gcc/ada/s-taprop-linux.adb b/gcc/ada/s-taprop-linux.adb index f46736f..7296ca1 100644 --- a/gcc/ada/s-taprop-linux.adb +++ b/gcc/ada/s-taprop-linux.adb @@ -879,6 +879,27 @@ package body System.Task_Primitives.Operations is CPU_SETSIZE / 8, T.Common.Task_Info.CPU_Affinity'Access); pragma Assert (Result = 0); + + -- Handle dispatching domains + + elsif T.Common.Domain /= null then + declare + CPU_Set : aliased cpu_set_t := (bits => (others => False)); + begin + -- Set the affinity to all the processors belonging to the + -- dispatching domain. + + for Proc in T.Common.Domain'Range loop + CPU_Set.bits (Integer (Proc)) := T.Common.Domain (Proc); + end loop; + + Result := + pthread_attr_setaffinity_np + (Attributes'Access, + CPU_SETSIZE / 8, + CPU_Set'Access); + pragma Assert (Result = 0); + end; end if; -- Since the initial signal mask of a thread is inherited from the @@ -1328,24 +1349,78 @@ package body System.Task_Primitives.Operations is Abort_Handler_Installed := True; end if; - -- pragma CPU for the environment task + -- pragma CPU and dispatching domains for the environment task - if pthread_setaffinity_np'Address /= System.Null_Address - and then Environment_Task.Common.Base_CPU /= - System.Multiprocessors.Not_A_Specific_CPU - then + Set_Task_Affinity (Environment_Task); + end Initialize; + + ----------------------- + -- Set_Task_Affinity -- + ----------------------- + + procedure Set_Task_Affinity (T : ST.Task_Id) is + use type System.Multiprocessors.CPU_Range; + + begin + if pthread_setaffinity_np'Address /= System.Null_Address then declare - CPU_Set : aliased cpu_set_t := (bits => (others => False)); + CPU_Set : access cpu_set_t := null; + + Result : Interfaces.C.int; + begin - CPU_Set.bits (Integer (Environment_Task.Common.Base_CPU)) := True; - Result := - pthread_setaffinity_np - (Environment_Task.Common.LL.Thread, - CPU_SETSIZE / 8, - CPU_Set'Access); - pragma Assert (Result = 0); + -- We look at the specific CPU (Base_CPU) first, then at the + -- Task_Info field, and finally at the assigned dispatching + -- domain, if any. + + if T.Common.Base_CPU /= Multiprocessors.Not_A_Specific_CPU then + -- Set the affinity to an unique CPU + + CPU_Set := new cpu_set_t'(bits => (others => False)); + CPU_Set.bits (Integer (T.Common.Base_CPU)) := True; + + -- Handle Task_Info + + elsif T.Common.Task_Info /= null + and then T.Common.Task_Info.CPU_Affinity /= Task_Info.Any_CPU + then + CPU_Set := T.Common.Task_Info.CPU_Affinity'Access; + + -- Handle dispatching domains + + elsif T.Common.Domain /= null and then + (T.Common.Domain /= ST.System_Domain or else + T.Common.Domain.all /= (Multiprocessors.CPU'First .. + Multiprocessors.Number_Of_CPUs => True)) + then + -- Set the affinity to all the processors belonging to the + -- dispatching domain. To avoid changing CPU affinities when + -- not needed, we set the affinity only when assigning to a + -- domain other than the default one, or when the default one + -- has been modified. + + CPU_Set := new cpu_set_t'(bits => (others => False)); + + for Proc in T.Common.Domain'Range loop + CPU_Set.bits (Integer (Proc)) := T.Common.Domain (Proc); + end loop; + end if; + + -- We set the new affinity if needed. Otherwise, the new task + -- will inherit its creator's CPU affinity mask (according to + -- the documentation of pthread_setaffinity_np), which is + -- consistent with Ada's required semantics. + + if CPU_Set /= null then + Result := + pthread_setaffinity_np + (T.Common.LL.Thread, + CPU_SETSIZE / 8, + CPU_Set); + pragma Assert (Result = 0); + end if; end; end if; - end Initialize; + end Set_Task_Affinity; end System.Task_Primitives.Operations; |