我正在尝试修改Minix 3中的schedule.c文件( /usr/src/minix/servers/sched/schedule.c )。对于每个耗尽它的时间段的进程,我都想看看系统运行了多少时间。因此,我想在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);
...但是我不知道正确的类型和功能。此外,也许还有另一种更好的方法。
发布于 2017-05-20 21:33:11
您可以在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参数的指针提供给它,它会用正确的信息填充这些指针。
https://stackoverflow.com/questions/43913623
复制相似问题