operating-system - 为什么xv6-riscv中没有GDT?

标签 operating-system riscv xv6

在 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在操作系统中不是必需的? 很困惑,感谢您的回复。

最佳答案

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

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

关于operating-system - 为什么xv6-riscv中没有GDT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73397444/

相关文章:

makefile - Makefile 中的@echo 总是导致错误 "*** missing separator. Stop."

python - 使用 Python 将文件从一个目录移动到另一个目录时无法解决错误

python - 在Python中重命名所有文件的名称

assembly - riscv objdump 如何设置打印 x0-x31 寄存器名称而不是 abi 名称

multithreading - 是否可以在 riscv 中的两个锁上构建原子 "release-and-acquire"操作?

c - 如何接收 (void *)0x12345678 参数?

java线程和操作系统线程

c - 为什么在内核模式下执行回调函数不好?

c - RISCV 32 位基础和 64 位扩展

operating-system - 在xv6中,switchuvm/switchkvm中的uvm和kvm代表什么?