@@ -4585,6 +4585,8 @@ posix_sched_get_priority_min(PyObject *self, PyObject *args)
45854585 return PyLong_FromLong (min );
45864586}
45874587
4588+ #ifdef HAVE_SCHED_SETSCHEDULER
4589+
45884590PyDoc_STRVAR (posix_sched_getscheduler__doc__ ,
45894591"sched_getscheduler(pid)\n\n\
45904592Get the scheduling policy for the process with a PID of *pid*.\n\
@@ -4604,6 +4606,10 @@ posix_sched_getscheduler(PyObject *self, PyObject *args)
46044606 return PyLong_FromLong (policy );
46054607}
46064608
4609+ #endif
4610+
4611+ #if defined(HAVE_SCHED_SETSCHEDULER ) || defined(HAVE_SCHED_SETPARAM )
4612+
46074613static PyObject *
46084614sched_param_new (PyTypeObject * type , PyObject * args , PyObject * kwargs )
46094615{
@@ -4656,6 +4662,10 @@ convert_sched_param(PyObject *param, struct sched_param *res)
46564662 return 1 ;
46574663}
46584664
4665+ #endif
4666+
4667+ #ifdef HAVE_SCHED_SETSCHEDULER
4668+
46594669PyDoc_STRVAR (posix_sched_setscheduler__doc__ ,
46604670"sched_setscheduler(pid, policy, param)\n\n\
46614671Set the scheduling policy, *policy*, for *pid*.\n\
@@ -4677,6 +4687,10 @@ posix_sched_setscheduler(PyObject *self, PyObject *args)
46774687 Py_RETURN_NONE ;
46784688}
46794689
4690+ #endif
4691+
4692+ #ifdef HAVE_SCHED_SETPARAM
4693+
46804694PyDoc_STRVAR (posix_sched_getparam__doc__ ,
46814695"sched_getparam(pid) -> sched_param\n\n\
46824696Returns scheduling parameters for the process with *pid* as an instance of the\n\
@@ -4724,6 +4738,10 @@ posix_sched_setparam(PyObject *self, PyObject *args)
47244738 Py_RETURN_NONE ;
47254739}
47264740
4741+ #endif
4742+
4743+ #ifdef HAVE_SCHED_RR_GET_INTERVAL
4744+
47274745PyDoc_STRVAR (posix_sched_rr_get_interval__doc__ ,
47284746"sched_rr_get_interval(pid) -> float\n\n\
47294747Return the round-robin quantum for the process with PID *pid* in seconds." );
@@ -4741,6 +4759,8 @@ posix_sched_rr_get_interval(PyObject *self, PyObject *args)
47414759 return PyFloat_FromDouble ((double )interval .tv_sec + 1e-9 * interval .tv_nsec );
47424760}
47434761
4762+ #endif
4763+
47444764PyDoc_STRVAR (posix_sched_yield__doc__ ,
47454765"sched_yield()\n\n\
47464766Voluntarily relinquish the CPU." );
@@ -10054,11 +10074,21 @@ static PyMethodDef posix_methods[] = {
1005410074#ifdef HAVE_SCHED_H
1005510075 {"sched_get_priority_max" , posix_sched_get_priority_max , METH_VARARGS , posix_sched_get_priority_max__doc__ },
1005610076 {"sched_get_priority_min" , posix_sched_get_priority_min , METH_VARARGS , posix_sched_get_priority_min__doc__ },
10077+ #ifdef HAVE_SCHED_SETPARAM
1005710078 {"sched_getparam" , posix_sched_getparam , METH_VARARGS , posix_sched_getparam__doc__ },
10079+ #endif
10080+ #ifdef HAVE_SCHED_SETSCHEDULER
1005810081 {"sched_getscheduler" , posix_sched_getscheduler , METH_VARARGS , posix_sched_getscheduler__doc__ },
10082+ #endif
10083+ #ifdef HAVE_SCHED_RR_GET_INTERVAL
1005910084 {"sched_rr_get_interval" , posix_sched_rr_get_interval , METH_VARARGS , posix_sched_rr_get_interval__doc__ },
10085+ #endif
10086+ #ifdef HAVE_SCHED_SETPARAM
1006010087 {"sched_setparam" , posix_sched_setparam , METH_VARARGS , posix_sched_setparam__doc__ },
10088+ #endif
10089+ #ifdef HAVE_SCHED_SETSCHEDULER
1006110090 {"sched_setscheduler" , posix_sched_setscheduler , METH_VARARGS , posix_sched_setscheduler__doc__ },
10091+ #endif
1006210092 {"sched_yield" , posix_sched_yield , METH_NOARGS , posix_sched_yield__doc__ },
1006310093#ifdef HAVE_SCHED_SETAFFINITY
1006410094 {"sched_setaffinity" , posix_sched_setaffinity , METH_VARARGS , posix_sched_setaffinity__doc__ },
0 commit comments