[Prev][Next][Index][Thread]
Re: sproc state information
At Thu, 3 Oct 2002 09:33:39 +0800 (WST),
Voon-Li Chung wrote:
>
> > With sproc implementation, thread state of a user-level process is
> > stored two times. Firstly, when a thread issues fork(), it executes
> > INT instruction and it is captured by a trap gate. The trap gate code
> > is in sproc_syscall_trap_inittab.S. The very first thing the trap
> > code does is to push all registers which is not saved by the processor
> > into the stack. Secondly, when the thread, which is now executing in
> > kernel mode, is rescheduled by the thread scheduler, the context
> > information is saved in somewhere (I guess it is saved in a thread
> > control block but I haven't checked the code).
>
> I've checked this; however the state information stored in the threads PCB
> (as it is called in the source code) only contains kernel-level space.
> Also, the TSSs referred to in the sproc_thread structure by the struct
> oskit_sproc (as far as I can tell) are not used in the way that Intel
> intended it. I suspect the TSSs are only used so that stack faults can be
> "recovered" from by using a trap task (which changes to its own stack).
I think most virtual memory systems on x86 for UNIX-like operating
system do not use TSS as Intel had intended, and UVM is not an
exception. Usually sproc uses base_tss, the OSKit default TSS, when
running a user-level program. I think one of the reason not using TSS
is that using multiple TSSs makes difficult to refer memory on
different TSSs.
> At the moment, in order to determine what the user-level area's state is
> (and change it when cloning a process), I wrote a function which is called
> immediately after the pusha instructure in base_irq_inittab.S. The
> function then stores the state information (and its location) in a global,
> which pthread_scheduler() can then associate with the appropriate thread
> for later use.
Similar thing sproc and UVM does... OSKit thread scheduler and UVM
have undocumented `context switch hook' which is called on every
context switch. Sproc uses this hook to keep track of which thread is
running. See thread_csw_hook() in oskit_uvm_thread.c and
oskit_sproc_csw() in sproc_csw.c. It is not efficient to switch
address spaces on every thread context switch so it should be improved
in the future.
You may want to enhance oskit_sproc_csw() to be able to call another
hook..
--
Kota Abe
Media Center, Osaka City Univ.
References: