Cygwin: Implement sched_[gs]etaffinity()
This patch set implements the Linux syscalls sched_getaffinity, sched_setaffinity, pthread_getaffinity_np, and pthread_setaffinity_np. Linux has a straightforward view of the cpu sets used in affinity masks. They are simply long (1024-bit) bit masks. This code emulates that view while internally dealing with Windows' distribution of available CPUs among processor groups.
This commit is contained in:
committed by
Corinna Vinschen
parent
d54edfdf81
commit
641ecb0753
@@ -23,6 +23,7 @@ details. */
|
||||
#include "winsup.h"
|
||||
#include "miscfuncs.h"
|
||||
#include "path.h"
|
||||
#include <sched.h>
|
||||
#include <stdlib.h>
|
||||
#include "sigproc.h"
|
||||
#include "fhandler.h"
|
||||
@@ -2606,6 +2607,24 @@ pthread_timedjoin_np (pthread_t thread, void **return_val,
|
||||
return pthread::join (&thread, (void **) return_val, &timeout);
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
pthread_getaffinity_np (pthread_t thread, size_t sizeof_set, cpu_set_t *set)
|
||||
{
|
||||
if (!pthread::is_good_object (&thread))
|
||||
return ESRCH;
|
||||
|
||||
return sched_get_thread_affinity (thread->win32_obj_id, sizeof_set, set);
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
pthread_setaffinity_np (pthread_t thread, size_t sizeof_set, const cpu_set_t *set)
|
||||
{
|
||||
if (!pthread::is_good_object (&thread))
|
||||
return ESRCH;
|
||||
|
||||
return sched_set_thread_affinity (thread->win32_obj_id, sizeof_set, set);
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user