On Apr 10 21:06, Mark Geisert wrote: > --- > newlib/libc/include/sched.h | 4 +++ > winsup/cygwin/sched.cc | 68 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 72 insertions(+) > > diff --git a/newlib/libc/include/sched.h b/newlib/libc/include/sched.h > index 1016235bb..e3a5b97e5 100644 > --- a/newlib/libc/include/sched.h > +++ b/newlib/libc/include/sched.h > @@ -92,6 +92,10 @@ int sched_yield( void ); > > #if __GNU_VISIBLE > int sched_getcpu(void); > + > +typedef uint64_t cpu_set_t; /* ...until cpuset(7) exists */ > +int sched_getaffinity(pid_t, size_t, cpu_set_t *); > +int sched_setaffinity(pid_t, size_t, const cpu_set_t *); > #endif > > #ifdef __cplusplus > diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc > index 10168e641..496e08857 100644 > --- a/winsup/cygwin/sched.cc > +++ b/winsup/cygwin/sched.cc > @@ -424,4 +424,72 @@ sched_getcpu () > return pnum.Group * __get_cpus_per_group () + pnum.Number; > } > > +int > +sched_getaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *mask) > +{ > + int status = 0; > + HANDLE process = pid ? OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid) > + : GetCurrentProcess ();
This needs to grab the pinfo(pid) aund use p->dwProcessId, as you noted on cygwin-developers already. Two more notes: - You could use GetCurrentProcess() in case of pid == myself->pid, too. - PROCESS_QUERY_LIMITED_INFORMATION should be sufficent per MSDN. PROCESS_QUERY_INFORMATION was required pre-Vista only. Thanks, Corinna -- Corinna Vinschen Cygwin Maintainer
signature.asc
Description: PGP signature