2025-04-07

xv6 操作系统,进程数据接口定义

// the registers xv6 will save and restore
// to stop and subsequently restart a process
struct context {
  int eip;
  int esp;
  int ebx;
  int ecx;
  int edx;
  int esi;
  int edi;
  int ebp;
};

// the different states a process can be in
enum proc_state { UNUSED, EMBRYO, SLEEPING,
                  RUNNABLE, RUNNING, ZOMBIE };

// the information xv6 tracks about each process
// including its register context and state
struct proc {
  char *mem;                   // Start of process memory
  uint sz;                     // Size of process memory
  char *kstack;                // Bottom of kernel stack
                               // for this process
  enum proc_state state;       // Process state
  int pid;                     // Process ID
  struct proc *parent;         // Parent process
  void *chan;                  // If non-zero, sleeping on chan
  int killed;                  // If non-zero, have been killed
  struct file *ofile[NOFILE];  // Open files
  struct inode *cwd;           // Current directory
  struct context context;      // Switch here to run process
  struct trapframe *tf;        // Trap frame for the
                               // current interrupt
};
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 进程和内存 进程有自己的内存空间(指令 数据 和栈),翻译这段话真别扭。操作系统可以在一组需要执行的进程之间进行切...
    王强儿阅读 700评论 2 3
  • 操作系统的一个关键要求是要一次支持多个活动。比如,使用系统调用fork,一个进程可以启动新进程。 操作系统必须在这...
    橡树人阅读 616评论 0 1
  • ——应对动态页面变更的思考与实践 在当前互联网环境下,网页结构不断变化、反爬机制层出不穷,传统数据采集技术面临巨大...
    数据蜘蛛阅读 32评论 0 0
  • 页表是操作系统给每个进程提供私有地址空间和内存的一种机制。页表决定内存地址的意义以及哪些物理内存能够访问。他们允许...
    sarto阅读 2,864评论 0 0
  • 环境 deepin 20 64 位系统 说在前面 本次Lab我也觉得比较难,到最后也有部分测试点没有通过,在实现p...
    扶桑与克里斯阅读 986评论 0 0