aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2008-08-27 09:51:02 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2008-08-27 09:51:02 -0300
commit68a9753a7606c18db695187fb7ddd310dab383bf (patch)
tree7d82c736f4141b17cd88dc217e176a4608edbee4
parentbc5cbc2913d5f945536dd98711bdf4ced6a72a04 (diff)
downloadpython-schedutils-68a9753a7606c18db695187fb7ddd310dab383bf.tar.gz
schedutils: Implement get_priority method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--python-schedutils/schedutils.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/python-schedutils/schedutils.c b/python-schedutils/schedutils.c
index 5ecdb35..fe02782 100644
--- a/python-schedutils/schedutils.c
+++ b/python-schedutils/schedutils.c
@@ -97,6 +97,22 @@ static PyObject *set_scheduler(PyObject *self __unused, PyObject *args)
return Py_None;
}
+static PyObject *get_priority(PyObject *self __unused, PyObject *args)
+{
+ int pid;
+ struct sched_param param = { .sched_priority = -1, };
+
+ if (!PyArg_ParseTuple(args, "i", &pid))
+ return NULL;
+
+ if (sched_getparam(pid, &param) != 0) {
+ PyErr_SetFromErrno(PyExc_SystemError);
+ return NULL;
+ }
+
+ return Py_BuildValue("i", param.sched_priority);
+}
+
static PyObject *schedstr(PyObject *self __unused, PyObject *args)
{
int scheduler;
@@ -162,6 +178,11 @@ static struct PyMethodDef PySchedutilsModuleMethods[] = {
.ml_flags = METH_VARARGS,
},
{
+ .ml_name = "get_priority",
+ .ml_meth = (PyCFunction)get_priority,
+ .ml_flags = METH_VARARGS,
+ },
+ {
.ml_name = "schedstr",
.ml_meth = (PyCFunction)schedstr,
.ml_flags = METH_VARARGS,