0

I am running RHEL 6.4 64 bit, and I was given a program to compile and execute. The program has:

cpu_set_t cputset;
CPU_ZERO(&cpuset);
CPU_SET(data->num, &cpuset); //data is a structure, don't think it's relevant to my question
int ret = sched_setaffinity(0, sizeof(cpuset), &cpuset);
//print ret

When compiling for 32/64 bit gcc/icc, there are no compilation errors. This will return 0 and correctly produce the result when compiled with -m32 (32 bit compiler), but when compiled with a 64 bit compiler, it has returned 1, 2, and 128 seemingly randomly just by running without any recompilation. Could someone help me troubleshoot / identify what is going wrong with this when I compile it for 64 bit and execute? Thanks for any help.

user3000724
  • 651
  • 3
  • 11
  • 22
  • Positive values aren't even a documented return value for `sched_setaffinity()` (it should return 0 on success or -1 on failure). Are you sure this is right? Are there maybe some weird linker issues going on? – TypeIA Jan 15 '14 at 22:03
  • I just redownloaded the source code to ensure it was what I was given, I compiled with icc 64-bit version WITH -m32 (so it used the ia32 icc) . I ran the executable and ret = 0 on all printouts. Then I removed the -m32 flag still using the intel64 icc and when running, I get ret = 1, 2, or 4 while it iterates through a nested loop. Any ideas why? – user3000724 Jan 15 '14 at 22:13

0 Answers0