File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def self.exclusive
1212 end
1313
1414 attr_reader :recursive_objects
15+ attr_reader :pid
1516
1617 # Implementation note: ideally, the recursive_objects
1718 # lookup table would be different per method call.
Original file line number Diff line number Diff line change 2020#include " metrics.hpp"
2121#include " util/logger.hpp"
2222
23+ #include < sys/syscall.h>
24+
2325/* HACK: returns a value that should identify a native thread
2426 * for debugging threading issues. The winpthreads library
2527 * defines pthread_t to be a structure not a pointer.
@@ -73,6 +75,7 @@ namespace rubinius {
7375 thr->joins (state, Array::create (state, 1 ));
7476 thr->killed (state, cFalse);
7577 thr->priority (state, Fixnum::from (0 ));
78+ thr->pid (state, Fixnum::from (0 ));
7679 thr->klass (state, klass);
7780
7881 vm->thread .set (thr);
@@ -289,6 +292,12 @@ namespace rubinius {
289292
290293 NativeMethod::init_thread (state);
291294
295+ #ifdef __APPLE__
296+ vm->thread ->pid (state, Fixnum::from (syscall (SYS_thread_selfid)));
297+ #else
298+ vm->thread ->pid (state, Fixnum::from (syscall (SYS_gettid)));
299+ #endif
300+
292301 // Lock the thread object and unlock it at __run__ in the ruby land.
293302 vm->thread ->alive (state, cTrue);
294303 vm->thread ->init_lock_ .unlock ();
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ namespace rubinius {
4747 Array* joins_; // slot
4848 Object* killed_; // slot
4949 Fixnum* priority_; // slot
50+ Fixnum* pid_; // slot
5051
5152 utilities::thread::SpinLock init_lock_;
5253 utilities::thread::Mutex join_lock_;
@@ -88,6 +89,7 @@ namespace rubinius {
8889 attr_accessor (joins, Array);
8990 attr_accessor (killed, Object);
9091 attr_accessor (priority, Fixnum);
92+ attr_accessor (pid, Fixnum);
9193
9294 VM * vm () const {
9395 return vm_;
You can’t perform that action at this time.
0 commit comments