开发者

Pthread segment registers

开发者 https://www.devze.com 2023-03-20 08:14 出处:网络
I will admit I did minimal research for this question (just a few shallow google 开发者_开发技巧searches). Do threading packages (pthreads specifically, but my question applies to all x86 unix user th

I will admit I did minimal research for this question (just a few shallow google 开发者_开发技巧searches). Do threading packages (pthreads specifically, but my question applies to all x86 unix user thread libraries) save segment registers (fs, cs, ds, etc) per thread? In other words, does each thread have its own copy of segment registers?


On most modern OSes, the segment registers have specific meanings determined by the OS. The OS thread libraries will ensure that the registers are set correctly for each thread at all times. e.g. on Windows, the FS register points to a segment with thread-specific data, which is thus updated with every thread switch, whereas the DS register refers to a process-wide segment, so is the same for all threads within a process.

If a platform allows the user to set segment register values, then I would expect them to be properly preserved across thread switches, just like any other register.

In general, I would expect the segment registers to be preserved, because that is easier than looking up what they "should" be, and leads to the least possibility of surprise.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号