Quote:
Originally Posted by
kumaran_5555
I was going through the Linux code, i stuck with few inline assembly language code,
I have tried online but in vain. Any help is much appreciated. Thanks.
esp would be the x86 stack pointer. And %0 is a variable parameter which in this case means ~(THREAD_SIZE-1) The stack is the context which thread-local variables, among other things, reside inside. Each thread gets their own little independent chunk.
I believe they're doing something similar to aligning a pointer along page boundaries. If the stack pointer was, say 0xfeff7352 and THREAD_SIZE was 0x00010000, they'd be doing 0xfeff7352 & 0xffff0000, you'd get 0xfeff0000 out of it. I suppose doing this would get you the very top of the thread's stack instance, where (I think) things like the thread ID are kept handy.
THREAD_SIZE may not be the system page size but is probably at least a power-of-two multiple of it.