我写了一个系统调用,设置一个变量,我添加td_sched早些时候我怎样才能返回比0别的东西从FreeBSD系统调用
#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;
}
所以我想返回-1时,这个过程没有ID被发现。 我测试过,看到代码正在工作,当发现进程 ,但如果它没有找到FreeBSD重新启动 问题在哪里? 其实我不知道如何正确返回-1。
感谢,这是它:) – po0ya