This is a multi-part message in MIME format.
--------------000607040400080900090905
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit

Hi,

I attached a patch to avoid timer thread.  Your reviews are welcome.

- Timer thread -> Interrupt thread
  - Two tasks
    - For Signal delivery
    - For Guarantee to interrupt ruby threads
  - wake up if needed
  - Communicate with POSIX semaphore.
    - Communicate with Signal handlers
    - Communicate with Ruby threads
  - Rarely wake-up (to reduce power consumption :))

- Ruby thread context switch timing is known by setitimer (SIGVTALRM)
  - set a timer using setitimer() if there is
    at least one  waiting thread
  - disable a timer if there are no waiting threads


Known issues:
  - MacOS X (Darwin Kernel Version 9.8.0) doesn't have sem_timedwait().
    - workaround for MacOSX user:
      Replace sem_timedwait() with usleep(10000).
  - No Windows support
  - stick with some tests on several environments

----
Japanese / にほんご

タイマスレッドを無くすパッチをい討澆泙靴拭7覿鼻▲悒襯僉璽好譽奪錨え
ものは残っているけれど、あんまり走りません。レビュー頂けると幸いです。

-- 
// SASADA Koichi at atdot dot net

--------------000607040400080900090905
Content-Type: text/plain;
 name
void_timerthread.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename
void_timerthread.patch"

SW5kZXg6IHRocmVhZF9wdGhyZWFkLmMNCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0tLSB0aHJlYWRfcHRo
cmVhZC5jCShyZXZpc2lvbiAyOTk2NCkKKysrIHRocmVhZF9wdGhyZWFkLmMJKHdvcmtpbmcg
Y29weSkKQEAgLTExLDYgKzExLDcgQEAKIAogI2lmZGVmIFRIUkVBRF9TWVNURU1fREVQRU5E
RU5UX0lNUExFTUVOVEFUSU9OCiAKKyNpbmNsdWRlIDxzZW1hcGhvcmUuaD4KICNpbmNsdWRl
ICJnYy5oIgogCiAjaWZkZWYgSEFWRV9TWVNfUkVTT1VSQ0VfSApAQCAtNDgsNiArNDksMjAg
QEAgZ3ZsX3Nob3dfd2F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