When ppc machine code is used, this program won't terminate:
int do_work = 1, rounds;
void work() { while (do_work) { rounds++; } }
int main() { for (int i = 0; i < 5; i++) Thread.thread_create (work); sleep (10); do_work = 0; sleep (1); werror ("rounds: %d\n", rounds); }
The reason is that it uses OPCODE_INLINE_BRANCH and doesn't generate the appropriate calls to check_threads_etc() on backward jumps after branch opcodes. (Normally the opcodes do that themselves since they have the address to jump to.)
As far as I can see, the x86 backend doesn't generate any such calls either.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-11-25 21:08: Subject: Checking threads on ppc
When ppc machine code is used, this program won't terminate:
int do_work = 1, rounds;
void work() { while (do_work) { rounds++; } }
int main() { for (int i = 0; i < 5; i++) Thread.thread_create (work); sleep (10); do_work = 0; sleep (1); werror ("rounds: %d\n", rounds); }
The reason is that it uses OPCODE_INLINE_BRANCH and doesn't generate the appropriate calls to check_threads_etc() on backward jumps after branch opcodes. (Normally the opcodes do that themselves since they have the address to jump to.)
/ Martin Stjernholm, Roxen IS
pike-devel@lists.lysator.liu.se