server: Use kernel support for thread affinity when available.
This commit is contained in:
parent
24036fe13a
commit
474b2e4bfb
|
@ -12127,6 +12127,7 @@ for ac_func in \
|
|||
pwrite \
|
||||
readdir \
|
||||
readlink \
|
||||
sched_setaffinity \
|
||||
sched_yield \
|
||||
select \
|
||||
setproctitle \
|
||||
|
|
|
@ -1692,6 +1692,7 @@ AC_CHECK_FUNCS(\
|
|||
pwrite \
|
||||
readdir \
|
||||
readlink \
|
||||
sched_setaffinity \
|
||||
sched_yield \
|
||||
select \
|
||||
setproctitle \
|
||||
|
|
|
@ -645,6 +645,9 @@
|
|||
/* Define to 1 if you have the <sched.h> header file. */
|
||||
#undef HAVE_SCHED_H
|
||||
|
||||
/* Define to 1 if you have the `sched_setaffinity' function. */
|
||||
#undef HAVE_SCHED_SETAFFINITY
|
||||
|
||||
/* Define to 1 if you have the `sched_yield' function. */
|
||||
#undef HAVE_SCHED_YIELD
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
#endif
|
||||
#ifdef HAVE_SCHED_H
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
|
@ -406,7 +409,26 @@ struct thread *get_thread_from_pid( int pid )
|
|||
|
||||
void set_thread_affinity( struct thread *thread, affinity_t affinity )
|
||||
{
|
||||
#ifdef HAVE_SCHED_SETAFFINITY
|
||||
if (thread->unix_pid != -1)
|
||||
{
|
||||
cpu_set_t set;
|
||||
int i;
|
||||
affinity_t mask;
|
||||
|
||||
CPU_ZERO( &set );
|
||||
for (i = 0, mask = 1; mask; i++, mask <<= 1)
|
||||
if (affinity & mask) CPU_SET( i, &set );
|
||||
|
||||
if (!sched_setaffinity( thread->unix_pid, sizeof(set), &set ))
|
||||
thread->affinity = affinity;
|
||||
else
|
||||
file_set_error();
|
||||
}
|
||||
else set_error( STATUS_ACCESS_DENIED );
|
||||
#else
|
||||
thread->affinity = affinity;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define THREAD_PRIORITY_REALTIME_HIGHEST 6
|
||||
|
|
Loading…
Reference in New Issue