How to keep gcc haifa from moving userlevel thread lock function?
Hi,
The green_threads implementation of the JDK sets a schedule lock that prevents any green thread (not a linuxthread) from yielding (think of green_threads as userland cooperative threads that run in a single process).
Here is the routine:
/*
* Lock the thread scheduler
*/
void_sched_lock()
{
++_scheduling_lock;
}where _scheduling_lock is a global integer.
The problem is that the calls to _sched_lock seems to be moved by the haifa scheduler just enough to force me to compile many things with -O0 to prevent problems.
I *think* gcc is inlining the call and then the haifa scheduler seems to want to move this around abit since it does not directly impact the code around it.
What is the correct way to keep the gcc (haifa) from moving this around?
I have already tried:
"-O2 -fno-schedule-insns -fno-schedule-insns2"
but that does not seem to do the trick.
I am sure there must be some indicator (like volatile) that I should be using.
Any help would be greatly appreciated.
Thanks,
Kevin
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Is _scheduling_lock delared volatile? You should not disable
scheduling or other optimizations to solve this problem. You should look for the appropriate attribute for the variable and/or function to prevent GCC from moving the code.
David
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/