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

197 Коммитов

Автор SHA1 Сообщение Дата
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
kosaki bcf1293681 * thread_pthread.c (ARRAY_SIZE): new.
* thread_pthread.c (gvl_acquire_common): use low priority
  notification for avoiding timer thread interval confusion.
  If we use timer_thread_pipe[1], every gvl_yield() request
  one more gvl_yield(). It lead to thread starvation.
  [Bug #7999] [ruby-core:53095]
* thread_pthread.c (rb_reserved_fd_p): adds timer_thread_pipe_low
  to reserved fds.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 04:00:21 +00:00
kosaki 9c021064a2 * thread_pthread.c (rb_thread_wakeup_timer_thread_fd): add fd
argument and remove hardcoded dependency of timer_thread_pipe[1].
* thread_pthread.c (consume_communication_pipe): add fd argument.
* thread_pthread.c (close_communication_pipe): ditto.

* thread_pthread.c (timer_thread_sleep): adjust the above changes.

* thread_pthread.c (setup_communication_pipe_internal): factor
  out pipe initialize logic.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 04:00:10 +00:00
kosaki 0eeb116923 * thread_pthread.c (ubf_select): add to small comments why we
need to call rb_thread_wakeup_timer_thread().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 04:00:00 +00:00
kosaki 383a2579c3 * thread_pthread.c (rb_thread_create_timer_thread): factor out
creating communication pipe logic into separate function.
* thread_pthread.c (setup_communication_pipe): new helper function.
* thread_pthread.c (set_nonblock): moves a definition before
  setup_communication_pipe.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 03:59:49 +00:00
kosaki 368fdf9cc1 * thread_pthread.c (consume_communication_pipe): retry when
read returned CCP_READ_BUFF_SIZE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 03:59:39 +00:00
kosaki 27f25728e6 * thread_pthread.c (timer_thread_sleep): use poll() instead of
select(). select doesn't work if timer_thread_pipe[0] is
  greater than FD_SETSIZE.
* thread_pthread.c (USE_SLEEPY_TIMER_THREAD): add a dependency
  against poll.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 03:59:29 +00:00
kosaki 3887a34c90 * thread_pthread.c (USE_SLEEPY_TIMER_THREAD): use more accurate
ifdef condtions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 03:59:19 +00:00
kosaki 5cebbe8f9b * thread_pthread.c (set_nonblock): new helper function for set O_NONBLOCK.
* thread_pthread.c (rb_thread_create_timer_thread): set O_NONBLOCK
  to timer_thread_pipe[0] too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 03:59:07 +00:00
ko1 e5481ccd8e * thread_pthread.c (ruby_init_stack): ignore `STACK_END_ADDRESS'
if Ruby interpreter is running on co-routine.
  [Feature #2294]
  https://bugs.ruby-lang.org/issues/2294#note-18



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-23 04:39:02 +00:00
kosaki e32ce1868f * thread_pthread.c (gvl_init): Reset gvl.wait_yield explicitly when
fork()ing. Patch by Apollon Oikonomopoulos. Thanks!
  [Bug #7693][ruby-core:51424]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15 00:32:23 +00:00
yugui 6837b808cd * configure.in (OBJCOPY): Fixes build error for NativeClient.
Avoid disabling OBJCOPY for NativeClient.

* thread_pthread.c (rb_reserved_fd_p): USE_SLEEPY_TIMER_THREAD is
  always defined.  Fixes compilation error for NativeClient.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-03 05:46:29 +00:00
nobu be7bf5aa0c adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:04 +00:00
ko1 87e1616048 * vm.c: support variable VM/Machine stack sizes.
Specified by the following environment variaables:
  - RUBY_THREAD_VM_STACK_SIZE: vm stack size used at thread creation.
  default: 128KB (32bit CPU) or 256KB (64bit CPU).
  - RUBY_THREAD_MACHINE_STACK_SIZE: machine stack size used at thread
  creation. default: 512KB or 1024KB.
  - RUBY_FIBER_VM_STACK_SIZE: vm stack size used at fiber creation.
  default: 64KB or 128KB.
  - RUBY_FIBER_MACHINE_STACK_SIZE: machine stack size used at fiber
  creation. default: 256KB or 256KB.
  This values are specified at launched timing. You can not change
  these values at running time.
  Environ variables are only *hints* because:
  - They are aligned to 4KB.
  - They have minimum values (depend on OSs).
  - Machine stack settings are ignored by some OSs.
  Default values especially fiber stack sizes are increased.
  This change affect Fiber's behavior:
  (1) You can run more complex program on a Fiber.
  (2) You can not make many (thousands) Fibers because of
  lack of address space (on 32bit CPU).
  If (2) bothers you,
  (a) Use 64bit CPU with big memory, or
  (b) Specify RUBY_FIBER_(VM|MACHINE)_STACK_SIZE correctly.
  You need to choose correct stack size carefully. These values
  are completely rely on systems (OS/compiler and so on).
* vm_core.h (rb_vm_t::default_params): add to record above settings.
* vm.c (RubyVM::DEFAULT_PARAMS): add new constant to see
  above setting.
* thread_pthread.c: support RUBY_THREAD_MACHINE_STACK_SIZE.
* cont.c: support RUBY_FIBER_(VM|MACHINE)_STACK_SIZE.
* test/ruby/test_fiber.rb: add tests for above.
* test/ruby/test_thread.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-19 22:29:18 +00:00
kosaki 4e73323a60 * thread_pthread.c (rb_reserved_fd_p): fix typo in macro check
that prevented the ifdef ever being true.
  [Bug #7281] [ruby-core:48940]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05 16:43:32 +00:00
kosaki 9da62b63d9 * thread_pthread.c (native_thread_init, native_thread_destroy):
removed HAVE_PTHREAD_CONDATTR_INIT check because this silly
  #ifdef makes use-uninitialized-var issue and (2) native_cond_initialize()
  already have a right platform and caller don't need any additional care.
  [Bug #6825]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05 02:46:41 +00:00
nobu 5aa7ff2b8a thread_pthread.c: RUBY_STACK_MIN
* thread_pthread.c (RUBY_STACK_MIN): may not a compile time constant.
  fix r37079.  [ruby-dev:46322] [Bug #7247]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-01 10:47:27 +00:00
nobu fab7e66131 thread_pthread.c: precise stack size
* thread_pthread.c (ruby_init_stack): round stack limit to page size
  boundary to calculate stack size more precisely.  [ruby-dev:46174]
  [Bug #7084]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-04 02:43:30 +00:00
nobu cbe3646e68 * thread_pthread.c (RUBY_STACK_MIN_LIMIT): name magic number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-04 02:39:34 +00:00
nobu 54c17dc8a9 thread_pthread.c: init stack with ulimit
* thread_pthread.c (ruby_init_stack): use getrlimit() for the main
  thread on Mac OS X, since pthread_get_stack{addr,size}_np() and
  return the default value always, but not the ulimit value.
  [ruby-dev:46174] [Bug #7084]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-03 06:33:08 +00:00
kosaki d9dfe2e514 * thread_pthread.c (native_cond_initialize): destroy condattr
after using it. Patch by Stanislav Sedov. Thank you.
  [Bug #7041] [ruby-core:47619]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-20 14:16:02 +00:00
kosaki 187d2bc1d6 * thread_pthread.c (native_cond_initialize): clean up #ifdef condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-20 14:15:46 +00:00
nobu 4ef43fc02f adjust style
* thread_pthread.c, vm_eval.c: adjust style.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-04 02:52:44 +00:00
nobu 36c45154d6 thread_pthread.c: STACK_GROW_DIR_DETECTION
* thread_pthread.c (ruby_init_stack): STACK_GROW_DIR_DETECTION is
  necessary on platforms with unknown stack direction.  [Bug #6761]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-21 14:12:55 +00:00
naruse 7e9c25d076 * thread_pthread.c: use #ifdef, not #if.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19 18:43:24 +00:00
ko1 91aba07aff * thread_pthread.c (register_cached_thread_and_wait):
return immediately if malloc() failed.
  [ruby-core:43960] [ruby-trunk - Bug #6235]
* thread_pthread.c (USE_THREAD_CACHE): check already defined or not.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-26 08:01:35 +00:00
yugui f8601bd903 * eval.c: Add doxygen comments.
* ruby.c: ditto.

* thread_pthread.c: ditto

* version.c: ditto.

* vm_core.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-14 02:21:51 +00:00
naruse e901d2ce2c * thread_pthread.c (get_stack): Linux is the only OS which includes
the size of guard page into the stack size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 23:18:35 +00:00
nobu 9341988b41 thread_pthread.c: suppress warning
* thread_pthread.c (get_stack): define guard only when it is used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 04:09:35 +00:00
naruse 35973f273c * thread_pthread.c (rb_thread_create_timer_thread): assign return
value to the variable err.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 21:21:51 +00:00
naruse 67b8c950bf * thread_pthread.c (native_cond_initialize): fix typo in r36022.
this cause a failure on FreeBSD 8.2 amd64.
  http://fbsd.rubyci.org/~chkbuild/ruby-trunk/log/20120610T130201Z.diff.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 21:19:07 +00:00
yugui c3f3d77225 Fixes threading on NativeClient.
* thread_pthread.c (timer_thread_sleep): Extracted out a function from
  thread_timer(). Added an alternative implementation for platforms
  that lacks select(2) or pipe(2).
  (rb_thread_create_timer_thread, native_cond_initialize,
  native_cond_destroy): Replaced wrong HAVE_XXX checks.

* configure.in (pthread_attr_init): New check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 12:51:37 +00:00
nobu 8706c00dfd gc.h: IS_STACK_DIR_UPPER
* gc.h (IS_STACK_DIR_UPPER): utility macro.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 08:54:38 +00:00
nobu 068dafd21f thread_pthread.c: adjust stack size
* thread_pthread.c (get_stack): seems stack size does not include
  guard size on Mac OS X.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 08:54:32 +00:00
nobu 35c96b9003 thread_pthread.c: adjust stack size
* thread_pthread.c (ruby_init_stack): adjust stack size for offset of
  addr from the bottom.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 08:54:28 +00:00
nobu c4c79e256b thread_pthread.c: use stack info
* thread_pthread.c (ruby_init_stack): use stack info if possible.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 23:30:55 +00:00
kosaki 1a2ef6bae3 * thread_pthread.c (rb_thread_create_timer_thread): Added error
check when failing fcntl(). [Bug #6147] [ruby-dev:45364]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-18 08:47:54 +00:00
nobu 7788d102c9 fix NaCl support
* configure.in: fix function name to be checked, to initialize
  rb_thread_cond_t properly.
* thread_pthread.c (native_cond_initialize, native_cond_destroy):
  fix macro name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 14:04:02 +00:00
yugui 82983e834d * thread.c, thread_pthread.c: Moved pthread-specific preprocessor
hacks to thread_pthread.c


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 03:54:50 +00:00
yugui 76bc2d1ed7 Imports Ruby's port to NativeClient (a.k.a NaCl).
Patch by Google Inc. [ruby-core:45073].

* configure.in (RUBY_NACL): New M4 func to configure variables for
  NaCl.
  (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
  of Pepper interface types.
  (BTESTRUBY): New variable to specify which ruby should be run on
  "make btest". NaCl can run the built binary by sel_ldr, but it need
  rbconfig.rb. So this variable is distinguished from $MINIRUBY.
  
* thread_pthread.c: Disabled some features on NaCl.

* io.c: ditto.

* process.c: ditto.

* signal.c: ditto.

* file.c: ditto.

* missing/flock.c: ditto.

* nacl/pepper_main.c: An example implementation of Pepper application
  that embeds Ruby.

* nacl/example.html: An example of web page that uses the Pepper
  application.

* nacl/nacl-config.rb: Detects variants of NaCl SDK.

* nacl/GNUmakefile.in: Makefile template for NaCl specific build
  process.

* nacl/package.rb: script for packaging a NaCl-Ruby embedding
  application. 

* nacl/reate_nmf.rb: Wrapper script of create_nmf.py

* dln.c (dln_load): Added a hack to call on NaCl.

* util.c (ruby_getcwd): Path to the current directort is not available
  on NaCl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 02:48:59 +00:00
nobu 6a1f418672 * thread_pthread.c: add prototype declarations for older Mac OS X.
[ruby-core:43376][Bug #6170]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-10 07:53:24 +00:00
nobu c6671f1005 * adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 03:31:50 +00:00
nobu ac018e7b3e * thread_pthread.c (native_cond_timeout): cast explicitly to suppress
a warning.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-02 07:36:34 +00:00
nagachika b288aa2d89 * thread_pthread.c (ping_signal_thread_list): remove return value.
* thread_pthread.c (check_signal_thread_list): add a new function to
  check if signal thread list is empty.
* thread_pthread.c (thread_timer): check signal thread list after
  timer_thread_function(). main thread might be added into signal thread
  list during timer_thread_function().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-22 13:45:58 +00:00