【问题标题】:Minix scheduler - how to check system time?Minix 调度程序 - 如何检查系统时间?
【发布时间】:2017-10-10 08:24:45
【问题描述】:

我正在尝试修改 Minix 3 中的 schedule.c 文件( /usr/src/minix/servers/sched/schedule.c )。对于每个用完它的进程,我想看看有多少 sys 时间通过了。所以我想在 do_noquantum() 中添加以下几行:

...
rmp = &schedproc[proc_nr_n];
minix_time_type curr_time = minix_function_to_get_curr_time();
minix_time_type time_passed = curr_time - last_time[proc_nr_n];
//last_time[NR_PROCS] is a global array
last_time[proc_nr_n] = curr_time;
do_something_with_this_knowledge(time_passed);
...

但我不知道正确的类型和功能。另外 - 也许还有另一种更好的方法。

【问题讨论】:

    标签: time scheduler scheduling minix


    【解决方案1】:

    您可以在 MINIX 中使用 syslib.h 中的 sys_times() 函数。 它有以下声明:

    int sys_times(endpoint_t proc_ep, clock_t* user_time, clock_t* sys_time, clock_t* uptime, clock_t* boottime)
    

    您将进程的端点和指向您感兴趣的clock_t参数的指针提供给它,它会用正确的信息填充指针。

    【讨论】:

      猜你喜欢
      • 2013-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-07
      相关资源
      最近更新 更多