该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
Minix是《操作系统:设计与实现》示例代码。\ Linus的Linux内核本身就参考了Minix。 Minix2.0.4http://download.minix3.org/previous-versions/Intel-2.0.4/小白入门的版本,需要自己做软盘。 Minix 3.2.,Minix2.0.4 ps ax 界面:可以看到文件系统,进程内存管理这些已经是系统独立进程的形式存在了,在ps中可以看到FS,MM。但Minix2版本无法手动操作这些进程,可以看到它们的pid都是0。 Minix3ps 返回结果:FS变成了VFS,但实质上一样。试着杀掉VFS进程,系统马上就不重启了。 FS进程请求SYS进程将从磁盘读取的内容复制到用户进程P的缓冲区,这一步是没有用户进程参与的,所以FS进程至少要知道用户进程P的内存信息元数据,这样才可以让内核态的SYS进程完成复制操作。 MM服务进程,该进程为用户进程的fork,exec,exit,wait等调用管理内存,系统所有进程的快照保存在mproc数组中,详见mm/mproc.h文件:/* This table has one slot per process. It contains all the memory management* information for each process. Among other things, it defines the text, data* and stack segments, uids and gids, and various flags. The kernel and file* systems have tables that are also indexed by process, with the contents* of corresponding slots referring to the same process in all three.*/EXTERN struct mproc {struct mem_map mp_seg[NR_SEGS];/* points to text, data, stack */char mp_exitstatus;/* storage for status when process exits */char mp_sigstatus;/* storage for signal # for killed procs */pid_t mp_pid;/* process id */pid_t mp_procgrp;/* pid of process group (used for signals) */pid_t mp_wpid;/* pid this process is waiting for */int mp_parent;/* index of parent process */...// } mproc[NR_PROCS];// fs/fproc.h:/* This is the per-process information. A slot is reserved for each potential* process. Thus NR_PROCS must be the same as in the kernel. It is not possible* or even necessary to tell when a slot is free here.*/EXTERN struct fproc {mode_t fp_umask;/* mask set by umask system call */struct inode *fp_workdir;/* pointer to working directory's inode */struct inode *fp_rootdir;/* pointer to current root dir (see chroot) */struct filp *fp_filp[OPEN_MAX];/* the file descriptor table */...// } fproc[NR_PROCS];// 同样是read读取文件,微内核只是把宏内核的纵向通信换成了横向通信而已。然而这个一纵一横的背后,却隐藏着大不同。纵向通信是实际发生的服务调用,即物理通信。横向通信是对等层通信,即逻辑通信。 对于Minix微内核的read场景,和TCP/IP的模型几乎一致,在横向对等IPC之下,宏内核一个系统调用的事,微内核的IPC竟然要12个系统调用,而且仅仅是send/receive重复6对!如此设计性能显然好不了对于微内核只需要send,receive两个系统调用就够了,所有的系统功能都可以通过send/receive两个系统调用封装IPC消息来完成:int read