Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Segments are not used for per-CPU storage #21

Open
pdav opened this issue Jul 15, 2019 · 0 comments
Open

Segments are not used for per-CPU storage #21

pdav opened this issue Jul 15, 2019 · 0 comments

Comments

@pdav
Copy link

pdav commented Jul 15, 2019

In mem.t (lines 860-870), it is written:

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant