summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>1999-01-16 17:34:53 +0000
committerrpj <rpj>1999-01-16 17:34:53 +0000
commit9b75468a10363ada39a17563cca6bcd819ec8fcd (patch)
treeea082f51c28cb761f109f9a407e54c5c4fe41bd2
parent677bfb0881c56dad767a07b31ac543db284e16c6 (diff)
Sun Jan 17 12:01:26 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>snapshot-1999-01-17
* private.c (_pthread_sem_timedwait): Move from semaphore.c. * semaphore.c : Remove redundant #includes. (_pthread_sem_timedwait): Move to private.c. (sem_wait): Add missing abstime arg to pthreadCancelableWait() call. 1999-01-17 Ross Johnson <rpj@ise.canberra.edu.au> * runtest: New script to build and run a test in the tests directory.
-rw-r--r--ChangeLog12
-rw-r--r--condvar.c4
-rw-r--r--private.c60
-rw-r--r--semaphore.c64
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/runtest.bat9
6 files changed, 86 insertions, 67 deletions
diff --git a/ChangeLog b/ChangeLog
index 170f913..d4da384 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Sun Jan 17 12:01:26 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
+
+ * private.c (_pthread_sem_timedwait): Move from semaphore.c.
+
+ * semaphore.c : Remove redundant #includes.
+ (_pthread_sem_timedwait): Move to private.c.
+ (sem_wait): Add missing abstime arg to pthreadCancelableWait() call.
+
+Fri Jan 15 23:38:05 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
+
+ * condvar.c (cond_timedwait): Remove comment.
+
Fri Jan 15 15:41:28 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* pthread.h: Add new 'abstime' arg to pthreadCancelableWait()
diff --git a/condvar.c b/condvar.c
index 5bf99e8..f55fefa 100644
--- a/condvar.c
+++ b/condvar.c
@@ -413,10 +413,6 @@ cond_timedwait (pthread_cond_t * cond,
/*
* OK to increment cv->waiters because the caller locked 'mutex'
- *
- * [RPJ] FIXME: This can still lead to race conditions, which I think
- * are NOT the same as the unpredictable scheduling behaviour noted in the
- * POSIX Pthread specs.
*/
cv->waiters++;
diff --git a/private.c b/private.c
index 3a4a0da..f20413c 100644
--- a/private.c
+++ b/private.c
@@ -437,3 +437,63 @@ _pthread_callUserDestroyRoutines (pthread_t thread)
/* </JEB> */
+
+int
+_pthread_sem_timedwait (sem_t * sem, const struct timespec * abstime)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function waits on a semaphore for at most
+ * 'abstime'.
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * abstime
+ * pointer to an instance of struct timespec
+ *
+ * DESCRIPTION
+ * This function waits on a semaphore. If the
+ * semaphore value is greater than zero, it decreases
+ * its value by one. If the semaphore value is zero, then
+ * the calling thread (or process) is blocked until it can
+ * successfully decrease the value or until interrupted by
+ * a signal.
+ *
+ * If 'abstime' is a NULL pointer then this function will
+ * block until it can successfully decrease the value or
+ * until interrupted by a signal.
+ *
+ * RESULTS
+ * 0 successfully decreased semaphore,
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOSYS semaphores are not supported,
+ * EINTR the function was interrupted by a signal,
+ * EDEADLK a deadlock condition was detected.
+ * ETIMEDOUT abstime elapsed before success.
+ *
+ * ------------------------------------------------------
+ */
+{
+ DWORD msecs;
+
+ if (abstime == NULL)
+ {
+ msecs = INFINITE;
+ }
+ else
+ {
+ /* Calculate the number of milliseconds in abstime. */
+ msecs = abstime->tv_sec * 1000;
+ msecs += abstime->tv_nsec / 1000000;
+ }
+
+ return ((sem == NULL)
+ ? EINVAL
+ : pthreadCancelableWait (*sem, msecs)
+ );
+
+} /* _pthread_sem_timedwait */
+
+
diff --git a/semaphore.c b/semaphore.c
index fc24b1a..9200cdd 100644
--- a/semaphore.c
+++ b/semaphore.c
@@ -35,9 +35,6 @@
* -------------------------------------------------------------
*/
#include <pthread.h>
-#include <windows.h>
-#include <process.h>
-#include <errno.h>
#include <string.h>
#include "semaphore.h"
@@ -215,66 +212,7 @@ sem_wait (sem_t * sem)
return ((sem == NULL)
? EINVAL
- : pthreadCancelableWait (*sem)
- );
-
-} /* sem_wait */
-
-
-int
-_pthread_sem_timedwait (sem_t * sem, const struct timespec * abstime)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function waits on a semaphore for at most
- * 'abstime'.
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * abstime
- * pointer to an instance of struct timespec
- *
- * DESCRIPTION
- * This function waits on a semaphore. If the
- * semaphore value is greater than zero, it decreases
- * its value by one. If the semaphore value is zero, then
- * the calling thread (or process) is blocked until it can
- * successfully decrease the value or until interrupted by
- * a signal.
- *
- * If 'abstime' is a NULL pointer then this function will
- * block until it can successfully decrease the value or
- * until interrupted by a signal.
- *
- * RESULTS
- * 0 successfully decreased semaphore,
- * EINVAL 'sem' is not a valid semaphore,
- * ENOSYS semaphores are not supported,
- * EINTR the function was interrupted by a signal,
- * EDEADLK a deadlock condition was detected.
- * ETIMEDOUT abstime elapsed before success.
- *
- * ------------------------------------------------------
- */
-{
- DWORD msecs;
-
- if (abstime == NULL)
- {
- msecs = INFINITE;
- }
- else
- {
- /* Calculate the number of milliseconds in abstime. */
- msecs = abstime->tv_sec * 1000;
- msecs += abstime->tv_nsec / 1000000;
- }
-
- return ((sem == NULL)
- ? EINVAL
- : pthreadCancelableWait (*sem, msecs)
+ : pthreadCancelableWait (*sem, INFINITE)
);
} /* sem_wait */
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 54cccef..c5ac1ce 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+1999-01-17 Ross Johnson <rpj@ise.canberra.edu.au>
+
+ * runtest: New script to build and run a test in the tests directory.
+
Wed Dec 30 11:22:44 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* tsd1.c: Re-written. See comments at start of file.
diff --git a/tests/runtest.bat b/tests/runtest.bat
new file mode 100644
index 0000000..fd68008
--- /dev/null
+++ b/tests/runtest.bat
@@ -0,0 +1,9 @@
+cd tmp
+cl /W3 /MT /nologo /Yd /Zi -I..\.. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c ..\%1.c
+cl /Feaout.exe /Zi %1.obj ..\..\pthread.lib
+del %1.obj
+copy ..\..\pthread.dll .
+aout.exe
+del aout.exe
+del pthread.dll
+cd ..