multithreading - Detect the bounds of the stack of the current thread -


I am writing a semi-precise garbage collector, and I wonder if any of the borders to find out correctly Method is the system-assigned stack for a given thread.

I need this so that I can scan the stack for the root (sign), and my current view is to save the stack pointer when a new thread is entered and

( I know that this approach is not ideal in the long run, because it becomes unnecessary, because it is locked for each thread when starting garbage collection using the main lock. ) But I would like to have a more "safe" way of detecting the boundaries, because this root is quite easy to 'escape' - this mechanism (thread based on implementation - managed pthreads It is easy to do, but this is not the case with OpenMP or Grand Central Dispatch).

If this was a portable way to do this, but I do not expect this to be the case. I am currently working on Mac OS X 10.6, but the answer to any platform is welcome.

You use the VM system to protect the end of the stack, and expand on the VM writing network . Then you know the boundary of the stack inside a stack page.

But I am not sure that for the current roads, I have an objection to inspecting the present value of SP, * If you have a "big stack" concept * Small and small threads are adopted by the parallel community.

For a discussion about a world model, look for where you have "big pile" then you can not create a GC which only scans the "stack" because it is a heap allocated on demand ( E.g., Function entry). Now you need to scan all the stack segments that can be live.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -