summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-11 14:27:08 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-11 14:27:08 +0000
commit9d4e471cf974d99ab01fc243b5419c6711888540 (patch)
tree531f8251fc433d165eb8a946cb9d6b6fad2aa7c0 /thread.c
parent8df20d6b169ed6b8e76927b5ce5db9acb0208a8b (diff)
* vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT,
RUBY_VM_SET_FINALIZER_INTERRUPT): use atomic ops for preventing interrupt_flag bit lost. * thread.c (rb_threadptr_execute_interrupts_rec): ditto. * vm_core.h (typedef struct rb_thread_struct): change type of interrupt_flag to rb_atomic_t. * atomic.h: move atomic ops definition from signal.c. * signal.c: remove atomic ops definition. * common.mk (gc, signal, thread, cont): add to dependency to atomic.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/thread.c b/thread.c
index 3365a55020..c52275fe4a 100644
--- a/thread.c
+++ b/thread.c
@@ -1290,19 +1290,20 @@ thread_s_pass(VALUE klass)
static void
rb_threadptr_execute_interrupts_rec(rb_thread_t *th, int sched_depth)
{
+ rb_atomic_t interrupt;
+
if (GET_VM()->main_thread == th) {
while (rb_signal_buff_size() && !th->exec_signal) native_thread_yield();
}
if (th->raised_flag) return;
- while (th->interrupt_flag) {
+ while ((interrupt = ATOMIC_EXCHANGE(th->interrupt_flag, 0)) != 0) {
enum rb_thread_status status = th->status;
- int timer_interrupt = th->interrupt_flag & 0x01;
- int finalizer_interrupt = th->interrupt_flag & 0x04;
+ int timer_interrupt = interrupt & 0x01;
+ int finalizer_interrupt = interrupt & 0x04;
th->status = THREAD_RUNNABLE;
- th->interrupt_flag = 0;
/* signal handling */
if (th->exec_signal) {