#include <config.h>
#include <stdio.h>
-#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include "lwp.h"
int LwpMaxpri = 0; /* maximum priority so far */
int LwpStackGrowsDown;
-static sigset_t oldmask;
-
static void lwpStackCheckInit(struct lwpProc *newp);
static void lwpStackCheck(struct lwpProc *newp);
static void lwpStackCheckUsed(struct lwpProc *newp);
void
lwpReschedule(void)
{
- static int lcount = LCOUNT;
static struct lwpProc *nextp;
static int i;
- static sigset_t tmask;
if (LwpCurrent && (LwpCurrent->flags & LWP_STACKCHECK)) {
lwpStackCheck(LwpCurrent);
}
- if (!--lcount) {
- int p = lwpSetPriority(LWP_MAX_PRIO - 1);
- lcount = LCOUNT;
- sigprocmask(SIG_SETMASK, &oldmask, &tmask);
- sigprocmask(SIG_SETMASK, &tmask, &oldmask);
- LwpCurrent->pri = p;
- }
/* destroy dead threads */
lwpStatus(LwpCurrent, "Cleaning dead queue");
void
lwpEntryPoint(void)
{
- sigset_t set;
-
- sigemptyset(&set);
- sigaddset(&set, SIGALRM);
- sigprocmask(SIG_SETMASK, &set, &oldmask);
*LwpContextPtr = LwpCurrent->ud;
-
lwpStatus(LwpCurrent, "starting at entry point");
(*LwpCurrent->entry)(LwpCurrent->ud);
lwpExit();
#include <setjmp.h>
#endif /* !UCONTEXT */
-/* `liveness' counter: check signals every `n' visits to the scheduler */
-/* note: the lower this value, the more responsive the system but the */
-/* more inefficient the context switch time */
-#define LCOUNT -1
-
/* process control block. do *not* change the position of context */
struct lwpProc {
#ifdef UCONTEXT