/*------------------------------------------------------------------------ * * sysinit - Initialize all Xinu data structures and devices * *------------------------------------------------------------------------ */ static void sysinit() { int32 i; struct procent *prptr; /* Ptr to process table entry */ struct sentry *semptr; /* Ptr to semaphore table entry */ /* Platform Specific Initialization */ platinit(); /* kprintf("\033[39;49m\n\r%s\n\n\r", VERSION);*/ /* Initialize the interrupt vectors */ initevec(); /* Initialize free memory list */ meminit(); /* 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 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 = getstk(NULLSTK); 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 the real time clock */ clkinit(); for (i = 0; i < NDEVS; i++) { init(i); } return; }
/*------------------------------------------------------------------------ * * sysinit - Initialize all Xinu data structures and devices * *------------------------------------------------------------------------ */ static void sysinit() { int32 i; struct procent *prptr; /* Ptr to process table entry */ struct sentry *semptr; /* Ptr to semaphore table entry */ /* Platform Specific Initialization */ platinit(); /* Initialize the interrupt vectors */ initevec(); /* Initialize free memory list */ meminit(); /* 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 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; prptr->prcpu_wait_ratio = 0; // Initializing waits at creation for each process to 0 } /* Initialize the Null process entry */ prptr = &proctab[NULLPROC]; prptr->prstate = PR_CURR; /* Setting the null process initial priority as the highest so that all other processes can run before it*/ prptr->initprio = MAXKEY; prptr->prcpumsec = 0; prptr->prctxswintime = 0; /* Reversing the priority order in case of Dynamic Process Scheduling (Q4 and Q5.) */ if (LAB2COND) { prptr->prprio = MAXKEY;// prptr->initprio + prptr->prcpumsec; //Highest int16 value. The Null process must take the lowest priority. } else { prptr->prprio = MINPRIO; } strncpy(prptr->prname, "prnull", 7); prptr->prstkbase = getstk(NULLSTK); 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_mltfbq(); init_recieverq(); /* Initialize the real time clock */ clkinit(); for (i = 0; i < NDEVS; i++) { init(i); } return; }