This talk seems to have gone into hashing algorithms, but anyway, this still seems to fit in here.
I spent a few more thoughts on thread migration, especially the issue whether a migrating thread should take the whole thread's stack with it, or it should get a new stack in the destination address space. I know you think I'm a bit keen on this, but I'm about to decide whether or not to support this mechanism, and how to implement it finally.
So, one method would be to map the whole thread's stack (that should have a fixed size then) into the destination address space, as soon as the thread migrates there, and still keeping the mapping in the address space the thread came from.
The pro-argument for this method is that any arguments the thread wants to transport can be put onto the stack, and are then naturally accessible from within any address space, in which the thread operates (since the whole stack is accessible from within there).
The second method would be to allocate a new stack (or take a pre-allocated stack) in the destination address space.
Advantages here are:
- The newly allocated stack can be of different size (depending on the call-depths and stack-usage which are common in the local code)
- It can save address space, since the newly allocated stack can be significantly smaller
The main disadvantage here is, that all arguments and data, which need to be transfered, have to be put into a seperate location before the thread migrates, in some cases this would mean to copy data from the stack to some other memory location.
The main reason why I would prefer the latter method is that even when you map the whole stack into the destination address space, you cannot rely that you can preserve the same base address, thus invalidating all the pointers that lie on the stack. This makes it impossible to make a thread migration implicit - before you migrate, you'd have to adapt pointers (and also have to make heap objects available in the destination address space - you can't just take the whole heap with you during migration).
So instead you could start off with a new stack, and when you need to take an object with you, you declare this in some 'argument-list' that the kernel will interpret and copy the corresponding objects into the destination address space - and backwards, of course, when the thread migrates back into the caller address space. When one of these objects resides on the stack, you'd put it onto the list anyway.
So, finally, if you also planned to implement migrating threads, or you already implemented it, I would be thankful for some comments about how you solved the stack-issue. Aside this, I'd would be interested in what you think about the concept at all - do you think it could be useful or not - and why?
THX for reading through this post, I'm afraid it has got a bit longer than I expected. ::)
cheers, Joe