Sjoerd's thread changes (including down_sema typo fix).
Note: waitflag not supported on NT.
This commit is contained in:
parent
5b1d9bad32
commit
cf1474b73a
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue