lib/utils: add scheduler control service
This commit is contained in:
parent
c93f95cccc
commit
b90d18b421
|
@ -17,6 +17,11 @@ ssize_t evl_log(int fd, const void *buf, size_t len);
|
|||
|
||||
int evl_printf(int fd, const char *fmt, ...);
|
||||
|
||||
int evl_sched_control(int policy,
|
||||
union evl_sched_ctlparam *param,
|
||||
union evl_sched_ctlinfo *info,
|
||||
int cpu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,7 @@ static struct sigaction orig_sigshadow, orig_sigdebug;
|
|||
|
||||
static struct evl_core_info core_info;
|
||||
|
||||
static int evl_ctlfd = -1;
|
||||
int evl_ctlfd = -1;
|
||||
|
||||
void *evl_shared_memory = NULL;
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ extern int (*arch_clock_gettime)(clockid_t clk_id,
|
|||
|
||||
extern void *evl_shared_memory;
|
||||
|
||||
extern int evl_ctlfd;
|
||||
|
||||
extern int evl_mono_clockfd;
|
||||
|
||||
extern int evl_real_clockfd;
|
||||
|
|
30
lib/utils.c
30
lib/utils.c
|
@ -5,11 +5,17 @@
|
|||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <evenless/thread.h>
|
||||
#include <evenless/syscall.h>
|
||||
#include <evenless/utils.h>
|
||||
#include <uapi/evenless/sched.h>
|
||||
#include <uapi/evenless/control.h>
|
||||
#include "internal.h"
|
||||
|
||||
ssize_t evl_log(int fd, const void *buf, size_t len)
|
||||
|
@ -32,3 +38,27 @@ int evl_printf(int fd, const char *fmt, ...)
|
|||
|
||||
return evl_log(fd, buf, len);
|
||||
}
|
||||
|
||||
int evl_sched_control(int policy,
|
||||
union evl_sched_ctlparam *param,
|
||||
union evl_sched_ctlinfo *info,
|
||||
int cpu)
|
||||
{
|
||||
struct evl_sched_ctlreq ctlreq;
|
||||
int ret;
|
||||
|
||||
if (evl_ctlfd < 0)
|
||||
return -ENXIO;
|
||||
|
||||
ctlreq.policy = policy;
|
||||
ctlreq.cpu = cpu;
|
||||
ctlreq.param = param;
|
||||
ctlreq.info = info;
|
||||
|
||||
if (evl_is_inband())
|
||||
ret = ioctl(evl_ctlfd, EVL_CTLIOC_SCHEDCTL, &ctlreq);
|
||||
else
|
||||
ret = oob_ioctl(evl_ctlfd, EVL_CTLIOC_SCHEDCTL, &ctlreq);
|
||||
|
||||
return ret ? -errno : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue