我需要打印一条消息,告知用户已从内核调用sys_fork分叉进程。
我在sys_fork()函数中添加了命令printf("process forked\n");
但没有任何反应。
这是正确的还是我必须做其他事情?有什么帮助吗?
代码是
#include "syslib.h"
PUBLIC int sys_fork(parent, child, child_endpoint, map_ptr, flags, msgaddr)
endpoint_t parent; /* process doing the fork */
endpoint_t child; /* which proc has been created by the fork */
endpoint_t *child_endpoint;
struct mem_map *map_ptr;
u32_t flags;
vir_bytes *msgaddr;
{
/* A process has forked. Tell the kernel. */
message m;
int r;
m.PR_ENDPT = parent;
m.PR_SLOT = child;
m.PR_MEM_PTR = (char *) map_ptr;
m.PR_FORK_FLAGS = flags;
r = _kernel_call(SYS_FORK, &m);
*child_endpoint = m.PR_ENDPT;
*msgaddr = (vir_bytes) m.PR_FORK_MSGADDR;
printf("process forked\n"); //the modification I made
return r;
}
答案 0 :(得分:1)
来自CEID的anna_jennifer!
你必须将printf放在/kernel/system/do_fork.c中并在返回OK之前;