【发布时间】:2019-01-02 19:32:40
【问题描述】:
在kernel/ipc.hTanenbaum 中将系统调用位定义为:
/* System call numbers that are passed when trapping to the kernel. The
* numbers are carefully defined so that it can easily be seen (based on
* the bits that are on) which checks should be done in sys_call().
*/
#define SEND 1 /* 0 0 0 1 : blocking send */
#define RECEIVE 2 /* 0 0 1 0 : blocking receive */
#define SENDREC 3 /* 0 0 1 1 : SEND + RECEIVE */
#define NOTIFY 4 /* 0 1 0 0 : nonblocking notify */
#define ECHO 8 /* 1 0 0 0 : echo a message */
但是在kernel/table.c 中,系统调用位被定义为:
/* Define system call traps for the various process types. These call masks
* determine what system call traps a process is allowed to make.
*/
#define TSK_T (1 << RECEIVE) /* clock and system */
#define SRV_T (~0) /* system services */
#define USR_T ((1 << SENDREC) | (1 << ECHO)) /* user processes */
为什么所有内容都向左移动? 1 << RECEIVE 将是 0100 而不是 0010。这不是说时钟和系统任务可以通知但不能接收吗?
【问题讨论】:
-
ip.h 名称是位位置,表值是位掩码