Commit cab30346 authored by Philippe Gerum's avatar Philippe Gerum

lib/cobalt: introduce sched_getconfig_np()

parent 3dbaac04
......@@ -20,6 +20,7 @@
#pragma GCC system_header
#include_next <sched.h>
#include <sys/types.h>
#include <cobalt/wrappers.h>
#include <cobalt/uapi/sched.h>
......@@ -41,17 +42,15 @@ int __sched_cpucount(size_t __setsize, const cpu_set_t *__setp);
void __sched_cpufill(size_t __setsize, cpu_set_t *__setp);
#endif /* !CPU_COUNT */
#define sched_tp_confsz(nr_win) \
(sizeof(struct __sched_config_tp) + nr_win * sizeof(struct sched_tp_window))
#define sched_quota_confsz() sizeof(struct __sched_config_quota)
#ifdef __cplusplus
extern "C" {
#endif
int sched_setconfig_np(int cpu, int policy,
union sched_config *config, size_t len);
const union sched_config *config, size_t len);
ssize_t sched_getconfig_np(int cpu, int policy,
union sched_config *config, size_t *len_r);
#ifdef __cplusplus
}
......
......@@ -62,6 +62,9 @@ struct __sched_config_tp {
struct sched_tp_window windows[0];
};
#define sched_tp_confsz(nr_win) \
(sizeof(struct __sched_config_tp) + nr_win * sizeof(struct sched_tp_window))
#ifndef SCHED_QUOTA
#define SCHED_QUOTA 12
#define sched_quota_group sched_u.quota.__sched_group
......@@ -74,7 +77,8 @@ struct __sched_quota_param {
enum {
sched_quota_add,
sched_quota_remove,
sched_quota_set
sched_quota_set,
sched_quota_get,
};
struct __sched_config_quota {
......@@ -90,8 +94,15 @@ struct __sched_config_quota {
int quota;
int quota_peak;
} set;
struct {
int tgid;
int *quota_r;
int *quota_peak_r;
} get;
};
#define sched_quota_confsz() sizeof(struct __sched_config_quota)
struct sched_param_ex {
int sched_priority;
union {
......
......@@ -112,5 +112,6 @@
#define sc_cobalt_event_sync 91
#define sc_cobalt_event_destroy 92
#define sc_cobalt_sched_setconfig_np 93
#define sc_cobalt_sched_getconfig_np 94
#endif /* !_COBALT_UAPI_SYSCALL_H */
......@@ -438,13 +438,29 @@ int pthread_probe_np(pid_t tid)
}
int sched_setconfig_np(int cpu, int policy,
union sched_config *config, size_t len)
const union sched_config *config, size_t len)
{
return -XENOMAI_SKINCALL4(__cobalt_muxid,
sc_cobalt_sched_setconfig_np,
cpu, policy, config, len);
}
ssize_t sched_getconfig_np(int cpu, int policy,
union sched_config *config, size_t *len_r)
{
ssize_t ret;
ret = XENOMAI_SKINCALL4(__cobalt_muxid,
sc_cobalt_sched_getconfig_np,
cpu, policy, config, *len_r);
if (ret < 0)
return -ret;
*len_r = ret;
return 0;
}
COBALT_IMPL(int, pthread_kill, (pthread_t thread, int sig))
{
int ret;
......
......@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <memory.h>
#include <malloc.h>
#include <unistd.h>
#include <signal.h>
......@@ -94,7 +95,7 @@ int main(int argc, char **argv)
sigset_t mask, oldmask;
union sched_config *p;
size_t len;
int ret;
int ret, n;
mlockall(MCL_CURRENT | MCL_FUTURE);
......@@ -150,6 +151,22 @@ int main(int argc, char **argv)
if (ret)
error(1, ret, "sched_setconfig_np");
memset(p, 0xa5, len);
ret = sched_getconfig_np(0, SCHED_TP, p, &len);
if (ret)
error(1, ret, "sched_getconfig_np");
printf("check: %d windows\n", p->tp.nr_windows);
for (n = 0; n < 4; n++)
printf("[%d] offset = { %ld s, %ld ns }, duration = { %ld s, %ld ns }, ptid = %d\n",
n,
p->tp.windows[n].offset.tv_sec,
p->tp.windows[n].offset.tv_nsec,
p->tp.windows[n].duration.tv_sec,
p->tp.windows[n].duration.tv_nsec,
p->tp.windows[n].ptid);
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
signal(SIGINT, cleanup);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment