Make empth_wakeup() and empth_terminate() wake up empth_sleep(), and
empth_sleep() return whether that happened: [EMPTH_LWP] (lwpWakeupSleep): New, factored out of lwpSelect(). [EMPTH_LWP] (lwpSelect): Use it. [EMPTH_LWP] (lwpWakeup): New. Call lwpWakeupFd() if sleeping in lwpSleepFd(), lwpWakeupSleep() if sleeping in lwpSleepUntil(). [EMPTH_LWP] (lwpTerminate, empth_wakeup): Use it rather than lwpWakeupFd(). [EMPTH_LWP] (lwpWakeupFd): Internal linkage. [EMPTH_LWP] (lwpSleepUntil): Reset member runtime, so that lwpWakeup() can test it reliably. Return how sleep woke up. [EMPTH_LWP] (empth_sleep): Return value of lwpSleepUntil(). [EMPTH_POSIX] (EMPTH_INTR): New. [EMPTH_POSIX] (empth_wakeup): Set state to it. [EMPTH_POSIX] (empth_restorectx): Clear state. [EMPTH_POSIX] (empth_sleep): Don't re-seleep when state is not clear, i.e. thread was woken up prematurely. Return how sleep woke up. [EMPTH_W32] (empth_sleep): Implement by waiting on hThreadEvent with a timeout rather than a straight Sleep(). Return how sleep woke up.
This commit is contained in:
parent
fe2de3d743
commit
cea39829af
7 changed files with 80 additions and 45 deletions
|
@ -29,7 +29,7 @@
|
|||
* lwp.c: lightweight process creation, destruction and manipulation
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Markus Armbruster, 2004-2006
|
||||
* Markus Armbruster, 2004-2007
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -145,7 +145,7 @@ lwpCreate(int priority, void (*entry)(void *), int stacksz,
|
|||
newp->argv = argv;
|
||||
newp->ud = ud;
|
||||
newp->dead = 0;
|
||||
newp->runtime = -1;
|
||||
newp->runtime = (time_t)-1;
|
||||
newp->fd = -1;
|
||||
if (LWP_MAX_PRIO <= priority)
|
||||
priority = LWP_MAX_PRIO - 1;
|
||||
|
@ -166,7 +166,7 @@ lwpCreate(int priority, void (*entry)(void *), int stacksz,
|
|||
return newp;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
lwpDestroy(struct lwpProc *proc)
|
||||
{
|
||||
if (proc->flags & LWP_STACKCHECK) {
|
||||
|
@ -244,8 +244,7 @@ lwpTerminate(struct lwpProc *p)
|
|||
{
|
||||
lwpStatus(p, "terminating process");
|
||||
p->dead = 1;
|
||||
if (p->fd >= 0)
|
||||
lwpWakeupFd(p);
|
||||
lwpWakeup(p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue