我正在修改minix 3.1.6的内核作为我的本科OS项目的一部分,我打算首先分析之前用它实现的调度算法 在某个文件中存储每个进程的调度相关信息,可以在以后进行分析。
在修改proc.c时,我在使用fprintf()将数据存储到某个文件时得到了Multiply定义的错误,同时fopen()工作正常。
我对这一切都很陌生,所以任何帮助都将受到赞赏。 在此先感谢............
这是一段代码..
PRIVATE void sched(rp, queue, front)
register struct proc *rp; /* process to be scheduled */
int *queue; /* return: queue to use */
int *front; /* return: front or back */
{
/* This function determines the scheduling policy. It is called whenever a
* process must be added to one of the scheduling queues to decide where to
* insert it. As a side-effect the process' priority may be updated.
*/
int time_left = (rp->p_ticks_left > 0); /* quantum fully consumed */
/* Check whether the process has time left. Otherwise give a new quantum
* and lower the process' priority, unless the process already is in the
* lowest queue.
*/
if (! time_left) { /* quantum consumed ? */
rp->p_ticks_left = rp->p_quantum_size; /* give new quantum */
if (rp->p_priority < (NR_SCHED_QUEUES-1)) {
rp->p_priority += 1; /* lower priority */
}
}
FILE *fp = fopen("/usr/newlog.txt","a");
/* If there is time left, the process is added to the front of its queue,
* so that it can immediately run. The queue to use simply is always the
* process' current priority.*/
fprintf(fp,"{\nprocess name: %s\nprocess quantum: %d\ntime left: %d\nprocess queue: %d\n}\n\n",
rp->p_name,rp->p_quantum_size,rp->p_ticks_left,rp->p_priority);
*queue = rp->p_priority;
*front = time_left;
fclose(fp);
}