我需要改变一个sched过程'通过创建和调用系统调用来状态。这是我的do_settickets系统调用代码。
#include <stdio.h>
#include "pm.h"
#include "../sched/sched.h"
#include "../sched/schedproc.h"
#include <assert.h>
#include <minix/com.h>
#include <machine/archtypes.h>
#include <stdlib.h>
#define LOW_THRESHOLD 1
#define HIGH_THRESHOLD 30
int do_settickets(void){
struct schedproc *rpm;
int set_ticket = m_in.m1_i2; // get wanted set ticket value from message
int index = m_in.m1_i1; //get processIndex
rpm = &schedproc[index];
if(set_ticket < LOW_THRESHOLD){
rpm->ticket = LOW_THRESHOLD;
}else if(set_ticket > HIGH_THRESHOLD){
rpm->ticket = HIGH_THRESHOLD;
}else{
rpm->ticket = set_ticket;
}
return 1;
}
当我使用&#34; make hdboot&#34; int / usr / src / releasetools,有一个链接错误,说:
do_settickets.o: In function `do_settickets':
do_settickets.c:(.text+0x1a): undefined reference to `schedproc'
do_settickets.c:(.text+0x2d): undefined reference to `schedproc'
包含&#34; struct schedproc&#34;
的声明的头文件 GNU nano 2.4.2 File: schedproc.h
/* This table has one slot per process. It contains scheduling information
* for each process.
*/
#include <limits.h>
#include <minix/bitmap.h>
/* EXTERN should be extern except in main.c, where we want to keep the struct */
#ifdef _MAIN
#undef EXTERN
#define EXTERN
#endif
#ifndef CONFIG_SMP
#define CONFIG_MAX_CPUS 1
#endif
/**
* We might later want to add more information to this table, such as the
* process owner, process group or cpumask.
*/
EXTERN struct schedproc {
endpoint_t endpoint; /* process endpoint id */
endpoint_t parent; /* parent endpoint id */
unsigned flags; /* flag bits */
int ticket;
int hasTorpil;
/* User space scheduling */
unsigned max_priority; /* this process' highest allowed priority */
unsigned priority; /* the process' current priority */
unsigned time_slice; /* this process's time slice */
unsigned cpu; /* what CPU is the process running on */
bitchunk_t cpu_mask[BITMAP_CHUNKS(CONFIG_MAX_CPUS)]; /* what CPUs is the
process allowed
to run on */
} schedproc[NR_PROCS];
/* Flag values */
#define IN_USE 0x00001 /* set when 'schedproc' slot in use */
如何在系统调用中修改schedproc数组?