--- /etc/oar/job_resource_manager_cgroups_memory.pl	2013-06-03 15:55:30.282952914 +0200
+++ /etc/oar/job_resource_manager_cgroups_memory_ht.pl	2014-07-07 14:36:44.730720175 +0200
@@ -32,6 +32,8 @@
 my $Old_umask = sprintf("%lo",umask());
 umask(oct("022"));
 
+my $hyperthreading_type = "ht";
+
 my $Cgroup_mount_point = "/dev/oar_cgroups";
 my $Cpuset;
 my $Log_level;
@@ -191,6 +193,16 @@
             exit_myself(5,"Failed to create and feed the cpuset $Cpuset_path_job");
         }
 
+        # Hyperthreading job
+        if (defined($Cpuset->{types}->{$hyperthreading_type}) and  ! system('diff '.$Cgroup_directory_collection_links.'/cpuset/cpuset.cpus '.$Cgroup_directory_collection_links.'/cpuset/'.$Cpuset_path_job.'/cpuset.cpus > /dev/null 2>&1')) {
+          if (system( 'oardodo /usr/sbin/ht on && 
+                   cat '.$Cgroup_directory_collection_links.'/cpuset/cpuset.cpus > '.$Cgroup_directory_collection_links.'/cpuset/'.$Cpuset->{cpuset_path}.'/cpuset.cpus &&
+                   cat '.$Cgroup_directory_collection_links.'/cpuset/cpuset.cpus > '.$Cgroup_directory_collection_links.'/cpuset/'.$Cpuset_path_job.'/cpuset.cpus')) {
+                exit_myself(19,"Failed to activate hyperthreading");
+              }
+         }
+            
+ 
         # Tag network packets from processes of this job
         if (system( '/bin/echo '.$Cpuset->{job_id}.' | cat > '.$Cgroup_directory_collection_links.'/net_cls/'.$Cpuset_path_job.'/net_cls.classid'
                   )){
@@ -476,6 +488,12 @@
         system("oardodo find /tmp/. /dev/shm/. /var/tmp/. -user $Cpuset->{job_user} -delete");
         system("oardodo /usr/sbin/userdel -f $Cpuset->{job_user}");
     }
+    # Hyperthreading job
+    if (defined($Cpuset->{types}->{$hyperthreading_type})) {
+      if(system('oardodo /usr/sbin/ht off')) {
+        exit_myself(20,"Failed disabling hyper threading");
+      }
+    }
 }else{
     exit_myself(3,"Bad command line argument $ARGV[0]");
 }