summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-10-08 14:17:53 +0000
committerGuido van Rossum <guido@python.org>1996-10-08 14:17:53 +0000
commit7a0232ab140edb21ae16ee49357e94e5aa80a647 (patch)
treeffa7dd2496674f08f1b9cf2e7dcc332bd524897f /Python
parentfd9d95648aa55e5ef7b5c240176541317052cac8 (diff)
downloadcpython-7a0232ab140edb21ae16ee49357e94e5aa80a647.tar.gz
Sjoerd's thread changes (including down_sema typo fix).
Note: waitflag not supported on NT.
Diffstat (limited to 'Python')
-rw-r--r--Python/thread_cthread.h5
-rw-r--r--Python/thread_foobar.h5
-rw-r--r--Python/thread_lwp.h5
-rw-r--r--Python/thread_nt.h6
-rw-r--r--Python/thread_os2.h4
-rw-r--r--Python/thread_pthread.h5
-rw-r--r--Python/thread_sgi.h13
-rw-r--r--Python/thread_solaris.h22
8 files changed, 47 insertions, 18 deletions
diff --git a/Python/thread_cthread.h b/Python/thread_cthread.h
index 79bcc0f40d..1e731ac5c0 100644
--- a/Python/thread_cthread.h
+++ b/Python/thread_cthread.h
@@ -183,10 +183,11 @@ void free_sema _P1(sema, type_sema sema)
dprintf(("free_sema(%lx) called\n", (long) sema));
}
-void down_sema _P1(sema, type_sema sema)
+int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
{
- dprintf(("down_sema(%lx) called\n", (long) sema));
+ dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
dprintf(("down_sema(%lx) return\n", (long) sema));
+ return -1;
}
void up_sema _P1(sema, type_sema sema)
diff --git a/Python/thread_foobar.h b/Python/thread_foobar.h
index 772f26b6f9..0bf58f48ab 100644
--- a/Python/thread_foobar.h
+++ b/Python/thread_foobar.h
@@ -142,10 +142,11 @@ void free_sema _P1(sema, type_sema sema)
dprintf(("free_sema(%lx) called\n", (long) sema));
}
-void down_sema _P1(sema, type_sema sema)
+int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
{
- dprintf(("down_sema(%lx) called\n", (long) sema));
+ dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
dprintf(("down_sema(%lx) return\n", (long) sema));
+ return -1;
}
void up_sema _P1(sema, type_sema sema)
diff --git a/Python/thread_lwp.h b/Python/thread_lwp.h
index a4e943f008..1541334503 100644
--- a/Python/thread_lwp.h
+++ b/Python/thread_lwp.h
@@ -190,10 +190,11 @@ void free_sema _P1(sema, type_sema sema)
dprintf(("free_sema(%lx) called\n", (long) sema));
}
-void down_sema _P1(sema, type_sema sema)
+int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
{
- dprintf(("down_sema(%lx) called\n", (long) sema));
+ dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
dprintf(("down_sema(%lx) return\n", (long) sema));
+ return -1;
}
void up_sema _P1(sema, type_sema sema)
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 453e942b99..18b01be6fd 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -223,7 +223,10 @@ void free_sema(type_sema aSemaphore)
CloseHandle((HANDLE) aSemaphore);
}
-void down_sema(type_sema aSemaphore)
+/*
+ XXX must do something about waitflag
+ */
+int down_sema(type_sema aSemaphore, int waitflag)
{
DWORD waitResult;
@@ -232,6 +235,7 @@ void down_sema(type_sema aSemaphore)
waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE);
dprintf(("%ld: down_sema(%lx) return: %l\n", get_thread_ident(),(long) aSemaphore, waitResult));
+ return 0;
}
void up_sema(type_sema aSemaphore)
diff --git a/Python/thread_os2.h b/Python/thread_os2.h
index f9eda928db..00a5244feb 100644
--- a/Python/thread_os2.h
+++ b/Python/thread_os2.h
@@ -203,9 +203,9 @@ void free_sema(type_sema aSemaphore)
}
-void down_sema(type_sema aSemaphore)
+void down_sema(type_sema aSemaphore, int waitflag)
{
-
+ return -1;
}
void up_sema(type_sema aSemaphore)
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index 0485e667cf..a43a2f81d6 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -274,10 +274,11 @@ void free_sema _P1(sema, type_sema sema)
dprintf(("free_sema(%lx) called\n", (long) sema));
}
-void down_sema _P1(sema, type_sema sema)
+int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
{
- dprintf(("down_sema(%lx) called\n", (long) sema));
+ dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
dprintf(("down_sema(%lx) return\n", (long) sema));
+ return -1;
}
void up_sema _P1(sema, type_sema sema)
diff --git a/Python/thread_sgi.h b/Python/thread_sgi.h
index 654d4aec3a..79357a5f5f 100644
--- a/Python/thread_sgi.h
+++ b/Python/thread_sgi.h
@@ -423,12 +423,19 @@ void free_sema _P1(sema, type_sema sema)
usfreesema((usema_t *) sema, shared_arena);
}
-void down_sema _P1(sema, type_sema sema)
+int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
{
+ int success;
+
dprintf(("down_sema(%lx) called\n", (long) sema));
- if (uspsema((usema_t *) sema) < 0)
- perror("uspsema");
+ if (waitflag)
+ success = uspsema((usema_t *) sema);
+ else
+ success = uscpsema((usema_t *) sema);
+ if (success < 0)
+ perror(waitflag ? "uspsema" : "uscpsema");
dprintf(("down_sema(%lx) return\n", (long) sema));
+ return success;
}
void up_sema _P1(sema, type_sema sema)
diff --git a/Python/thread_solaris.h b/Python/thread_solaris.h
index f7fd056922..871affa096 100644
--- a/Python/thread_solaris.h
+++ b/Python/thread_solaris.h
@@ -25,6 +25,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#include </usr/include/thread.h>
#undef _POSIX_THREADS
@@ -211,12 +212,25 @@ void free_sema _P1(sema, type_sema sema)
free((void *) sema);
}
-void down_sema _P1(sema, type_sema sema)
+int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
{
+ int success;
+
dprintf(("down_sema(%lx) called\n", (long) sema));
- if (sema_wait((sema_t *) sema))
- perror("sema_wait");
- dprintf(("down_sema(%lx) return\n", (long) sema));
+ if (waitflag)
+ success = sema_wait((sema_t *) sema);
+ else
+ success = sema_trywait((sema_t *) sema);
+ if (success < 0) {
+ if (errno == EBUSY)
+ success = 0;
+ else
+ perror("sema_wait");
+ }
+ else
+ success = !success;
+ dprintf(("down_sema(%lx) return %d\n", (long) sema, success));
+ return success;
}
void up_sema _P1(sema, type_sema sema)