but xv6 uses segments only for the common trick of
implementing per-cpu variables such as
.code proc
that are at a fixed address but have different values
on different CPUs (see
.code-index seginit ).
Implementations of per-CPU (or per-thread) storage on non-segment
architectures would dedicate a register to holding a pointer
to the per-CPU data area, but the x86 has so few general
registers that the extra effort required to use segmentation
is worthwhile.
As far as I understand, all segments in GDT/LDT start from 0 to ffffffff. Thus, they are not used for the described trick. Furthermore, proc is referenced through struct cpu in the cpus[] array (and index in this array is obtained by searching the local APICID).
Therefore, I suggest removing this whole paragraph.
In mem.t (lines 860-870), it is written:
As far as I understand, all segments in GDT/LDT start from 0 to ffffffff. Thus, they are not used for the described trick. Furthermore, proc is referenced through
struct cpu
in thecpus[]
array (and index in this array is obtained by searching the local APICID).Therefore, I suggest removing this whole paragraph.