【问题标题】:Why there is no GDT in xv6-riscv?为什么 xv6-riscv 中没有 GDT?
【发布时间】:2022-08-19 03:02:29
【问题描述】:

在 xv6-x86 中,每个 cpu 结构都有一个 gdt:

struct cpu {
  uchar apicid;                // LAPIC ID
  struct context *scheduler;
  struct taskstate ts;
  struct segdesc gdt[NSEGS];   // GDT
  volatile uint started;
  int ncli;
  int intena;
  struct proc *proc;
};

但它在 xv6-riscv 中被删除:

// Per-CPU state.
struct cpu {
  struct proc *proc;          // The process running on this cpu, or null.
  struct context context;     // swtch() here to enter scheduler().
  int noff;                   // Depth of push_off() nesting.
  int intena;                 // Were interrupts enabled before push_off()?
};

所以操作系统中不需要gdt? 很困惑,感谢任何答复。

    标签: operating-system riscv xv6


    【解决方案1】:

    全局描述符表 (GDT) 是特定于 x86 指令集架构的硬件数据结构,并且与该 ISA 的分段内存模型相关。即使在平面内存模型中,x86 保护模式也需要它,甚至需要在 x86-64 长模式下设置(根本不应用分段)。

    RISC-V 等其他 ISA 不使用分段,因此没有与 GDT 等效的功能。

    【讨论】:

      猜你喜欢
      • 2021-08-26
      • 2013-03-22
      • 2015-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多