diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | create.c | 12 | ||||
-rw-r--r-- | implement.h | 12 | ||||
-rw-r--r-- | private.c | 7 | ||||
-rw-r--r-- | pthread.h | 2 |
5 files changed, 36 insertions, 13 deletions
@@ -1,3 +1,19 @@ +Mon Jul 27 17:46:37 1998 Ross Johnson <rpj@swan.canberra.edu.au> + + * 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 <rpj@ixobrychus.canberra.edu.au> * private.c (_pthread_delete_thread_entry): Destroy the thread @@ -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; @@ -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) { @@ -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; |