Skip to content

Commit

Permalink
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions kernel/common/thread.rb
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ def self.exclusive
end

attr_reader :recursive_objects
attr_reader :pid

# Implementation note: ideally, the recursive_objects
# lookup table would be different per method call.
9 changes: 9 additions & 0 deletions vm/builtin/thread.cpp
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@
#include "metrics.hpp"
#include "util/logger.hpp"

#include <sys/syscall.h>

/* HACK: returns a value that should identify a native thread
* for debugging threading issues. The winpthreads library
* defines pthread_t to be a structure not a pointer.
@@ -73,6 +75,7 @@ namespace rubinius {
thr->joins(state, Array::create(state, 1));
thr->killed(state, cFalse);
thr->priority(state, Fixnum::from(0));
thr->pid(state, Fixnum::from(0));
thr->klass(state, klass);

vm->thread.set(thr);
@@ -289,6 +292,12 @@ namespace rubinius {

NativeMethod::init_thread(state);

#ifdef __APPLE__
vm->thread->pid(state, Fixnum::from(syscall(SYS_thread_selfid)));
#else
vm->thread->pid(state, Fixnum::from(syscall(SYS_gettid)));
#endif

// Lock the thread object and unlock it at __run__ in the ruby land.
vm->thread->alive(state, cTrue);
vm->thread->init_lock_.unlock();
2 changes: 2 additions & 0 deletions vm/builtin/thread.hpp
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ namespace rubinius {
Array* joins_; // slot
Object* killed_; // slot
Fixnum* priority_; // slot
Fixnum* pid_; // slot

utilities::thread::SpinLock init_lock_;
utilities::thread::Mutex join_lock_;
@@ -88,6 +89,7 @@ namespace rubinius {
attr_accessor(joins, Array);
attr_accessor(killed, Object);
attr_accessor(priority, Fixnum);
attr_accessor(pid, Fixnum);

VM* vm() const {
return vm_;

0 comments on commit cda7249

Please sign in to comment.