提交 4b667751 编写于 作者: 些猜's avatar 些猜

扩展了与进程策略设置相关的函数

Signed-off-by: 些猜's avatarcaifuzhou <504631861@qq.com>
上级 47812782
......@@ -9,18 +9,24 @@
int main(int argc,char *argv[])
{
struct sched_param param;
int maxpri;
maxpri = sched_get_priority_max(SCHED_FIFO);
if(maxpri == -1)
int maxpri,minpri;
int sched;
pid_t pid;
sched = SCHED_FIFO;
pid = getpid();
maxpri = sched_get_priority_max(sched);
minpri = sched_get_priority_min(sched);
if(maxpri == -1 || minpri == -1)
{
perror("get priority failed");
perror("get maxpriority or minpriority failed");
return -1;
}
param.sched_priority = maxpri;
TEST(sched_setscheduler(getpid(), SCHED_FIFO, &param));
TEST(!(sched_getscheduler(getpid()) == SCHED_FIFO));
param.sched_priority = 23;//取值范围:minpri~maxpri
TEST(sched_setscheduler(pid, sched, &param));
TEST(!(sched_getscheduler(pid) == sched));
TEST(sched_getparam(pid, &param));
return 0;
}
......@@ -1838,7 +1838,10 @@ musl_src_porting_file = [
"src/multibyte/wcsnrtombs.c",
"src/network/inet_legacy.c",
"src/passwd/getspnam_r.c",
"src/sched/sched_setparam.c",
"src/sched/sched_getparam.c",
"src/sched/sched_setscheduler.c",
"src/sched/sched_getscheduler.c",
"src/thread/arm/clone.s",
"src/thread/arm/syscall_cp.s",
]
#include <sched.h>
#include <errno.h>
#include "syscall.h"
#include <string.h>
int sched_getparam(pid_t pid, struct sched_param *param)
{
int r;
if (!param) {
r = -EINVAL;
goto exit;
}
memset(param, 0, sizeof(struct sched_param));
r = __syscall(SYS_sched_getparam, pid , param);
if (r >= 0) {
r = 0;
}
exit:
return __syscall_ret(r);
}
#include <sched.h>
#include <errno.h>
#include <string.h>
#include "syscall.h"
int sched_getscheduler(pid_t pid)
{
int r = __syscall(SYS_sched_getscheduler, pid);
return __syscall_ret(r);
}
\ No newline at end of file
#include <sched.h>
#include <errno.h>
#include <string.h>
#include "syscall.h"
int sched_setparam(pid_t pid, const struct sched_param *param)
{
int r;
if (!param) {
r = -EINVAL;
goto exit;
}
r = __syscall(SYS_sched_setparam, pid, param);
exit:
return __syscall_ret(r);
}
\ No newline at end of file
......@@ -10,11 +10,7 @@ int sched_setscheduler(pid_t pid, int sched, const struct sched_param *param)
r = -EINVAL;
goto exit;
}
r = __syscall(SYS_sched_setscheduler, pid , sched , param->sched_priority);
;
r = __syscall(SYS_sched_setscheduler, pid , sched , param);
exit:
return __syscall_ret(r);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册