getcontext() for a different thread
John Polstra
jdp at polstra.com
Mon Jun 16 18:55:47 PDT 2003
I've been toying with the idea of making Modula-3 use FreeBSD's native
threads library. One thing that would be required is something like
getcontext() that could be called to get the context of a different
thread. That is needed by the garbage collector, because it has to
examine all of the threads' registers in case some of them contain
pointers to objects that need to be traced.
Are there any major obstacles to implementing this?
I see that getcontext() in the kernel already takes a "struct thread *"
argument. But it calls get_mcontext(), which (at least on the
i386) references "curthread" a couple of times. Is that really
necessary, or could "td" be used in place of "curthread"?
An other-thread getcontext would have to be passed a kernel thread
handle of some sort. Is there currently anything like that which is
exposed to userland?
An other-thread getcontext would have to do some security checks to
make sure you weren't trying to read the register of a thread that
didn't belong to you.
Anything else?
John
--
John Polstra
John D. Polstra & Co., Inc. Seattle, Washington USA
"Two buttocks cannot avoid friction." -- Malawi saying
More information about the freebsd-threads
mailing list