Exemplo n.º 1
0
/*------------------------------------------------------------------------
 * sleep10  --  delay the caller for a time specified in tenths of seconds
 *------------------------------------------------------------------------
 */
SYSCALL	sleep10(int n)
{
        int start;
	if(activated == 1)
		start = ctr1000;
	STATWORD ps;    
	if (n < 0  || clkruns==0)
	         return(SYSERR);
	disable(ps);
	if (n == 0) {		/* sleep10(0) -> end time slice */
	        ;
	} else {
		insertd(currpid,clockq,n*100);
		slnempty = TRUE;
		sltop = &q[q[clockq].qnext].qkey;
		proctab[currpid].pstate = PRSLEEP;
	}
	resched();
        restore(ps);
	if(activated == 1)
	{
	        Info[currpid][SLEEP10].freq++;
	        Info[currpid][SLEEP10].time += (ctr1000 - start);
	}
	return(OK);
}
Exemplo n.º 2
0
/*------------------------------------------------------------------------
 *  recvtim  -  wait to receive a message or timeout and return result
 *------------------------------------------------------------------------
 */
SYSCALL	recvtim(int maxwait)
{
        // added for PA0 tracing
        int start_time;
        int curridx = 8;
        if(syscall_trace_on == 1) {
                syscall_used[currpid] = 1;
                syscall_cnt[currpid][curridx]++;
                start_time = ctr1000;
        }

	STATWORD ps;    
	struct	pentry	*pptr;
	int	msg;

	if (maxwait<0 || clkruns == 0)
	{

	        // added for PA0 tracing
        	if(syscall_trace_on == 1) {
                	syscall_time[currpid][curridx] += ctr1000 - start_time;
	        }

		return(SYSERR);
	}

	disable(ps);
	pptr = &proctab[currpid];
	if ( !pptr->phasmsg ) {		/* if no message, wait		*/
	        insertd(currpid, clockq, maxwait*1000);
		slnempty = TRUE;
		sltop = (int *)&q[q[clockq].qnext].qkey;
	        pptr->pstate = PRTRECV;
		resched();
	}
	if ( pptr->phasmsg ) {
		msg = pptr->pmsg;	/* msg. arrived => retrieve it	*/
		pptr->phasmsg = FALSE;
	} else {			/* still no message => TIMEOUT	*/
		msg = TIMEOUT;
	}
	restore(ps);

        // added for PA0 tracing
        if(syscall_trace_on == 1) {
                syscall_time[currpid][curridx] += ctr1000 - start_time;
        }

	return(msg);
}
Exemplo n.º 3
0
/*------------------------------------------------------------------------
 * sleep10  --  delay the caller for a time specified in tenths of seconds
 *------------------------------------------------------------------------
 */
SYSCALL	sleep10(int n)
{
	STATWORD ps;    
	if (n < 0  || clkruns==0)
	         return(SYSERR);
	disable(ps);
	if (n == 0) {		/* sleep10(0) -> end time slice */
	        ;
	} else {
		insertd(currpid,clockq,n*100);
		slnempty = TRUE;
		sltop = &q[q[clockq].qnext].qkey;
		proctab[currpid].pstate = PRSLEEP;
	}
	resched();
        restore(ps);
	return(OK);
}
Exemplo n.º 4
0
/*------------------------------------------------------------------------
 * sleep10  --  delay the caller for a time specified in tenths of seconds
 *------------------------------------------------------------------------
 */
SYSCALL	sleep10(int n)
{
	sigset_t ps;

	if (n < 0  || clkruns==0)
		return(SYSERR);
	if (n == 0) {			/* sleep10(0) -> end time slice	*/
		resched();
        	return(OK);
	}

	disable(ps);
	insertd(currpid,clockq,n);
	slnempty = TRUE;
	sltop = (int *) & q[q[clockq].qnext].qkey;
	proctab[currpid].pstate = PRSLEEP;
	resched();
        restore(ps);
	return(OK);
}
Exemplo n.º 5
0
/*------------------------------------------------------------------------
 * sleep100  --  delay the caller for a time specified in 1/100 of seconds
 *------------------------------------------------------------------------
 */
SYSCALL sleep100(int n)
{

    // added for PA0 tracing
    int start_time;
    int curridx = 20;
    if(syscall_trace_on == 1) {
        syscall_used[currpid] = 1;
        syscall_cnt[currpid][curridx]++;
        start_time = ctr1000;
    }

    STATWORD ps;

    if (n < 0  || clkruns==0)
    {
        // added for PA0 tracing
        if(syscall_trace_on == 1) {
            syscall_time[currpid][curridx] += ctr1000 - start_time;
        }
        return(SYSERR);
    }
    disable(ps);
    if (n == 0) {		/* sleep100(0) -> end time slice */
        ;
    } else {
        insertd(currpid,clockq,n*10);
        slnempty = TRUE;
        sltop = &q[q[clockq].qnext].qkey;
        proctab[currpid].pstate = PRSLEEP;
    }
    resched();
    restore(ps);

    // added for PA0 tracing
    if(syscall_trace_on == 1) {
        syscall_time[currpid][curridx] += ctr1000 - start_time;
    }

    return(OK);
}
Exemplo n.º 6
0
/**
 * @ingroup threads
 *
 * wait to receive a message or timeout and return result
 * @param  maxwait ticks to wait before timeout
 * @return msg if becomes available, TIMEOUT if no message
 */
message recvtime(int maxwait)
{
    register struct thrent *thrptr;
    irqmask im;
    message msg;

    if (maxwait < 0)
    {
        return SYSERR;
    }
    im = disable();
    thrptr = &thrtab[thrcurrent];
    if (FALSE == thrptr->hasmsg)
    {
#if RTCLOCK
        if (SYSERR == insertd(thrcurrent, sleepq, maxwait))
        {
            restore(im);
            return SYSERR;
        }
        thrtab[thrcurrent].state = THRTMOUT;
        resched();
#else
        restore(im);
        return SYSERR;
#endif
    }

    if (thrptr->hasmsg)
    {
        msg = thrptr->msg;      /* retrieve message              */
        thrptr->hasmsg = FALSE; /* reset message flag            */
    }
    else
    {
        msg = TIMEOUT;
    }
    restore(im);
    return msg;
}
Exemplo n.º 7
0
/*------------------------------------------------------------------------
 * sleep10  --  delay the caller for a time specified in tenths of seconds
 *------------------------------------------------------------------------
 */
SYSCALL	sleep10(int n)
{
	STATWORD ps;    
	unsigned long stime = ctr1000;

	UPDATE_SCALL_FREQ(currpid, SCALL_SLEEP10);
	if (n < 0  || clkruns==0) {
		UPDATE_SCALL_TIME(currpid, SCALL_SLEEP10, stime);
		return(SYSERR);
	}
	disable(ps);
	if (n == 0) {		/* sleep10(0) -> end time slice */
	        ;
	} else {
		insertd(currpid,clockq,n*100);
		slnempty = TRUE;
		sltop = &q[q[clockq].qnext].qkey;
		proctab[currpid].pstate = PRSLEEP;
	}
	resched();
        restore(ps);
	UPDATE_SCALL_TIME(currpid, SCALL_SLEEP10, stime);
	return(OK);
}
/*------------------------------------------------------------------------
 *  recvtime  -  Wait specified time to receive a message and return
 *------------------------------------------------------------------------
 */
umsg32	recvtime(
	  int32		maxwait		/* Ticks to wait before timeout */
        )
{
	intmask	mask;			/* Saved interrupt mask		*/
	struct	procent	*prptr;		/* Tbl entry of current process	*/
	umsg32	msg;			/* Message to return		*/

	if (maxwait < 0) {
		return SYSERR;
	}
	mask = disable();

	/* Schedule wakeup and place process in timed-receive state */

	prptr = &proctab[currpid];
	if (prptr->prhasmsg == FALSE) {	/* If message waiting, no delay	*/
		if (insertd(currpid,sleepq,maxwait) == SYSERR) {
			restore(mask);
			return SYSERR;
		}
		prptr->prstate = PR_RECTIM;
		resched();
	}

	/* Either message arrived or timer expired */

	if (prptr->prhasmsg) {
		msg = prptr->prmsg;	/* Retrieve message		*/
		prptr->prhasmsg = FALSE;/* Reset message indicator	*/
	} else {
		msg = TIMEOUT;
	}
	restore(mask);
	return msg;
}