Zbr's days.
February
Sun Mon Tue Wed Thu Fri Sat
       
4
     
2007
Months
Feb

About :: TODO :: Blog :: RSS :: Old blog :: Projects :: GIT :: Gallery :: Notes

Sun, 04 Feb 2007

Major step in M:N threading implementation - moved to partial userspace context usage.


As a first step I just started to use struct ucontext instead of sigframe - this allows to use getcontext()/makecontext() for initalization, which is a bit faster than signal waiting, but potentially can be much faster (I just need to remove a signal mask initialization through syscall in getcontext()). It also allows some code refactoring, which hides per-arch signal frame definition into implementation files from headers.
I created simple convertor from signal stack frame (mainly sigcontext() structure) into ucontext (mcontext_t) structure, which is used as storage. Although they have exactly the same binary layout, x86 segment registers should not be copied. Current code does not properly saves/restores FPU state too, but this requires more learning.
Next step is to implement getcontext() by hands so that code would not initialize signal mask at all. Then I will think about proper SMP scaling, which will use stack tricks instead of 'current' pointers.

There is a problem though - new thread is started only after parent's timeslice is over, i.e. it is possible to create set of threads with empty functions and they will exists quite for a while - for example 500 threads started in a loop still are created too quickly to be called and stopped to release memory, but for example 100 NTL threads creations are about 1.6 times faster in that synthetic benchmark than NPTL ones. I will think about resolution.
API is also very limited in this version yet.

/devel/threading :: Link / Comments (0)

Please solve this captcha to be allowed to post (need to reload in a minute): 78 + 63

Comments are closed for this story.