code:user - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
0400 /*
0401 * The user structure.
0402 * One allocated per process.
0403 * Contains all per process data
0404 * that doesn’t need to be referenced
0405 * while the process is swapped.
0406 * The user block is USIZE*64 bytes
0407 * long; resides at virtual kernel
0408 * loc 140000; contains the system
0409 * stack per user; is cross referenced
0410 * with the proc structure for the
0411 * same process.
0412 */
0413 struct user
0414 {
0415 int u_rsav[2]; /* save r5,r6 when exchanging stacks */
0416 int u_fsav[25]; /* save fp registers */
0417 /* rsav and fsav must be first in structure */
- procxmt中 使用 u_fsav
0418 char u_segflg; /* flag for IO; user or kernel space */
0419 char u_error; /* return error code */
0420 char u_uid; /* effective user id */
0421 char u_gid; /* effective group id */
0422 char u_ruid; /* real user id */
0423 char u_rgid; /* real group id */
0424 int u_procp; /* pointer to proc structure */
- 分别为
- 有效用户ID
- 有效组ID
- 真实用户ID
- 真实组ID
- 参看权限管理
0425 char *u_base; /* base address for IO */
0426 char *u_count; /* bytes remaining for IO */
- 当前 I/O 的基地址
0427 char *u_offset[2]; /* offset in file for IO */
- 当前 I/O 的 剩余字节数
0428 int *u_cdir; /* pointer to inode for current directory */
- 当前 I/O 的 文件偏移量
0429 char u_dbuf[DIRSIZ]; /* current pathname component */
- 指向 当前目录 的inode块
0430 char *u_dirp; /* current pointer to inode */
0431 struct { /* current directory entry */
- 在 namei 调用时, 指向 文件路径字符串
0432 int u_ino;
0433 char u_name[DIRSIZ];
0434 } u_dent;
0435 int *u_pdir; /* inode of parent directory of dirp */
- 当前目录项 的 信息
- u_ino : 目录项对应的 INODE 号
- u_name : 目录项的文件名
0436 int u_uisa[16]; /* prototype segmentation addresses */
- 指向 目录的父目录的INODE
0437 int u_uisd[16]; /* prototype segmentation descriptors */
0438 int u_ofile[NOFILE]; /* pointers to file structures of
- 与 UISA UISD 对应的相对地址映照表
- 参看 内存管理
0439 open files */
0440 int u_arg[5]; /* arguments to current system call */
- 进程打开文件表
- 参看内存打开文件结构
0441 int u_tsize; /* text size (*64) */
- 参与 系统调用的参数传递
- 参看系统调用
0442 int u_dsize; /* data size (*64) */
0443 int u_ssize; /* stack size (*64) */
0444 int u_sep; /* flag for I and D separation */
- 分别是进程的
- 共享正文段 大小
- 数据段 大小
- 用户栈 大小
- 都以 内存块 为单位(64字节/块)
- 参看 进程图像
0445 int u_qsav[2]; /* label variable for quits & interrupts */
- 指令空间 和 数据空间 的 分离标志
- 对于 pdp11/40 始终为0
0446 int u_ssav[2]; /* label variable for swapping */
0447 int u_signal[NSIG]; /* disposition of signals */
0448 int u_utime; /* this process user time */
- 信号处理函数 入口表
0449 int u_stime; /* this process system time */
- 进程 用户态 运行时间
0450 int u_cutime[2]; /* sum of childs’ utimes */
- 进程 核心态 运行时间
0451 int u_cstime[2]; /* sum of childs’ stimes */
分别是0452 int *u_ar0; /* address of users saved R0 */
关于u_ar0的使用,参考关于u_ar0的使用0453 int u_prof[4]; /* profile arguments */
0454 char u_intflg; /* catch intr from sys */
- 程序统计直方图 的参数
0455 /* kernel stack per user
- 系统调用 出错标志
0456 * extends from u + USIZE*64
0457 * backward not to reach here
0458 */
0459 } u;
0460 /* ------------------------- */
- code:main
- code:estabur
- code:newproc
- code:sleep
- code:swtch
- code:expand
- code:trap
- code:trap1
- code:nosys
- code:exec
- code:rexit
- code:exit
- code:wait
- code:fork
- code:sbreak
- code:getswit
- code:gtime
- code:stime
- code:setuid
- code:getuid
- code:setgid
- code:getgid
- code:getpid
- code:nice
- code:unlink
- code:chdir
- code:chmod
- code:chown
- code:smdate
- code:ssig
- code:kill
- code:times
- code:profil
- code:clock
- code:issig
- code:stop
- code:psig
- code:core
- code:grow
- code:ptrace
- code:procxmt
- code:xfree
- code:xalloc
- code:physio
- code:geterror
- code:rdwr
- code:open
- code:creat
- code:open1
- code:close
- code:seek
- code:link
- code:mknod
- code:sslep
- code:fstat
- code:stat
- code:dup
- code:smount
- code:sumount
- code:getmdev
- code:readi
- code:writei
- code:iomove
- code:bmap
- code:passc
- code:cpass
- code:nodev
- code:getf
- code:openi
- code:access
- code:suser
- code:ufalloc
- code:falloc
- code:iinit
- code:alloc
- code:ialloc
- code:iget
- code:maknode
- code:wdir
- code:namei
- code:schar
- code:uchar
- code:pipe
- code:writep
- code:klopen
- code:gtty
- code:stty
- code:sgtty
- code:ttystty
- code:mmread
- code:mmwrite