thread switch results in kernel stack switch
On x86 protected mode,task-switch results in renewal of TR(task register).
Renewal of TR contains to renew kernel stack(ss0:esp0) .
Now,suppose one process has two threads(A,B) and they have separate
register set , PC , user stack and kernel stack(ss0:esp0).
When thread-A switches to thread-B,the TR doesn't renew because they
are int the same process.
Howerer , thread-B uses call-gate or interrupt to make user's stack switch
to kernel stack(ss0:esp0),But the kernel stack belongs to
thread-A , because task-switch doesn't happen and TR keeps a state
(includeing kernel stack) of thread-A.
Thread-B uses call-gate or interrupt and it's kernel stack refers to TR
,But the kernel stack in TR belong to thread-A.
How the thread-B use own kernel stack without task-switch ?
ps: task-switch causes renewal of TR, the behavior is calles task-swich,
not "thread-switch" .
My problem is how to use own kernel stack in thread-B.
Thanks very mush!!
Oh dear ... it's been more than a year since my OS class in grad school and we were doing that all on SPARC, which is completely different from x86. But I know that Linux uses the 1-1 model to implemented threading in the kernel. So each thread is actually a different process, as far as the kernel is concerned (i.e. the PIDs are the same, but the TIDs are different), therefore I think that each thread has its own TSS and its own kernel stack, which makes sense as each thread needs its own instruction pointer, among other things. This page seems to have some good info, but I don't have the time to read it all right now :-(.
BTW you might want to ask a mod to move this to the programming forum, as it might get better coverage there. Not sure.
|All times are GMT -5. The time now is 05:23 AM.|