aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/release/3.6.04
-rw-r--r--winsup/cygwin/sched.cc11
2 files changed, 13 insertions, 2 deletions
diff --git a/winsup/cygwin/release/3.6.0 b/winsup/cygwin/release/3.6.0
index d48ee11..ad4a6f5 100644
--- a/winsup/cygwin/release/3.6.0
+++ b/winsup/cygwin/release/3.6.0
@@ -132,3 +132,7 @@ Fixes:
- Fix starving of auxiliary signal return address stack in case signal
handlers bail out (longjmp/setcontext).
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257648.html
+
+- Fix sched_getaffinity(2) to carry determined process affinity all the way
+ through to the returned result.
+ Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257616.html
diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc
index 2f4fbc3..e15daad 100644
--- a/winsup/cygwin/sched.cc
+++ b/winsup/cygwin/sched.cc
@@ -587,9 +587,16 @@ __sched_getaffinity_sys (pid_t pid, size_t sizeof_set, cpu_set_t *set)
goto done;
}
- KAFFINITY miscmask = groupmask (__get_cpus_per_group ());
+ KAFFINITY fullmask = groupmask (__get_cpus_per_group ());
+ /* if process is multi-group, we don't have processor visibility. */
+ /*TODO We could provide the missing Windows visibility by book-keeping
+ each thread's current group and mask in our thread overhead, updating
+ them on sched_set_thread_affinity() calls. We could then assemble the
+ total mask here by looping through all threads. */
+ if (groupcount > 1)
+ procmask = fullmask;
for (int i = 0; i < groupcount; i++)
- setgroup (sizeof_set, set, grouparray[i], miscmask);
+ setgroup (sizeof_set, set, grouparray[i], fullmask & procmask);
}
else
status = ESRCH;