Exemple #1
0
/*
 *	Called from switchin when we discover that we want to run
 *	a swapped process. As all our processes are the same size
 *	for now this remains fairly simple.
 */
void swapper(ptptr p)
{
	pagemap_alloc(p);	/* May cause a swapout */
#ifdef DEBUG
	kprintf("Swapping in %x (page %d), utab.ptab %x\n", p, p->p_page,
		udata.u_ptab);
#endif
	swapin(p);
#ifdef DEBUG
	kprintf("Swapped in %x (page %d), udata.ptab %x\n",
		p, p->p_page, udata.u_ptab);
#endif
}
Exemple #2
0
ptptr ptab_alloc(void)
{
	ptptr p, newp;
	irqflags_t irq;

	newp = NULL;
	udata.u_error = EAGAIN;

	irq = di();
	for (p = ptab; p < ptab_end; p++)
		if (p->p_status == P_EMPTY) {
			newp = p;
			break;
		}

	if (newp) {		/* found a slot? */
		/* zero process structure */
		memset(newp, 0, sizeof(struct p_tab));

		/* select a unique pid */
		while (newp->p_pid == 0) {
			if (nextpid++ > MAXPID)
				nextpid = 20;
			newp->p_pid = nextpid;

			for (p = ptab; p < ptab_end; p++)
				if (p->p_status != P_EMPTY
				    && p->p_pid == nextpid) {
					newp->p_pid = 0;	/* try again */
					break;
				}
		}
		newp->p_top = udata.u_top;
		if (pagemap_alloc(newp) == 0) {
			newp->p_status = P_FORKING;
			nproc++;
		} else {
			udata.u_error = ENOMEM;
			newp = NULL;
                }
                newp->p_pgrp = udata.u_ptab->p_pgrp;
                memcpy(newp->p_name, udata.u_ptab->p_name, sizeof(newp->p_name));
	}
	irqrestore(irq);
	if (newp)
		udata.u_error = 0;
	return newp;
}
Exemple #3
0
/*
 *	Called from switchin when we discover that we want to run
 *	a swapped process. We let pagemap_alloc cause any needed swap
 *	out of idle processes.
 */
void swapper(ptptr p)
{
    uint16_t map = p->p_page2;
    pagemap_alloc(p);	/* May cause a swapout. May also destroy
                                   the old value of p->page2 */
#ifdef DEBUG
    kprintf("Swapping in %x (page %d), utab.ptab %x\n", p, p->p_page,
            udata.u_ptab);
#endif
    swapin(p, map);
    swapmap_add(map);
#ifdef DEBUG
    kprintf("Swapped in %x (page %d), udata.ptab %x\n",
            p, p->p_page, udata.u_ptab);
#endif
}