简体   繁体   English

每个从sched_getscheduler(pid)返回int值的调度策略对应于什么? [C]

[英]What scheduling policy does each return int value from sched_getscheduler(pid) correspond to? [C]

When I use the following code to set the scheduling policy to Deadline: 当我使用以下代码将调度策略设置为“截止日期”时:

struct sched_attr attr = {
          .size = sizeof(attr),
          .sched_policy = SCHED_DEADLINE,
          .sched_runtime = 30000000,
          .sched_period = 100000000,
          .sched_deadline = 100000000
      };

  pid_t pid = getpid();
    printf("pid=(%d)\n",pid);

  if (sched_setattr(pid, &attr, 0)){
    printf("[ERROR] sched_setattr()\n");
    perror("[ERROR] sched_setattr()\n");
  }

  // Check scheduler policy is set correctly
  printf("Scheduler Policy is %d.\n", sched_getscheduler(pid));

The result of the aformentioned code is as follows: 上述代码的结果如下:

pid=(XXXXXX) pid =(XXXXXX)

Scheduler Policy is 6. 计划程序策略为6。

Can someone explain which return int value from sched_getscheduler(pid) corresponds to which scheduler policy? 有人可以解释sched_getscheduler(pid)的哪个返回int值对应于哪个调度程序策略吗?

For example: From the aforementioned code I believe 6 corresponds to SCHED_DEADLINE policy. 例如:从上述代码中,我相信6对应于SCHED_DEADLINE策略。

You can find out things like this easily yourself on your system like for example that: 您可以自己在系统上轻松找到类似这样的内容,例如:

$ grep -r SCHED_DEADLINE /usr/include/ 
/usr/include/linux/sched.h:
#define SCHED_DEADLINE      6
$ grep define.SCHED_ /usr/include/linux/sched.h 
#define SCHED_NORMAL        0
#define SCHED_FIFO      1
#define SCHED_RR        2
#define SCHED_BATCH     3
#define SCHED_IDLE      5
#define SCHED_DEADLINE      6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用SCHED_RR调度策略运行的线程对sched_yield()的影响 - Effects of sched_yield() from a thread running with SCHED_RR scheduling policy struct sched_domain在include / linux / sched.h中的含义(在内核中调度域) - what does struct sched_domain stands for in include/linux/sched.h (scheduling domains in kernel) 如果我的调度策略是SCHED_OTHER,则使用setpriority()是否会产生任何影响 - Does using setpriority() have any affect if my scheduling policy is SCHED_OTHER SCHED_OTHER 调度策略的优先级 - Priority levels of SCHED_OTHER scheduling policy 如果main()没有返回int值会发生什么? - What happens if main() does not return an int value? 设置调度策略 SCHED_IDLE 或 SCHED_BATCH 失败并显示 EINVAL (22) - Setting scheduling policy SCHED_IDLE or SCHED_BATCH fails with EINVAL (22) 使用调度策略标志SCHED_BATCH或SCHED_IDLE会产生错误 - Usage of scheduling policy flags SCHED_BATCH or SCHED_IDLE gives error linux kernel / sched.c-find_process_by_pid-如何从ac应用程序代码使用它 - linux kernel/sched.c - find_process_by_pid - how to use it from a c application code 为什么getpid()返回pid_t而不是int? - Why does getpid() return pid_t instead of int? 设置主线程时,pthread_create返回EAGAIN sched_deadline调度策略 - pthread_create returns EAGAIN when the main thread is set sched_deadline scheduling policy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM