コード例 #1
0
ファイル: mtdispatch.C プロジェクト: Keloran/okws
void
mtd_stats_t::report ()
{
  if (ok_amt_stat_freq == 0 ||
      !tsdiff (start_sample, sfs_get_tsnow(), ok_amt_stat_freq))
    return;
  epoch_t e = new_epoch ();
  warn ("STATS: i=%d;o=%d;r=%d;q=%d;a=%d;t=%d;l=%d\n",
	e.in, e.out, e.rejects, e.queued, e.async_serv, e.to, e.len_msec);
}
コード例 #2
0
ファイル: resched.c プロジェクト: michalt25/Courses
/*-----------------------------------------------------------------------
 * resched  --  reschedule processor to highest priority ready process
 *
 * Notes:	Upon entry, currpid gives current process id.
 *		Proctab[currpid].pstate gives correct NEXT state for
 *			current process if other than PRREADY.
 *------------------------------------------------------------------------
 */
int resched()
{
	register struct	pentry	*optr;	/* pointer to old process entry */
	register struct	pentry	*nptr;	/* pointer to new process entry */
	int rand_num,temp_currpid,i;
	/* no switch needed if current process priority higher than next*/

        if(used_scheduler == RANDOMSCHED)
        {
		optr= &proctab[currpid];
	}
        else if(used_scheduler == LINUXSCHED)
        {
		optr= &proctab[currpid];
	}
	else
	{

		if ( ( (optr= &proctab[currpid])->pstate == PRCURR) &&
	   (lastkey(rdytail)<optr->pprio)) 
		{
			return(OK);
		}
	}
	
	/* force context switch */

	if (optr->pstate == PRCURR) 
	{
		optr->pstate = PRREADY;
		optr->arrival_time = ctr1000;
		if(preempt >= 0)
			optr->quantum_left = preempt;
		insert(currpid,rdyhead,optr->pprio);
	}

	/* remove highest priority process at end of ready list */
	if(used_scheduler != LINUXSCHED)
        {
		execution_time[currpid]+=(QUANTUM-preempt);
	}
	else
		execution_time[currpid]+= (proctab[currpid].quantum_left -preempt);
	//kprintf("\nPreempt: %d",preempt);
	

        if(used_scheduler == RANDOMSCHED)
        {
		if(q[rdyhead].qnext == rdytail)
			return(OK);
		do
		{
			rand_num = rand()%100;
		//	kprintf("Random Number: %d",rand_num);
			if(rand_num >=80)
				 temp_currpid = random_getpid(1);
			else if(rand_num <80 && rand_num >=50)
                                 temp_currpid = random_getpid(2);			
			else	
                                 temp_currpid = random_getpid(3);

		}while(temp_currpid == -1);
		currpid = temp_currpid;
		nptr = &proctab[currpid];
		dequeue(currpid);
		//kprintf("\n Current PID : %d",currpid);
	
        }
	else if(used_scheduler == LINUXSCHED)
        {
		temp_currpid = linux_getpid();
		if(temp_currpid == -1)
		{
			 new_epoch();
                         temp_currpid = linux_getpid();
			 if(temp_currpid == -1)
        		 {
				temp_currpid=0;;
			 }	
			
		}
                currpid = temp_currpid;
                nptr = &proctab[currpid];
                dequeue(currpid);		
	}
	else
	{
		nptr = &proctab[ (currpid = getlast(rdytail)) ];
	}
	nptr->pstate = PRCURR;		/* mark it currently running	*/
#ifdef	RTCLOCK
	if(used_scheduler != LINUXSCHED)
		preempt = QUANTUM;		/* reset preemption counter	*/
	else
	{		preempt = proctab[currpid].quantum_left;
	}
#endif
	
	ctxsw((int)&optr->pesp, (int)optr->pirmask, (int)&nptr->pesp, (int)nptr->pirmask);
	
	/* The OLD process returns here when resumed. */
	return OK;
}