From 8a90a4b73ddc1709dd6b6ee5799cce4d57b66a8e Mon Sep 17 00:00:00 2001 From: rpj Date: Mon, 27 Jul 1998 08:11:21 +0000 Subject: Mon Jul 27 17:46:37 1998 Ross Johnson * create.c (pthread_create): Start of rewrite. Not completed yet. * private.c (_pthread_new_thread_entry): Start of rewrite. Not complete. * implement.h (_pthread_threads_thread): Rename, remove thread member, add win32handle and ptstatus members. (_pthread_t): Add. * pthread.h: pthread_t is no longer mapped directly to a Win32 HANDLE type. This is so we can let the Win32 thread terminate and reuse the HANDLE while pthreads holds it's own thread ID until the last waiting join exits. --- ChangeLog | 16 ++++++++++++++++ create.c | 12 ++++++------ implement.h | 12 +++++++++--- private.c | 7 ++++--- pthread.h | 2 +- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37a1c9c..d8d18b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Mon Jul 27 17:46:37 1998 Ross Johnson + + * create.c (pthread_create): Start of rewrite. Not completed yet. + + * private.c (_pthread_new_thread_entry): Start of rewrite. Not + complete. + + * implement.h (_pthread_threads_thread): Rename, remove thread + member, add win32handle and ptstatus members. + (_pthread_t): Add. + + * pthread.h: pthread_t is no longer mapped directly to a Win32 + HANDLE type. This is so we can let the Win32 thread terminate and + reuse the HANDLE while pthreads holds it's own thread ID until + the last waiting join exits. + Mon Jul 27 00:20:37 1998 Ross Johnson * private.c (_pthread_delete_thread_entry): Destroy the thread diff --git a/create.c b/create.c index dc54c37..61c5aff 100644 --- a/create.c +++ b/create.c @@ -19,20 +19,20 @@ _pthread_start_call(void * us_arg) /* We're now in a running thread. Any local variables here are on this threads private stack so we're safe to leave data in them until we leave. */ - _pthread_threads_thread__t * us; + pthread_t us; _pthread_call_t * call; unsigned (*func)(void *); void * arg; unsigned ret; int from; - us = (_pthread_threads_thread__t *) us_arg; + us = (pthread_t) us_arg; /* FIXME: For now, if priority setting fails then at least ensure that our records reflect true reality. */ - if (SetThreadPriority((HANDLE) us->thread, us->attr.priority) == FALSE) + if (SetThreadPriority((HANDLE) us->win32handle, us->attr.priority) == FALSE) { - us->attr.priority = GetThreadPriority((HANDLE) us->thread); + us->attr.priority = GetThreadPriority((HANDLE) us->win32handle; } func = us->call.routine; @@ -56,14 +56,14 @@ pthread_create(pthread_t *thread, void * security = NULL; DWORD threadID; pthread_attr_t * attr_copy; - _pthread_threads_thread_t * us; + pthread_t * usptr; /* Success unless otherwise set. */ int ret; /* CRITICAL SECTION */ pthread_mutex_lock(&_pthread_table_mutex); - ret = _pthread_new_thread_entry((pthread_t) handle, us); + ret = _pthread_new_thread_entry((pthread_t) handle, usptr); pthread_mutex_lock(&_pthread_table_mutex); /* END CRITICAL SECTION */ diff --git a/implement.h b/implement.h index e830293..c19e6b9 100644 --- a/implement.h +++ b/implement.h @@ -55,10 +55,16 @@ typedef struct { (&_pthread_threads_mutex_table[_PTHREAD_THREADS_TABLE_INDEX(this)]) /* An element in the thread table. */ -typedef struct _pthread_threads_thread _pthread_threads_thread_t; +typedef struct _pthread _pthread_t; -struct _pthread_threads_thread { - pthread_t thread; +/* Keep the old typedef until we've updated all source files. */ +typedef struct _pthread _pthread_threads_thread_t; + +/* Related constants */ +struct _pthread { + HANDLE win32handle; + int ptstatus; /* _PTHREAD_EXITED + _PTHREAD_REUSABLE */ pthread_attr_t attr; _pthread_call_t call; int cancel_pending; diff --git a/private.c b/private.c index 8424277..44afd4f 100644 --- a/private.c +++ b/private.c @@ -23,16 +23,17 @@ */ int -_pthread_new_thread_entry(pthread_t thread, _pthread_threads_thread_t * entry) +_pthread_new_thread_entry(_pthread_t * entry) { - _pthread_threads_thread_t * new; + _pthread_t new; if (_pthread_threads_count >= PTHREAD_THREADS_MAX) { return EAGAIN; } - new = &_pthread_threads_table[_PTHREAD_HASH_INDEX(thread)]; + /* Use a preloaded reuse stack of pthread_t. */ + new = while (new->thread != NULL) { diff --git a/pthread.h b/pthread.h index 129c720..d2be555 100644 --- a/pthread.h +++ b/pthread.h @@ -65,7 +65,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. pointer to an object in memory. */ #define PTHREAD_CANCELED ((void *) 1) -typedef HANDLE pthread_t; +typedef struct _pthread * pthread_t; typedef CRITICAL_SECTION pthread_mutex_t; typedef DWORD pthread_key_t; -- cgit v1.2.3