Exemple #1
0
void	nulluser(void)
{
	kprintf("\n\r%s\n\n\r", VERSION);

	sysinit();

	/* Output Xinu memory layout */

	kprintf("%10d bytes physical memory.\r\n",
		(uint32)maxheap - (uint32)addressp2k(0));
	kprintf("           [0x%08X to 0x%08X]\r\n",
		(uint32)addressp2k(0), (uint32)maxheap - 1);
	kprintf("%10d bytes reserved system area.\r\n",
		(uint32)_start - (uint32)addressp2k(0));
	kprintf("           [0x%08X to 0x%08X]\r\n",
		(uint32)addressp2k(0), (uint32)_start - 1);
	kprintf("%10d bytes Xinu code.\r\n",
		(uint32)&_end - (uint32)_start);
	kprintf("           [0x%08X to 0x%08X]\r\n",
		(uint32)_start, (uint32)&_end - 1);
	kprintf("%10d bytes stack space.\r\n",
		(uint32)minheap - (uint32)&_end);
	kprintf("           [0x%08X to 0x%08X]\r\n",
		(uint32)&_end, (uint32)minheap - 1);
	kprintf("%10d bytes heap space.\r\n",
		(uint32)maxheap - (uint32)minheap);
	kprintf("           [0x%08X to 0x%08X]\r\n\r\n",
		(uint32)minheap, (uint32)maxheap - 1);

	/* Enable interrupts */

	enable();

	/* Create a process to execute function main() */

	resume(create
          ((void *)main, INITSTK, INITPRIO, "Main process", 0, NULL));

	/* Become the Null process (i.e., guarantee that the CPU has	*/
	/*  something to run when no other process is ready to execute)	*/
	
	
	/*CS 354 Spring 2012*/
	/*Lab 2: Round Robin Scheduling*/
	/*Created by : Wilson Sumanang
	  Date       : 12 February 2012*/
	
	while (TRUE) {
		
		kprintf("N");		/* do nothing */
	}
}
static	void	sysinit(void)
{
	int32	i;
	struct	procent	*prptr;		/* ptr to process table entry	*/
	struct	sentry	*semptr;	/* prr to semaphore table entry	*/
	struct	memblk	*memptr;	/* ptr to memory block		*/

	/* Initialize system variables */

	/* Count the Null process as the first process in the system */

	prcount = 1;

	/* Scheduling is not currently blocked */

	Defer.ndefers = 0;

	/* Initialize the free memory list */

	maxheap = (void *)addressp2k(MAXADDR);

	memlist.mnext = (struct memblk *)minheap;

	/* Overlay memblk structure on free memory and set fields */

	memptr = (struct memblk *)minheap;
	memptr->mnext = NULL;
	memptr->mlength = memlist.mlength = (uint32)(maxheap - minheap);

	/* Initialize process table entries free */

	for (i = 0; i < NPROC; i++) {
		prptr = &proctab[i];
		prptr->prstate = PR_FREE;
		prptr->prname[0] = NULLCH;
		prptr->prstkbase = NULL;
		prptr->prprio = 0;
	}

	/* Initialize the Null process entry */

	prptr = &proctab[NULLPROC];
	prptr->prstate = PR_CURR;
	prptr->prprio = 0;
	strncpy(prptr->prname, "prnull", 7);
	prptr->prstkbase = minheap;
	prptr->prstklen = NULLSTK;
	prptr->prstkptr = 0;
	currpid = NULLPROC;

	/* Initialize semaphores */

	for (i = 0; i < NSEM; i++) {
		semptr = &semtab[i];
		semptr->sstate = S_FREE;
		semptr->scount = 0;
		semptr->squeue = newqueue();
	}

	/* Initialize buffer pools */

	bufinit();

	/* Create a ready list for processes */

	readylist = newqueue();

	/* Initialize real time clock */

	clkinit();

	/* Initialize non-volative RAM storage */
#if 0
	nvramInit();
#endif

	/* Initialize devices */

	for (i = 0; i < NDEVS; i++) {
		init(i);
	}
	return;
}
Exemple #3
0
static	void	sysinit(void)
{
	int32	i;
	struct	procent	*prptr;		/* ptr to process table entry	*/
	struct	dentry	*devptr;	/* ptr to device table entry	*/
	struct	sentry	*semptr;	/* prr to semaphore table entry	*/
	struct	memblk	*memptr;	/* ptr to memory block		*/

	/* Initialize system variables */

	/* Count the Null process as the first process in the system */

	prcount = 1;

	/* Scheduling is not currently blocked */

	Defer.ndefers = 0;

	/* Initialize the free memory list */

	maxheap = (void *)addressp2k(MAXADDR);

	memlist.mnext = (struct memblk *)minheap;

	/* Overlay memblk structure on free memory and set fields */

	memptr = (struct memblk *)minheap;
	memptr->mnext = NULL;
	memptr->mlength = memlist.mlength = (uint32)(maxheap - minheap);

	/* Initialize process table entries free */

	for (i = 0; i < NPROC; i++) {
		prptr = &proctab[i];
		prptr->prstate = PR_FREE;
		prptr->prname[0] = NULLCH;
		prptr->prstkbase = NULL;
		prptr->prprio = 0;
	}

	/* Initialize the Null process entry */

	prptr = &proctab[NULLPROC];
	prptr->prstate = PR_CURR;
	prptr->prprio = 0;
	strncpy(prptr->prname, "prnull", 7);
	prptr->prstkbase = minheap;
	prptr->prstklen = NULLSTK;
	prptr->prstkptr = 0;
	currpid = NULLPROC;

	/* Initialize semaphores */

	for (i = 0; i < NSEM; i++) {
		semptr = &semtab[i];
		semptr->sstate = S_FREE;
		semptr->scount = 0;
		semptr->squeue = newqueue();
	}

	/* Initialize buffer pools */

	bufinit();

	/* Create a ready list for processes */

	readylist = newqueue();

	/* Initialize real time clock */

	clkinit();

	/* Initialize non-volative RAM storage */

	nvramInit();

	for (i = 0; i < NDEVS; i++) {
		if (! isbaddev(i)) {
			devptr = (struct dentry *) &devtab[i];
			(devptr->dvinit) (devptr);
		}
	}
	/**
	 * Initialize the last two entries in lflcblk used for
	 * directory manipulation.
	 */
	struct dentry dircblk;
	dircblk.dvminor = Nlfl;
	lflInit(&dircblk);
	dircblk.dvminor = Nlfl+1;
	lflInit(&dircblk);
	lfDirCblkMutex = semcreate(1);

	open(ETHER0,NULL, NULL);

	/* Create a process to handle network packets */
	resume((create(netin, 8192, 500, "netin", 0)) );

	return;
}
Exemple #4
0
static	void	sysinit(void)
{
	int32	i;
	struct  pipentry *pipptr;       /* ptr to pipe tabe entry       */  
	struct	procent	*prptr;		/* ptr to process table entry	*/
	struct	dentry	*devptr;	/* ptr to device table entry	*/
	struct	sentry	*semptr;	/* prr to semaphore table entry	*/
	struct	memblk	*memptr;	/* ptr to memory block		*/

	/* Initialize system variables */

	/* Count the Null process as the first process in the system */

	prcount = 1;

	/* Scheduling is not currently blocked */

	Defer.ndefers = 0;

	/* Initialize the free memory list */

	maxheap = (void *)addressp2k(MAXADDR);

	memlist.mnext = (struct memblk *)minheap;

	/* Overlay memblk structure on free memory and set fields */

	memptr = (struct memblk *)minheap;
	memptr->mnext = NULL;
	memptr->mlength = memlist.mlength = (uint32)(maxheap - minheap);

	/* Initialize pipe table entries free */

	for (i = 0; i < NPIPE; i++) {
		pipptr = &piptab[i];
		pipptr->pipstate = PR_FREE;
		pipptr->owner = NPROC + 1;
		pipptr->rdend = NPROC + 1;
		pipptr->wrtend = NPROC + 1;
		pipptr->nextpos = -1;
		pipptr->buffer[0] = NULL;
	}

	/* Initialize process table entries free */

	for (i = 0; i < NPROC; i++) {
		prptr = &proctab[i];
		prptr->prstate = PR_FREE;
		prptr->prname[0] = NULLCH;
		prptr->prstkbase = NULL;
		prptr->prprio = 0;
	}

	/* Initialize the Null process entry */

	prptr = &proctab[NULLPROC];
	prptr->prstate = PR_CURR;
	prptr->prprio = 0;
	strncpy(prptr->prname, "prnull", 7);
	prptr->prstkbase = minheap;
	prptr->prstklen = NULLSTK;
	prptr->prstkptr = 0;
	currpid = NULLPROC;

	/* Initialize semaphores */

	for (i = 0; i < NSEM; i++) {
		semptr = &semtab[i];
		semptr->sstate = S_FREE;
		semptr->scount = 0;
		semptr->squeue = newqueue();
	}

	/* Initialize buffer pools */

	bufinit();

	/* Create a ready list for processes */

	readylist = newqueue();

	/* Initialize real time clock */

	clkinit();

	for (i = 0; i < NDEVS; i++) {
		if (! isbaddev(i)) {
			devptr = (struct dentry *) &devtab[i];
			(devptr->dvinit) (devptr);
		}
	}
	return;
}