- 论坛徽章:
- 0
|
自己创建实时进程的步骤如下:(但是总是失败,求大神告知原因)、
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main()
{
int rc,old_scheduler_policy;
struct sched_param my_params;
old_scheduler_policy=sched_getscheduler(getpid()); // 返回值为0,表示是普通进程,采用SCHED_OTHER调度策略
my_params.sched_priority=sched_get_priority_max(SCHED_RR); // 尽可能高的实时优先级
printf("press any key to change the current scheduler and priority to SCHED_RR\n");
getchar();
rc=sched_setscheduler(getpid(),SCHED_RR,&my_params);
if(rc<0)
{
perror("sched_setscheduler to SCHED_RR error");
exit(0);
}
return 0;
}
1. 创建实时进程失败了,为什么,应该如何来创建实时进程呢?
2. 执行main函数的进程调度策略是SCHED_OTHER,通过ps -elcf查看该进程的PRI,发现为19,普通进程的优先级不是在[100,139]范围么? |
|