lkml.org 
[lkml]   [1999]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Q: Thread local storage, thread IDs
Hello Brian,

Brian Gerst wrote:

> > Linux uses FLAT address space. And FLAT means exactly this: flat. No selectors.
> > In userspace that is. No way to create new selector and no need to change
> > [csdefg]s at all. You'll need really, really, REALLY strong argument to change
> > this. And even then such patch will be rejected :-)) No way, sorry. Linux 2.2
> > uses 1 selector per process (for TSS) and 2.3 does not use even one selector
> > per process and it's worth it.
>
> Not true. On the x86, you cannot disable segmentation. Flat address
> space simply means that all the segments have a base of 0 and limit of
> 4GB thereby negating the effects of segmentation. You can modify the
> LDT to create additional selectors with the modify_ldt syscall. Wine
> needs this to simulate the Windows address map mechanisms. You are
> thinking of the GDT which is per process (or per cpu in recent
> kernels). LDTs are always per process.

Ah, this is exactly what I hoped to find - a way to modify the LDT. I
know it doesn't make my programs very portable, but since the compiler I
use/port is i386-only, portability to other Linux/Unix platforms is not
an issue (yet). My problem is actually somewhat related to the Wine
problem, because the compiler's code generation relies on several
features specific to the OS2/Windows platforms, one of them being that
thread information block pointed to by the FS selector.

Now, I tried to use the modify_ldt system call. I was able to create a
new selector (result = 0), but couldn't use it. I guess that's because
the base address I specified was expected to be in linear (physical)
address space, not in the flat address space of my process. At least I
got a segmentation fault. I also tried to read the process LDT and
modify one of the existing selectors, but the size of the LDT I got from
Linux was always 0. What did I do wrong?

Maybe someone with more knowledge in protected mode assembler Linux
programming could even give me the few lines of assembler code needed to
solve my complete problem: I have a memory block named TIB where my
thread information is stored. This block may be 4- or 16-byte-aligned or
whatever is necessary. I need an FS selector pointing to the block, so
that FS:[0] is the first longword of my thread information.

--
Bye, E-Mail ......... mailto:joerg.pleumann@trantor.de
Jörg Homepage ... http://www.trantor.de/joerg.pleumann



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:1.402 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site