File tree 3 files changed +12
-0
lines changed
3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def self.exclusive
12
12
end
13
13
14
14
attr_reader :recursive_objects
15
+ attr_reader :pid
15
16
16
17
# Implementation note: ideally, the recursive_objects
17
18
# lookup table would be different per method call.
Original file line number Diff line number Diff line change 20
20
#include " metrics.hpp"
21
21
#include " util/logger.hpp"
22
22
23
+ #include < sys/syscall.h>
24
+
23
25
/* HACK: returns a value that should identify a native thread
24
26
* for debugging threading issues. The winpthreads library
25
27
* defines pthread_t to be a structure not a pointer.
@@ -73,6 +75,7 @@ namespace rubinius {
73
75
thr->joins (state, Array::create (state, 1 ));
74
76
thr->killed (state, cFalse);
75
77
thr->priority (state, Fixnum::from (0 ));
78
+ thr->pid (state, Fixnum::from (0 ));
76
79
thr->klass (state, klass);
77
80
78
81
vm->thread .set (thr);
@@ -289,6 +292,12 @@ namespace rubinius {
289
292
290
293
NativeMethod::init_thread (state);
291
294
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
+
292
301
// Lock the thread object and unlock it at __run__ in the ruby land.
293
302
vm->thread ->alive (state, cTrue);
294
303
vm->thread ->init_lock_ .unlock ();
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ namespace rubinius {
47
47
Array* joins_; // slot
48
48
Object* killed_; // slot
49
49
Fixnum* priority_; // slot
50
+ Fixnum* pid_; // slot
50
51
51
52
utilities::thread::SpinLock init_lock_;
52
53
utilities::thread::Mutex join_lock_;
@@ -88,6 +89,7 @@ namespace rubinius {
88
89
attr_accessor (joins, Array);
89
90
attr_accessor (killed, Object);
90
91
attr_accessor (priority, Fixnum);
92
+ attr_accessor (pid, Fixnum);
91
93
92
94
VM* vm () const {
93
95
return vm_;
You can’t perform that action at this time.
0 commit comments