2006-12-31 10:02:22 -05:00
|
|
|
/* -*-c-*- */
|
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
thread_win32.ci -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
|
|
|
|
Copyright (C) 2004-2006 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifdef THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
|
|
|
|
|
|
|
|
#include <process.h>
|
|
|
|
|
|
|
|
#define WIN32_WAIT_TIMEOUT 10 /* 10 ms */
|
|
|
|
#undef Sleep
|
|
|
|
|
|
|
|
#define native_thread_yield() Sleep(0)
|
2007-02-08 06:51:40 -05:00
|
|
|
#define remove_signal_thread_list(th)
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
Init_native_thread()
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th = GET_THREAD();
|
2006-12-31 10:02:22 -05:00
|
|
|
DuplicateHandle(GetCurrentProcess(),
|
|
|
|
GetCurrentThread(),
|
|
|
|
GetCurrentProcess(),
|
|
|
|
&th->thread_id, 0, FALSE, DUPLICATE_SAME_ACCESS);
|
|
|
|
|
|
|
|
th->native_thread_data.interrupt_event = CreateEvent(0, TRUE, FALSE, 0);
|
|
|
|
|
|
|
|
thread_debug("initial thread (th: %p, thid: %p, event: %p)\n",
|
|
|
|
th, GET_THREAD()->thread_id,
|
|
|
|
th->native_thread_data.interrupt_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
w32_show_error_message()
|
|
|
|
{
|
|
|
|
LPVOID lpMsgBuf;
|
|
|
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL,
|
|
|
|
GetLastError(),
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPTSTR) & lpMsgBuf, 0, NULL);
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* {int *a=0; *a=0;} */
|
2006-12-31 10:02:22 -05:00
|
|
|
MessageBox(NULL, (LPCTSTR) lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION);
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* exit(1); */
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
w32_wait_event(HANDLE event, DWORD timeout, rb_thread_t *th)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
HANDLE events[2];
|
|
|
|
int count = 0;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
events[count++] = event;
|
|
|
|
thread_debug(" * handle: %p (count: %d)\n", event, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (th) {
|
|
|
|
HANDLE intr = th->native_thread_data.interrupt_event;
|
|
|
|
ResetEvent(intr);
|
|
|
|
if (th->interrupt_flag) {
|
|
|
|
SetEvent(intr);
|
|
|
|
}
|
|
|
|
|
|
|
|
events[count++] = intr;
|
|
|
|
thread_debug(" * handle: %p (count: %d, intr)\n", intr, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
thread_debug(" WaitForMultipleObjects start (count: %d)\n", count);
|
|
|
|
ret = WaitForMultipleObjects(count, events, FALSE, timeout);
|
|
|
|
thread_debug(" WaitForMultipleObjects end (ret: %d)\n", ret);
|
|
|
|
|
|
|
|
if (ret == WAIT_OBJECT_0 + count - 1 && th) {
|
|
|
|
errno = EINTR;
|
|
|
|
}
|
|
|
|
if (ret == -1 && THREAD_DEBUG) {
|
|
|
|
int i;
|
|
|
|
DWORD dmy;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
thread_debug(" * error handle %d - %s\n", i,
|
|
|
|
GetHandleInformation(events[i], &dmy) ? "OK" : "NG");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-02-08 06:51:40 -05:00
|
|
|
static void ubf_handle(rb_thread_t *th);
|
|
|
|
#define ubf_select ubf_handle
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
static void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
native_sleep(rb_thread_t *th, struct timeval *tv)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
DWORD msec;
|
|
|
|
if (tv) {
|
|
|
|
msec = tv->tv_sec * 1000 + tv->tv_usec / 1000;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msec = INFINITE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GVL_UNLOCK_BEGIN();
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
int status = th->status;
|
|
|
|
th->status = THREAD_STOPPED;
|
2007-02-08 06:51:40 -05:00
|
|
|
th->unblock_function = ubf_handle;
|
2006-12-31 10:02:22 -05:00
|
|
|
thread_debug("native_sleep start (%d)\n", (int)msec);
|
|
|
|
ret = w32_wait_event(0, msec, th);
|
|
|
|
thread_debug("native_sleep done (%d)\n", ret);
|
2007-02-08 06:51:40 -05:00
|
|
|
th->unblock_function = 0;
|
2006-12-31 10:02:22 -05:00
|
|
|
th->status = status;
|
|
|
|
}
|
|
|
|
GVL_UNLOCK_END();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
native_mutex_lock(rb_thread_lock_t *lock)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
#if USE_WIN32_MUTEX
|
|
|
|
DWORD result;
|
|
|
|
while (1) {
|
|
|
|
thread_debug("native_mutex_lock: %p\n", *lock);
|
|
|
|
result = w32_wait_event(*lock, INFINITE, 0);
|
|
|
|
switch (result) {
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
/* get mutex object */
|
|
|
|
thread_debug("acquire mutex: %p\n", *lock);
|
|
|
|
return 0;
|
|
|
|
case WAIT_OBJECT_0 + 1:
|
|
|
|
/* interrupt */
|
|
|
|
errno = EINTR;
|
|
|
|
thread_debug("acquire mutex interrupted: %p\n", *lock);
|
|
|
|
return 0;
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
thread_debug("timeout mutex: %p\n", *lock);
|
|
|
|
break;
|
|
|
|
case WAIT_ABANDONED:
|
|
|
|
rb_bug("win32_mutex_lock: WAIT_ABANDONED");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rb_bug("win32_mutex_lock: unknown result (%d)", result);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
EnterCriticalSection(lock);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
native_mutex_unlock(rb_thread_lock_t *lock)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
#if USE_WIN32_MUTEX
|
|
|
|
thread_debug("release mutex: %p\n", *lock);
|
|
|
|
return ReleaseMutex(*lock);
|
|
|
|
#else
|
|
|
|
LeaveCriticalSection(lock);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
native_mutex_trylock(rb_thread_lock_t *lock)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
#if USE_WIN32MUTEX
|
|
|
|
int result;
|
|
|
|
thread_debug("native_mutex_trylock: %p\n", *lock);
|
|
|
|
result = w32_wait_event(*lock, 1, 0);
|
|
|
|
thread_debug("native_mutex_trylock result: %d\n", result);
|
|
|
|
switch (result) {
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
return 0;
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
return EBUSY;
|
|
|
|
}
|
|
|
|
return EINVAL;
|
|
|
|
#else
|
|
|
|
return TryEnterCriticalSection(lock) == 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
native_mutex_initialize(rb_thread_lock_t *lock)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
#if USE_WIN32MUTEX
|
|
|
|
*lock = CreateMutex(NULL, FALSE, NULL);
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* thread_debug("initialize mutex: %p\n", *lock); */
|
2006-12-31 10:02:22 -05:00
|
|
|
#else
|
|
|
|
InitializeCriticalSection(lock);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
NOINLINE(static int
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
thread_start_func_2(rb_thread_t *th, VALUE *stack_start));
|
2006-12-31 10:02:22 -05:00
|
|
|
void static thread_cleanup_func(void *th_ptr);
|
|
|
|
|
|
|
|
static unsigned int _stdcall
|
|
|
|
thread_start_func_1(void *th_ptr)
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th = th_ptr;
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE stack_start;
|
|
|
|
/* run */
|
|
|
|
th->native_thread_data.interrupt_event = CreateEvent(0, TRUE, FALSE, 0);
|
|
|
|
|
|
|
|
thread_debug("thread created (th: %p, thid: %p, event: %p)\n", th,
|
|
|
|
th->thread_id, th->native_thread_data.interrupt_event);
|
|
|
|
thread_start_func_2(th, &stack_start);
|
|
|
|
thread_cleanup_func(th);
|
|
|
|
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* native_mutex_unlock(&GET_VM()->global_interpreter_lock); */
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
thread_debug("close handle - intr: %p, thid: %p\n",
|
|
|
|
th->native_thread_data.interrupt_event, th->thread_id);
|
|
|
|
CloseHandle(th->native_thread_data.interrupt_event);
|
|
|
|
CloseHandle(th->thread_id);
|
|
|
|
thread_debug("thread deleted (th: %p)\n", th);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void make_timer_thread();
|
|
|
|
|
|
|
|
static HANDLE
|
|
|
|
w32_create_thread(DWORD stack_size, void *func, void *val)
|
|
|
|
{
|
|
|
|
HANDLE handle;
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
DWORD dmy;
|
|
|
|
handle = CreateThread(0, stack_size, func, val, 0, &dmy);
|
|
|
|
#else
|
|
|
|
handle = (HANDLE) _beginthreadex(0, stack_size, func, val, 0, 0);
|
|
|
|
#endif
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
native_thread_create(rb_thread_t *th)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
size_t stack_size = 4 * 1024 - sizeof(int); /* 4KB */
|
|
|
|
|
|
|
|
if ((th->thread_id =
|
|
|
|
w32_create_thread(stack_size, thread_start_func_1, th))
|
|
|
|
== 0) {
|
|
|
|
rb_raise(rb_eThreadError, "can't create Thread (%d)", errno);
|
|
|
|
}
|
|
|
|
if (THREAD_DEBUG) {
|
|
|
|
Sleep(0);
|
|
|
|
thread_debug("create: (th: %p, thid: %p, intr: %p), stack size: %d\n",
|
|
|
|
th, th->thread_id,
|
|
|
|
th->native_thread_data.interrupt_event, stack_size);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-07 04:47:52 -05:00
|
|
|
static void
|
|
|
|
native_thread_join(HANDLE th)
|
|
|
|
{
|
|
|
|
w32_wait_event(th, 0, 0);
|
|
|
|
}
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
static void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
native_thread_apply_priority(rb_thread_t *th)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
int priority = th->priority;
|
|
|
|
if (th->priority > 0) {
|
|
|
|
priority = THREAD_PRIORITY_ABOVE_NORMAL;
|
|
|
|
}
|
|
|
|
else if (th->priority < 0) {
|
|
|
|
priority = THREAD_PRIORITY_BELOW_NORMAL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
priority = THREAD_PRIORITY_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetThreadPriority(th->thread_id, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-02-08 06:51:40 -05:00
|
|
|
ubf_handle(rb_thread_t *th)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
2007-02-08 06:51:40 -05:00
|
|
|
thread_debug("ubf_handle: %p\n", th);
|
2006-12-31 10:02:22 -05:00
|
|
|
SetEvent(th->native_thread_data.interrupt_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void timer_thread_function(void);
|
|
|
|
|
2007-01-07 04:47:52 -05:00
|
|
|
static HANDLE timer_thread_id = 0;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
static unsigned int _stdcall
|
|
|
|
timer_thread_func(void *dummy)
|
|
|
|
{
|
|
|
|
thread_debug("timer_thread\n");
|
|
|
|
while (system_working) {
|
|
|
|
Sleep(WIN32_WAIT_TIMEOUT);
|
|
|
|
timer_thread_function();
|
|
|
|
}
|
|
|
|
thread_debug("timer killed\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rb_thread_create_timer_thread(void)
|
|
|
|
{
|
2007-01-07 04:47:52 -05:00
|
|
|
if (timer_thread_id == 0) {
|
|
|
|
timer_thread_id = w32_create_thread(1024, timer_thread_func, 0);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */
|