Граф коммитов

240 Коммитов

Автор SHA1 Сообщение Дата
nobu 78c75612f0 thread_pthread.c: keep sp safe zone
* thread_pthread.c (reserve_stack): keep sp safe zone to get rid
  of crash by -fstack-check.  [ruby-core:68740] [Bug #11030]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14 22:34:53 +00:00
nobu 40564c1e3b thread_pthread.c: use rb_pid_t
* thread_pthread.c (timer_thread_pipe.owner_process): process ID
  should be pid_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-01 12:27:06 +00:00
nobu 8fe95fea9d thread_pthread.c: Fix intermittent SIGBUS on Linux
* thread_pthread.c (reserve_stack): fix intermittent SIGBUS on
  Linux, by reserving the stack virtual address space at process
  start up so that it will not clash with the heap space.
  [Fix GH-822]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-31 03:06:26 +00:00
normal 8341136f07 thread.c: micro-optimize thread create/join
* thread.c (struct join_arg): restructure and make smaller
  (thread_join_sleep): avoid timeofday() call if forever
  (thread_join): pass join_arg.delay directly
  (rb_thread_inspect_msg): remove, inline into rb_thread_inspect
  (rb_thread_inspect): reduce branching and string creation
* thread_pthread.c (native_set_thread_name): create string directly
  to avoid reparsing. [Misc #10723]

This reduces time in benchmark/bm_vm_thread_create_join.rb by
a few percent.

Minor improvements only:

target 0: 2.1.5 (ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux])
target 1: trunk (ruby 2.3.0dev (2015-01-16 trunk 49282) [x86_64-linux])
target 2: built (ruby 2.3.0dev (2015-01-16 trunk 49282) [x86_64-linux])

benchmark results:
minimum results in each 3 measurements.
Execution time (sec)
name                    2.1.5   trunk   built
vm_thread_create_join   1.049   1.242   1.138

Speedup ratio: compare with the result of `2.1.5' (greater is better)
name                    trunk   built
vm_thread_create_join   0.845   0.923

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-28 17:06:40 +00:00
akr 1ea4976041 * thread_pthread.c (native_set_thread_name): New function to
set thread name visible with ps command on GNU/Linux.
  Ex. ps -o %c -L

* thread.c (thread_start_func_2): Call native_set_thread_name at
  beginning.
  (rb_thread_inspect_msg): Extract from rb_thread_inspect.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 05:14:47 +00:00
hsbt 8362f9b581 * symbian/*: removed Symbian support.
[Feature #10199][ruby-core:64725]
* dln.c: ditto.
* include/ruby/defines.h: ditto.
* thread_pthread.c: ditto.
* vm.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04 11:09:32 +00:00
normal fdb2fc0b04 thread_pthread: prefer rb_nativethread* types/functions
This will make it easier for us to try alternative mutex/condvar
implementations while still using pthreads for thread management.
[Feature #10134]

* thread_pthread.h: define RB_NATIVETHREAD_LOCK_INIT and
  RB_NATIVETHREAD_COND_INIT macros

* thread_pthread.c (native_mutex_lock, native_mutex_unlock,
  native_mutex_trylock, native_mutex_initialize,
  native_mutex_destroy, native_cond_wait):
  use rb_nativethread_lock_t instead of pthread_mutex_t

* thread_pthread.c (native_mutex_debug): make argument type-agnostic
  to avoid later cast.

* thread_pthread.c (register_cached_thread_and_wait):
  replace PTHREAD_COND_INITIALIZER with RB_NATIVETHREAD_COND_INIT,
  use native_mutex_{lock,unlock}

* thread_pthread.c (use_cached_thread):
  use native_mutex_{lock,unlock}

* thread_pthread.c (native_sleep):
  use rb_nativethread_lock_t to match th->interrupt_lock,
  use native_mutex_{lock,unlock}

* thread_pthread.c (timer_thread_lock): use rb_nativethread_lock_t type

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-15 00:17:53 +00:00
nobu dfd8c5d402 thread.c: fix for non-scalar pthread_t
* configure.in (rb_cv_scalar_pthread_t): pthread_t is not required
  to be a scalar type.
* thread.c (fill_thread_id_string, thread_id_str): dump pthread_t
  in hexadecimal form if it is not a scalar type, assume it can be
  represented in a pointer form otherwise.  based on the patch by
  Rei Odaira at [ruby-core:62867].  [ruby-core:62857] [Bug #9884]
* thread_pthread.c (Init_native_thread, thread_start_func_1),
  (native_thread_create): set thread_id_str if needed.
* vm_core.h (rb_thread_t): add thread_id_string if needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-11 08:38:09 +00:00
nobu e2b10b6d13 thread_pthread.c: timer thread flag
* thread_pthread.c (timer_thread): add a flag to tell timer thread
  is created, since 0 may be a valid value as pthread_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-11 08:37:44 +00:00
nobu a5b9624fdc thread_pthread.c: variable for errno
* thread_pthread.c (rb_thread_wakeup_timer_thread_fd): use a local
  variable for errno.

* thread_pthread.c (consume_communication_pipe): ditto.  add
  EWOULDBLOCK case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10 15:52:45 +00:00
nobu 3385f6a0d4 thread_pthread.c: timer_thread_pipe struct
* thread_pthread.c (timer_thread_pipe): aggregate timer thread
  pipe stuff into a struct.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10 14:48:58 +00:00
nobu 779ce6b00e thread_pthread.c: compare with pthread_equal
* thread_pthread.c (ubf_select): compare thread_id with
  pthread_equal() but not directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10 14:47:04 +00:00
nobu a46e21c86f thread_pthread.c: variable for errno
* thread_pthread.c (timer_thread_sleep): use a local variable for
  errno.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10 04:32:10 +00:00
nobu ed37579c6a thread_*.c: constify
* thread_{pthread,win32}.c (native_cond_timedwait): constify.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-09 14:31:34 +00:00
nobu 6245e02cd3 configure.in: define SET_THREAD_NAME
* configure.in (SET_THREAD_NAME): define according to
  pthread_setname_np variations.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:11 +00:00
nobu bb7ae984f8 configure.in: use pthread_setname_np only if available
* configure.in: check if pthread_setname_np is available.
* thread_pthread.c: pthread_setname_np is not available on old
  Darwins.  [ruby-core:60524] [Bug #9492]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-13 02:06:36 +00:00
nobu f423a63cfa thread_pthread.c: use get_stack
* thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p):
  place get_stack above others to get stack boundary information.
  [ruby-core:60113] [Bug #9454]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28 07:33:20 +00:00
naruse 239c994243 * thread_pthread.c: rlimit is only available on Linux.
At least r44712 breaks FreeBSD.
  [ruby-core:60113] [Bug #9454]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28 06:29:51 +00:00
nobu 628f75b752 vm_core.h: rb_thread_struct::machine
* vm_core.h (rb_thread_struct): aggregate cpu stuff into a struct,
  so that a debugger can show its content at once.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28 06:09:58 +00:00
nobu d7b106db6f thread_pthread.c: cast to size_t
* thread_pthread.c (ruby_stack_overflowed_p): range of rlim_cur
  may be larger than size_t.  [ruby-core:60113] [Bug #9454]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-27 13:16:25 +00:00
nobu 60e85501f2 thread_pthread.c: get current main thread stack size
* thread_pthread.c: get current main thread stack size, which may
  be expanded than allocated size at initialization, by rlimit().
  [ruby-core:60113] [Bug #9454]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-27 12:53:48 +00:00
nobu 6802a3f6f2 thread_pthread.c: fix for dynamic PTHREAD_STACK_MIN
* thread_pthread.c (rb_thread_create_timer_thread): fix for platforms
  where PTHREAD_STACK_MIN is a dynamic value and not a compile-time
  constant.  [ruby-dev:47911] [Bug #9436]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21 11:14:54 +00:00
nobu 03a89f5bc3 * thread_pthread.c (rb_thread_create_timer_thread): fix missing paren.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21 08:26:17 +00:00
nobu ad9d4f0211 thread_pthread.c: expand timer thread stack size
* thread_pthread.c (rb_thread_create_timer_thread): expand timer
  thread stack size to get rid of segfault on FreeBSD/powerpc64.
  based on the patch by Steve Wills at [ruby-core:59923].
  [ruby-core:56590] [Bug #8783]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21 07:26:47 +00:00
nobu a4963d464b thread_pthread.c: timer thread stack size
* thread_pthread.c (rb_thread_create_timer_thread): define the stack
  size for timer thread at compile time.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21 07:26:46 +00:00
nobu 53953eee7c thread_pthread.c: use get_main_stack properly
* thread_pthread.c (ruby_init_stack): set stack_start properly by
  get_main_stack() if possible.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-18 13:47:12 +00:00
akr fbdd08b8c2 * thread_pthread.c (rb_thread_create_timer_thread): Show error
message instead of error number.

* cont.c (fiber_machine_stack_alloc): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-16 16:49:39 +00:00
nobu 09c96a7858 thread_pthread.c: set thread name
* thread_pthread.c (thread_timer): set timer thread name on OSX too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-03 01:37:00 +00:00
nobu 1908874bf4 thread_pthread.c: fix compile error on HP-UX
* thread_pthread.c (sys/dyntune.h): for gettune().
* thread_pthread.c (hpux_attr_getstackaddr): fix missing *.
  [ruby-core:56983] [Feature #8793]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-03 12:35:22 +00:00
nobu 93024c6377 thread_pthread.c: fill stack info by creator thread
* thread_pthread.c (native_thread_init_stack): wait the creator thread
  to fill machine stack info, if get_stack_of() is available.
* thread_pthread.c (native_thread_create): fill the created thread
  stack info after starting, if get_stack_of() is available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30 13:37:59 +00:00
nobu b59b1b9bd9 thread_pthread.c: define attr only if used
* thread_pthread.c (native_thread_create): define attr only if it is
  used, and merge pthread_create() calls.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30 13:37:51 +00:00
nobu 7703ba8544 thread_pthread.c: get_main_stack
* thread_pthread.c (get_main_stack): separate function to get stack of
  main thread.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30 13:37:46 +00:00
nobu f8b3123eb9 thread_pthread.c: fix vps_pagesize
* thread_pthread.c (hpux_attr_getstackaddr): vps_pagesize is defaulted
  to 16 and in Kbytes.  [ruby-core:56863]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30 01:26:05 +00:00
nobu 806ddf6713 thread_pthread.c: get_stack on HP-UX
* thread_pthread.c (hpux_attr_getstackaddr): basic support for the
  get_stack() under HP-UX.  based on the patch by michal@rokos.cz
  (Michal Rokos) at [ruby-core:56645].  [Feature #8793]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-28 08:20:13 +00:00
nobu b7aa49b9a7 thread_pthread.c: dup code
* thread_pthread.c (get_stack): merge duplicated code split by ifdef.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-28 08:20:10 +00:00
nobu 50b17c701f thread_pthread.c: simplify
* thread_pthread.c (register_cached_thread_and_wait): simplify and
  reduce branches.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-28 05:59:13 +00:00
ko1 4d3feac974 * thread_(pthread|win32).h: rename rb_thread_cond_t to
rb_nativethread_cond_t.
* thread.c, thread_pthread.c, thread_win32.c, vm_core.h: catch up
  renaming.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 10:50:32 +00:00
ko1 b2bcef7294 * thread_native.h: add rb_nativethread_self() which returns
current running native thread identifier.
* thread_[pthread|win32].c: implement rb_nativethread_self().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 10:46:37 +00:00
ko1 2b1088c89f * thread_pthread.h, thread_win32.h: rename rb_thread_id_t to
rb_nativethread_id_t.
* thread_pthread.c, vm_core.h: use rb_nativethread_id_t.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 10:38:36 +00:00
ko1 bd058912da * thread_native.h: added.
Move native thread related lines from vm_core.h.
  And declare several functions "rb_nativethread_lock_*",
  manipulate locking.
* common.mk: add thread_native.h.
* thread.c: add functions "rb_nativethread_lock_*".
* thraed.c, thread_[pthread,win32].[ch]: rename rb_thread_lock_t
  to rb_nativethread_lock_t to make it clear that this lock is for
  native thraeds, not for ruby threads.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 09:53:14 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
akr ab750920b9 * thread_pthread.c (ruby_init_stack): Add STACK_GROW_DIR_DETECTION.
This fixes a compilation failure while cross-compiling for Tensilica
  Xtensa Processor.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-27 11:21:10 +00:00
akr ed9e1f9ad9 * thread_pthread.c (ruby_init_stack): Add STACK_GROW_DIR_DETECTION.
This fixes a compilation failure while cross-compiling for ARM.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-26 08:43:37 +00:00
yugui 75b4c8f490 * thread_pthread.c: Fixes wrong scopes of #if USE_SLEEPY_TIMER_THREAD
.. #endif sections.  This fixes a build error on NativeClient.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 08:01:27 +00:00
yugui 360edb1c04 * thread_pthread.c (ruby_init_stack): Avoid using uninitialized value.
stackaddr and size are not set if get_stack() fails.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 08:01:23 +00:00
nobu 77ff241fa0 timev.h: move time_t stuffs
* timev.h (TYPEOF_TIMEVAL_TV_SEC, unsigned_time_t): move from time.c.

* thread.c: use definitions in timev.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:08:36 +00:00
nobu 57123fb2f1 thread_pthread.c: poll.h is already included
* thread_pthread.c (poll.h): already included in ruby/io.h from
  thread.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-27 06:17:36 +00:00
akr bfb0edbad2 * internal.h: Define TIMET_MAX and TIMET_MIN here.
* time.c: Remove TIMET_MAX and TIMET_MIN definitions.

* thread.c: Ditto.

* thread_pthread.c: Remove TIMET_MAX definition.

* thread_win32.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-26 14:45:55 +00:00
kosaki 798ff850e4 * configure.in: check struct timeval exist or not.
* include/ruby/missing.h (struct timeval): check HAVE_STRUCT_TIMEVAL
  properly. and don't include sys/time.h if struct timeval exist.

* file.c: include sys/time.h explicitly.
* random.c: ditto.
* thread_pthread.c: ditto.
* time.c: ditto.
* ext/date/date_strftime.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-16 05:06:47 +00:00
kosaki e1807e5995 * thread_pthread.c (numberof): renamed from ARRAY_SIZE() because
other all files use numberof().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-15 21:26:36 +00:00