【发布时间】:2011-12-22 13:06:47
【问题描述】:
我已经编写了一个系统调用,它在我之前添加的 td_sched 中设置了一个变量
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysproto.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/sched.h>
#include <sys/lock.h>
#include <sys/mutex.h>
struct set_proc_args{
pid_t pid;
struct timeval WCET;
struct timeval deadline;
};
static int set_process_slack(struct thread *tda ,struct set_proc_args * arg){
struct proc * process = pfind(arg->pid);
struct thread* td = FIRST_THREAD_IN_PROC(process);
if(process == NULL)
{
tda->td_retval[0] = -1;
return -1;
}
if(td == NULL)
{
tda->td_retval[0] = -1;
return -1;
}
PROC_LOCK_ASSERT(process, MA_OWNED);
td->td_sched->WCET = (1000000 * arg->WCET.tv_sec + arg->WCET.tv_usec);
td->td_sched->deadline =(uint64_t)( 1000000 * arg->deadline.tv_sec+arg->deadline.tv_usec);
td->td_sched->slack_mode = 1;
PROC_UNLOCK(process);
return 0;
}
所以我想在没有找到具有此 ID 的进程时返回 -1。 我已经测试并看到找到进程时代码正在运行 但如果没有找到 FreeBSD 重新启动 问题出在哪里? 其实我不知道如何正确返回-1。
【问题讨论】:
标签: kernel return-value freebsd system-calls