【发布时间】:2019-09-09 22:34:18
【问题描述】:
所以我试图在 PM 服务器上创建一个新的系统调用。我的问题是,我怎样才能发送某种消息来运行。
在 IPC 服务器中,我所要做的就是将我的系统调用添加到列表中,因为那里的所有函数都定义为 (*func)(message *)
(...)/servers/ipc/main.c
static struct {
int type;
int (*func)(message *);
int reply; /* whether the reply action is passed through */
} ipc_calls[] = {
(...)
{ IPC_MYNEWSIGNAL, do_something, 1 },
};
但是在 PM 中的 table.c 函数被定义为
(...)/servers/pm/table.c
int (* const call_vec[NR_PM_CALLS])(void) = {
(...)
CALL(PM_GETSYSINFO) = do_getsysinfo
}
如果我尝试通过签名传递函数
int do_something(message *m)
我会得到错误:
Incompatible pointer types: initializing int (*const)(void) with int (message *)
如果我需要接收某种信息,在 PM 服务器上创建信号的正确方法是什么?
【问题讨论】:
-
如果你需要这个用于 SO :) 我认为你不需要在该数组中注册任何函数。相反,数组
mproc[NR_PROCS]仅用于获取有关进程之间关系的信息,或者您甚至可以在结构mproc中添加一些字段来跟踪时间:)
标签: c system-calls minix