diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-27 16:48:14 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-27 16:48:14 +0000 |
commit | 6244e502cc12a7b8c5698740d3b5b355c1695e37 (patch) | |
tree | 63f6fc1cd8a5df52669315113ecedbe3e62d0c09 /thread_pthread.ci | |
parent | 51fb5511e0f4ac9eb96819648beaac173f054c0b (diff) | |
download | ruby-6244e502cc12a7b8c5698740d3b5b355c1695e37.tar.gz |
* thread.c: fix Mutex to be interruptable lock.
* thread_win32.ci, thread_win32.h, thread_pthread.ci, thread_pthread.h:
prepare native_cond_*() which are based on pthread_cond_*() spec.
* prelude.rb: fix Mutex#synchronize method.
* vm_core.h, include/ruby/intern.h: change unblock function interface
(to pass some user data).
* file.c, process.c: ditto.
* benchmark/bm_vm2_mutex.rb: add a benchmark for mutex.
* benchmark/bm_vm3_thread_mutex.rb: add a benchmark for mutex
with contension.
* benchmark/run.rb: fix to remove ENV['RUBYLIB'] for matzruby.
* test/ruby/test_thread.rb: add a test.
* common.mk: fix benchmark options.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.ci')
-rw-r--r-- | thread_pthread.ci | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/thread_pthread.ci b/thread_pthread.ci index b8b609145e..2f22d1eae1 100644 --- a/thread_pthread.ci +++ b/thread_pthread.ci @@ -39,7 +39,7 @@ native_mutex_trylock(pthread_mutex_t *lock) return EBUSY; } else { - rb_bug("native_mutex_unlock return non-zero: %d", r); + rb_bug("native_mutex_trylock return non-zero: %d", r); } } return 0; @@ -63,6 +63,43 @@ native_mutex_destroy(pthread_mutex_t *lock) } } +void +native_cond_initialize(pthread_cond_t *cond) +{ + int r = pthread_cond_init(cond, 0); + if (r != 0) { + rb_bug("native_cond_initialize return non-zero: %d", r); + } +} + +void +native_cond_destroy(pthread_cond_t *cond) +{ + int r = pthread_cond_destroy(cond); + if (r != 0) { + rb_bug("native_cond_destroy return non-zero: %d", r); + } +} + +void +native_cond_signal(pthread_cond_t *cond) +{ + pthread_cond_signal(cond); +} + +void +native_cond_broadcast(pthread_cond_t *cond) +{ + pthread_cond_broadcast(cond); +} + +void +native_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +{ + pthread_cond_wait(cond, mutex); +} + + #define native_cleanup_push pthread_cleanup_push #define native_cleanup_pop pthread_cleanup_pop #define native_thread_yield() sched_yield() @@ -309,7 +346,7 @@ native_thread_apply_priority(rb_thread_t *th) } static void -ubf_pthread_cond_signal(rb_thread_t *th) +ubf_pthread_cond_signal(rb_thread_t *th, void *ptr) { thread_debug("ubf_pthread_cond_signal (%p)\n", th); pthread_cond_signal(&th->native_thread_data.sleep_cond); @@ -326,7 +363,7 @@ ubf_select_each(rb_thread_t *th) } static void -ubf_select(rb_thread_t *th) +ubf_select(rb_thread_t *th, void *ptr) { add_signal_thread_list(th); ubf_select_each(th); |