@@ -66,7 +66,11 @@ cpu_set_t sched_getaffinity() {
6666 return cpuset ;
6767 }
6868
69- public static void sched_setaffinity (final BitSet affinity ) {
69+ public static void sched_setaffinity (final BitSet affinity ) {
70+ sched_setaffinity (0 , affinity );
71+ }
72+
73+ public static void sched_setaffinity (final int pid , final BitSet affinity ) {
7074 final CLibrary lib = CLibrary .INSTANCE ;
7175 final cpu_set_t cpuset = new cpu_set_t ();
7276 final int size = version .isSameOrNewer (VERSION_2_6 ) ? cpu_set_t .SIZE_OF_CPU_SET_T : NativeLong .SIZE ;
@@ -80,12 +84,12 @@ public static void sched_setaffinity(final BitSet affinity) {
8084 }
8185 }
8286 try {
83- if (lib .sched_setaffinity (0 , size , cpuset ) != 0 ) {
84- throw new IllegalStateException ("sched_setaffinity(0 , " + size +
87+ if (lib .sched_setaffinity (pid , size , cpuset ) != 0 ) {
88+ throw new IllegalStateException ("sched_setaffinity(" + pid + " , " + size +
8589 ", 0x" + Utilities .toHexString (affinity ) + ") failed; errno=" + Native .getLastError ());
8690 }
8791 } catch (LastErrorException e ) {
88- throw new IllegalStateException ("sched_setaffinity(0 , " + size +
92+ throw new IllegalStateException ("sched_setaffinity(" + pid + " , " + size +
8993 ", 0x" + Utilities .toHexString (affinity ) + ") failed; errno=" + e .getErrorCode (), e );
9094 }
9195 }
0 commit comments