extern struct blkbuf bufpool[NBUFS];
extern struct p_tab ptab[PTABSIZE];
+extern struct p_tab *ptab_end;
extern struct oft of_tab[OFTSIZE]; /* Open File Table */
extern struct cinode i_tab[ITABSIZE]; /* In-core inode table */
extern struct mount fs_tab[NMOUNTS]; /* Mount table */
struct blkbuf bufpool[NBUFS];
struct p_tab ptab[PTABSIZE];
+struct p_tab *ptab_end; /* Points to first byte off end */
struct oft of_tab[OFTSIZE]; /* Open File Table */
struct cinode i_tab[ITABSIZE]; /* In-core inode table */
struct mount fs_tab[NMOUNTS]; /* In-core mount table */
kprintf("wakeup(0x%x)\n", event);
#endif
irq = di();
- for (p = ptab; p < ptab + maxproc; ++p) {
+ for (p = ptab; p < ptab_end; ++p) {
if (p->p_status > P_RUNNING && p->p_wait == event) {
#ifdef DEBUG
kprintf("wakeup: found proc 0x%x pid %d\n",
#ifdef DEBUG
#ifdef DEBUGREALLYHARD
kputs("getproc start ... ");
- for (pp = ptab; pp < ptab + maxproc; pp++)
+ for (pp = ptab; pp < ptab_end; pp++)
kprintf("ptab[0x%x]: pid=%d uid=%d status=%d, page=0x%x\n",
pp, pp->p_pid, pp->p_uid, pp->p_status,
pp->p_page);
for (;;) {
getproc_nextp++;
- if (getproc_nextp >= ptab + maxproc) {
+ if (getproc_nextp >= ptab_end) {
getproc_nextp = ptab;
}
udata.u_error = EAGAIN;
irq = di();
- for (p = ptab; p < ptab + maxproc; p++)
+ for (p = ptab; p < ptab_end; p++)
if (p->p_status == P_EMPTY) {
newp = p;
break;
if (nextpid++ > MAXPID)
nextpid = 20;
newp->p_pid = nextpid;
- for (p = ptab; p < ptab + maxproc; p++)
+ for (p = ptab; p < ptab_end; p++)
if (p->p_status != P_EMPTY
&& p->p_pid == nextpid)
newp->p_pid = 0; /* try again */
ticks.full++;
/* Update process alarm clocks and timeouts */
- for (p = ptab; p < ptab + maxproc; ++p) {
+ for (p = ptab; p < ptab_end; ++p) {
if (p->p_alarm) {
p->p_alarm--;
if (!p->p_alarm)
void sgrpsig(uint16_t pgrp, uint16_t sig)
{
ptptr p;
- for (p = ptab; p < ptab + maxproc; ++p) {
+ for (p = ptab; p < ptab_end; ++p) {
if (-p->p_pgrp == pgrp)
ssig(p, sig);
}
2 * sizeof(clock_t));
/* See if we have any children. Set child's parents to our parent */
- for (p = ptab; p < ptab + maxproc; ++p) {
+ for (p = ptab; p < ptab_end; ++p) {
if (p->p_status && p->p_pptr == udata.u_ptab
&& p != udata.u_ptab)
p->p_pptr = udata.u_ptab->p_pptr;
#else
maxproc = PTABSIZE;
#endif
+ /* Used as a stop marker to make compares fast on process
+ scheduling and the like */
+ ptab_end = &ptab[maxproc];
+
/* Parameters message */
kprintf("%dkB total RAM, %dkB available to processes (%d processes max)\n", ramsize, procmem, maxproc);
bufinit();
}
/* See if we have any children. */
- for (p = ptab; p < ptab + maxproc; ++p) {
+ for (p = ptab; p < ptab_end; ++p) {
if (p->p_status && p->p_pptr == udata.u_ptab
&& p != udata.u_ptab)
goto ok;
udata.u_error = EINTR;
return (-1);
}
- for (p = ptab; p < ptab + maxproc; ++p) {
+ for (p = ptab; p < ptab_end; ++p) {
if (p->p_status == P_ZOMBIE
&& p->p_pptr == udata.u_ptab) {
if (pid == -1 || p->p_pid == pid
if (pid == 0)
udata.u_argn = -udata.u_ptab->p_pgrp;
- for (p = ptab; p < ptab + maxproc; ++p) {
+ for (p = ptab; p < ptab_end; ++p) {
/* No overlap here */
if (-p->p_pgrp == pid || p->p_pid == pid) {
f = 1; /* Found */