我想对内核进行 2 次系统调用(getlot 和 setlot)。他们必须在内核中的 struct proc 中读取并设置一些值。问题是什么?什么不见了?
在 /usr/include/minix/callnr.h 我增加了 NCALLS 并添加了 2 个定义
#define NCALLS 80 /* number of system calls allowed */
#define SETLOT 78
#define GETLOT 79
在 usr/src/mm/main.c
PUBLIC void do_setlot()
{
message msg;
msg = mm_in;
_taskcall(SYSTASK, SYS_SETLOT), &msg);
}
PUBLIC void do_getlot()
{
message msg;
msg = mm_in;
_taskcall(SYSTASK, SYS_GETLOT, &msg);
}
在 /usr/src/mm/proto.h 我添加了两个原型
_PROTOTYPE( void do_setlot, (void));
_PROTOTYPE( void do_getlot, (void));
在 /usr/src/mm/table.c 我添加到 _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) 的末尾
do_setlot,
do_getlot,
在 /usr/src/fs/table.c 我添加到_PROTOTYPE (int (*call_vec[]), (void) ) 的末尾
no_sys,
no_sys,
在 /usr/include/minix/com.h 我创建了 2 SYS_xxx 定义
# define SYS_SETLOT 22
# define SYS_GETLOT 23
在 /usr/src/kernel/system.c 我写了
FORWARD _PROTOTYPE( int do_procsetlot, (message *m_ptr) );
FORWARD _PROTOTYPE( int do_procgetlot, (message *m_ptr) );
然后添加 SYS_xxx 来切换 PUBLIC void sys_task()
case SYS_SETLOT: r = do_procsetlot(&m); break;
case SYS_GETLOT: r = do_procgetlot(&m); break;
在底部我写了2个定义
PRIVATE int do_procsetlot(m_ptr)
register message *m_ptr;
{
pid_t prid;
int i;
int tickets;
prid = m_ptr->m1_i1;
tickets = m_ptr->m1_i2;
if(tickets > LOT_MAX)
return EINVAL;
if(tickets < LOT_MIN)
return EINVAL;
for(i = 0 ; i <NR_PROCS; i++)
{
if(proc[i].p_pid == prid)
{
proc[i].tickets_number = tickets;
return 0;
}
{
return EINVAL;
}
PRIVATE int do_procgetlot(m_ptr)
register message *m_ptr;
{
int i;
pid_t prid;
prid = m_ptr->m1_i1;
for(i = 0 ; i< NR_PROCS; i++)
{
if(proc[i].p_pid == prid)
return proc[i].tickets_number;
}
return EINVAL;
}
最后在make hdboot之后我得到了错误:
exec cc -c -I/usr/include main.c
exec cc -c -I/usr/include proc.c
exec cc -c -I/usr/include system.c
"system.c", line 1260: static not expected
make in /usr/src/kernel: Exit code 1
第 1260 行是
PRIVATE int do_procgetlot(m_ptr)