• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ resched函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中resched函数的典型用法代码示例。如果您正苦于以下问题:C++ resched函数的具体用法?C++ resched怎么用?C++ resched使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了resched函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: releaseall

SYSCALL releaseall(nargs, args){
	unsigned long	*a;		/* points to list of args	*/
	STATWORD ps;    	
	struct pentry *pptr;
	disable(ps);
	//kprintf("\n in release.");
	a = (unsigned long *)(&args) -1; /* last argument	*/
	int arr[*a];
	int i=0;
	
	 for ( ; nargs > 0 ; nargs--)	{/* machine dependent; copy args	*/
		*a++;	/* onto created process' stack	*/
		 //kprintf("\n Lock to release: %d",*(a+i));
		 arr[i] = release(*(a+i));//1 returns then syserr., 
		 i++;
	}
	
	int flag = 0;
	int j=0;
	for(j=0;j<i;j++){
		if(arr[j]!=0)
			flag = 1;

	}
	//kprintf("\nAbout to reschedule");
	if((pptr=&proctab[currpid])->callfromkill==0)
		resched();
	
	restore(ps);
	//kprintf("\n\nall released: %d", flag);
	if(flag==1)
		return(SYSERR);
	return OK;
}
开发者ID:riturajsacademic,项目名称:XinuPA2,代码行数:34,代码来源:releaseall.c


示例2: resched_cntl

/*------------------------------------------------------------------------
 *  resched_cntl  -  Control whether rescheduling is deferred or allowed
 *------------------------------------------------------------------------
 */
status	resched_cntl(		/* Assumes interrupts are disabled	*/
	  int32	defer		/* Either DEFER_START or DEFER_STOP	*/
	)
{
	switch (defer) {

	    case DEFER_START:	/* Handle a deferral request */

		if (Defer.ndefers++ == 0) {
			Defer.attempt = FALSE;
		}
		return OK;

	    case DEFER_STOP:	/* Handle end of deferral */
		if (Defer.ndefers <= 0) {
			return SYSERR;
		}
		if ( (--Defer.ndefers == 0) && Defer.attempt ) {
			resched();
		}
		return OK;

	    default:
		return SYSERR;
	}
}
开发者ID:prashant-r,项目名称:Xinu,代码行数:30,代码来源:resched.c


示例3: chprio

/*------------------------------------------------------------------------
 * chprio  --  change the scheduling priority of a process
 *------------------------------------------------------------------------
 */
SYSCALL
chprio(int pid, unsigned newprio)
{
	STATWORD ps;    
	int	oldprio;
	struct	pentry	*pptr;

	disable(ps);
	if (isbadpid(pid) ||
	    (pptr = &proctab[pid])->pstate == PRFREE) {
		restore(ps);
		return SYSERR;
	}
	oldprio = pptr->pprio;
	pptr->pprio = newprio;
	switch (pptr->pstate) {
	case PRREADY:
		insert( dequeue(pid), rdyhead, newprio);
	case PRCURR:
		resched();
	default:
		break;
	}
	restore(ps);
	return oldprio;
}
开发者ID:beckah,项目名称:Ethernet-ARP-IP-Simulation,代码行数:30,代码来源:chprio.c


示例4: receive

/*------------------------------------------------------------------------
 *  receive  -  wait for a message and return it
 *------------------------------------------------------------------------
 */
SYSCALL	receive()
{
    int start;
    if(activated == 1)
        start = ctr1000;
    STATWORD ps;
    struct	pentry	*pptr;
    WORD	msg;

    disable(ps);
    pptr = &proctab[currpid];
    if ( !pptr->phasmsg ) {		/* if no message, wait for one	*/
        pptr->pstate = PRRECV;
        resched();
    }
    msg = pptr->pmsg;		/* retrieve message		*/
    pptr->phasmsg = FALSE;
    restore(ps);
    if(activated == 1)
    {
        Info[currpid][RECEIVE].freq++;
        Info[currpid][RECEIVE].time += (ctr1000 - start);
    }
    return(msg);
}
开发者ID:michalt25,项目名称:Courses,代码行数:29,代码来源:receive.c


示例5: ready

/*------------------------------------------------------------------------
 *  ready  -  Make a process eligible for CPU service
 *------------------------------------------------------------------------
 */
status	ready(
	  pid32		pid		/* ID of process to make ready	*/
	)
{
	register struct procent *prptr;

	if (isbadpid(pid)) {
		return SYSERR;
	}

	/* Set process state to indicate ready and add to ready list */

	prptr = &proctab[pid];

	record_cpuqdata(pid);  /* call function to record process state time data */
							   /* (actual recording is controlled by EV_CPUQDATA env var and choice of scheduler) */
	prptr->prstate = PR_READY;
	readycount++;  /* increase the readylist count tracker */

	/* assigns a new adjusted priority based on the scheduler currently active */
	prptr->prprio = setprio(pid);

	insert(pid, readylist, prptr->prprio);
	resched();

	return OK;
}
开发者ID:nwilder0,项目名称:bbb-xinu,代码行数:31,代码来源:ready.c


示例6: strtclk

/*------------------------------------------------------------------------
 *  strtclk  --  take the clock out of defer mode
 *------------------------------------------------------------------------
 */
strtclk()
{
	STATWORD ps;    
	int makeup;
	int next;

	disable(ps);
	if ( defclk<=0 || --defclk>0 ) {
		restore(ps);
		return;
	}
	makeup = clkdiff;
	preempt -= makeup;
	clkdiff = 0;
	if ( slnempty ) {
		for (next=firstid(clockq) ; 
		    next < NPROC && q[next].qkey < makeup ;
		    next=q[next].qnext) {
			makeup -= q[next].qkey;
			q[next].qkey = 0;
		}
		if (next < NPROC)
			q[next].qkey -= makeup;
		wakeup();
	}
	if ( preempt <= 0 )
	        resched();
	restore(ps);
}
开发者ID:beckah,项目名称:Ethernet-ARP-IP-Simulation,代码行数:33,代码来源:ssclock.c


示例7: wait

/**
 * @ingroup semaphores
 *
 * Wait on a semaphore.
 *
 * If the semaphore's count is positive, it will be decremented and this
 * function will return immediately.  Otherwise, the currently running thread
 * will be put to sleep until the semaphore is signaled with signal() or
 * signaln(), or freed with semfree().
 *
 * @param sem
 *      Semaphore to wait on.
 *
 * @return
 *      ::OK on success; ::SYSERR on failure.  This function can only fail if @p
 *      sem did not specify a valid semaphore.
 */
syscall wait(semaphore sem)
{
    register struct sement *semptr;
    register struct thrent *thrptr;
    irqmask im;

    im = disable();
    if (isbadsem(sem)) //SDEFER is checked for inside this function in include/semaphore.h
    {
        restore(im);
        return SYSERR;
    }


    thrptr = &thrtab[thrcurrent];
    semptr = &semtab[sem];
    if (--(semptr->count) < 0)
    {
        thrptr->state = THRWAIT;
        thrptr->sem = sem;
        enqueue(thrcurrent, semptr->queue);
        resched();
    }
    restore(im);
    return OK;
}
开发者ID:breppert,项目名称:Xinu-Raspberry-Pi-Cross-Compile,代码行数:43,代码来源:wait.c


示例8: wait

/*------------------------------------------------------------------------
 * wait  --  make current process wait on a semaphore
 *------------------------------------------------------------------------
 */
SYSCALL	wait(int sem)
{
	unsigned long timer_start_value=ctr1000;
	if(start_summary==1)
	{
		
		summary_tab[currpid][26].syscall_name="sys_wait";
		summary_tab[currpid][26].frequency+=1;
	}
	
	STATWORD ps;    
	struct	sentry	*sptr;
	struct	pentry	*pptr;

	disable(ps);
	if (isbadsem(sem) || (sptr= &semaph[sem])->sstate==SFREE) {
		restore(ps);
		summary_tab[currpid][26].time+=ctr1000-timer_start_value;
		return(SYSERR);
	}
	
	if (--(sptr->semcnt) < 0) {
		(pptr = &proctab[currpid])->pstate = PRWAIT;
		pptr->psem = sem;
		enqueue(currpid,sptr->sqtail);
		pptr->pwaitret = OK;
		resched();
		restore(ps);
		summary_tab[currpid][26].time+=ctr1000-timer_start_value;
		return pptr->pwaitret;
	}
	restore(ps);
	summary_tab[currpid][26].time+=ctr1000-timer_start_value;
	return(OK);
}
开发者ID:harsh6292,项目名称:OS_PA0,代码行数:39,代码来源:wait.c


示例9: suspend

/*------------------------------------------------------------------------
 *  suspend  --  suspend a process, placing it in hibernation
 *------------------------------------------------------------------------
 */
SYSCALL	suspend(int pid)
{
	STATWORD ps;    
	struct	pentry	*pptr;		/* pointer to proc. tab. entry	*/
	int	prio;			/* priority returned		*/
	unsigned long stime = ctr1000;

	UPDATE_SCALL_FREQ(currpid, SCALL_SUSPEND);
	disable(ps);
	if (isbadpid(pid) || pid==NULLPROC ||
	 ((pptr= &proctab[pid])->pstate!=PRCURR && pptr->pstate!=PRREADY)) {
		restore(ps);
		UPDATE_SCALL_TIME(currpid, SCALL_SUSPEND, stime);
		return(SYSERR);
	}
	if (pptr->pstate == PRREADY) {
		pptr->pstate = PRSUSP;
		dequeue(pid);
	}
	else {
		pptr->pstate = PRSUSP;
		resched();
	}
	prio = pptr->pprio;
	restore(ps);
	UPDATE_SCALL_TIME(currpid, SCALL_SUSPEND, stime);
	return(prio);
}
开发者ID:acads,项目名称:csc501-xinu-intro,代码行数:32,代码来源:suspend.c


示例10: semdelete

syscall semdelete(sid32 sem)
{
	intmask mask;
	struct semEntry *semptr;

	mask = disable();
	if(isbadsid(sem))
	{
		restore(mask);
		return SYSERR;
	}

	semptr = &semtab[sem];
	if(semptr->sestate == SE_FREE)
	{
		restore(mask);
		return SYSERR;
	}
	semptr->sestate = SE_FREE;

	while(semptr->secount++ < 0)
	{
		ready(getfirst(semptr->sequeue), RESCHED_NO);
	}
	resched();
	restore(mask);
	return OK;
}
开发者ID:shouhutsh,项目名称:myXinu,代码行数:28,代码来源:semaphore.c


示例11: wait

/*------------------------------------------------------------------------
 *  wait  -  Cause current process to wait on a semaphore
 *------------------------------------------------------------------------
 */
syscall	wait(
	  sid32		sem		/* Semaphore on which to wait  */
	)
{
	intmask mask;			/* Saved interrupt mask		*/
	struct	procent *prptr;		/* Ptr to process's table entry	*/
	struct	sentry *semptr;		/* Ptr to sempahore table entry	*/

	mask = disable();
	if (isbadsem(sem)) {
		restore(mask);
		return SYSERR;
	}

	semptr = &semtab[sem];
	if (semptr->sstate == S_FREE) {
		restore(mask);
		return SYSERR;
	}

	if (--(semptr->scount) < 0) {		/* If caller must block	*/
		prptr = &proctab[currpid];
		prptr->prstate = PR_WAIT;	/* Set state to waiting	*/
		prptr->prsem = sem;		/* Record semaphore ID	*/
		enqueue(currpid,semptr->squeue);/* Enqueue on semaphore	*/
		resched();			/*   and reschedule	*/
	}

	restore(mask);
	return OK;
}
开发者ID:pvanevery,项目名称:school,代码行数:35,代码来源:wait.c


示例12: ready

/*------------------------------------------------------------------------
 *  ready  -  Make a process eligible for CPU service
 *------------------------------------------------------------------------
 */
status	ready(
	  pid32		pid,		/* ID of process to make ready	*/
	  bool8		resch		/* reschedule afterward?	*/
	)
{
	register struct procent *prptr;

	int rrChecker = 1 ; 	/* variable to check if round robin should run */
	
	if (isbadpid(pid)) {
		return(SYSERR);
	}

	/* Set process state to indicate ready and add to ready list */
	
	prptr = &proctab[pid];
	prptr->prstate = PR_READY;
	if (rrChecker != 1) {
		insert(pid, readylist, prptr->prprio);
	} else if (rrChecker == ROUND_ROBIN) {
		insert(pid, readylist, prptr->prprio);
	}

	if (resch == RESCHED_YES) {
		resched();
	}
	return OK;
}
开发者ID:alicialim,项目名称:Xinu,代码行数:32,代码来源:ready.c


示例13: sleep

/*------------------------------------------------------------------------
 * sleep  --  delay the calling process n seconds
 *------------------------------------------------------------------------
 */
SYSCALL	sleep(int n)
{
	STATWORD ps;    
	if (n<0 || clkruns==0)
		return(SYSERR);
	if (n == 0) {
	        disable(ps);
		resched();
		restore(ps);
		return(OK);
	}
	while (n >= 1000) {
		sleep10(10000);
		n -= 1000;
	}
	if (n > 0)
		sleep10(10*n);

	if( syscalls_trace ) 
	{
		sleep_freq[currpid]++;
	}

	return(OK);
}
开发者ID:tastynoodle,项目名称:CSC501-OS,代码行数:29,代码来源:sleep.c


示例14: fwait

/*------------------------------------------------------------------------
 *  wait  -  Cause current process to wait on a semaphore
 *------------------------------------------------------------------------
 */
syscall	fwait(
	  future *f		/* future in which to wait  */
	)
{
	intmask mask;			/* Saved interrupt mask		*/
	struct	procent *prptr;		/* Ptr to process' table entry	*/

	mask = disable();

	if(f->state != FUTURE_EMPTY){
		restore(mask);
		return SYSERR;	
	}

	prptr = &proctab[currpid];
	prptr->prstate = PR_WAIT;
	
	f->tid = currpid;
	f->state=FUTURE_WAITING;		

	resched();			/*   and reschedule	*/

	restore(mask);
	return OK;
}
开发者ID:ajinkya-dhamnaskar,项目名称:xinu-os,代码行数:29,代码来源:fwait.c


示例15: wait

/*------------------------------------------------------------------------
 * wait  --  make current process wait on a semaphore
 *------------------------------------------------------------------------
 */
SYSCALL	wait(int sem)
{
	STATWORD ps;    
	struct	sentry	*sptr;
	struct	pentry	*pptr;
	unsigned long stime = ctr1000;

	UPDATE_SCALL_FREQ(currpid, SCALL_WAIT);
	disable(ps);
	if (isbadsem(sem) || (sptr= &semaph[sem])->sstate==SFREE) {
		restore(ps);
		UPDATE_SCALL_TIME(currpid, SCALL_WAIT, stime);
		return(SYSERR);
	}
	
	if (--(sptr->semcnt) < 0) {
		(pptr = &proctab[currpid])->pstate = PRWAIT;
		pptr->psem = sem;
		enqueue(currpid,sptr->sqtail);
		pptr->pwaitret = OK;
		resched();
		restore(ps);
		UPDATE_SCALL_TIME(currpid, SCALL_WAIT, stime);
		return pptr->pwaitret;
	}
	restore(ps);
	UPDATE_SCALL_TIME(currpid, SCALL_WAIT, stime);
	return(OK);
}
开发者ID:acads,项目名称:csc501-xinu-intro,代码行数:33,代码来源:wait.c


示例16: sreset

/*------------------------------------------------------------------------
 *  sreset  --  reset the count and queue of a semaphore
 *------------------------------------------------------------------------
 */
SYSCALL sreset(int sem, int count)
{
        int start;
	if(activated == 1)
		start = ctr1000;
	STATWORD ps;    
	struct	sentry	*sptr;
	int	pid;
	int	slist;

	disable(ps);
	if (isbadsem(sem) || count<0 || semaph[sem].sstate==SFREE) {
		restore(ps);
		return(SYSERR);
	}
	sptr = &semaph[sem];
	slist = sptr->sqhead;
	while ((pid=getfirst(slist)) != EMPTY)
		ready(pid,RESCHNO);
	sptr->semcnt = count;
	resched();
	restore(ps);
	if(activated == 1)
	{
	        Info[currpid][SRESET].freq++;
	        Info[currpid][SRESET].time += (ctr1000 - start);
	}
	return(OK);
}
开发者ID:michalt25,项目名称:Courses,代码行数:33,代码来源:sreset.c


示例17: receiveb

/*------------------------------------------------------------------------
 *  receive  -  wait for a message and return the message to the caller
 *------------------------------------------------------------------------
 */
umsg32	receiveb(void)
{
	intmask	mask;			/* saved interrupt mask		*/
	struct	procent *prptr;		/* ptr to process' table entry	*/
	umsg32	msg;			/* message to return		*/

	mask = disable();
	prptr = &proctab[currpid];
	if (prptr->prhasmsg == FALSE) {
		
		if(!isempty(prptr->msgqueue))
		{
			pid32 senderpid = dequeue(prptr->msgqueue);
			struct procent *sender = &proctab[senderpid];

			msg = sender->sndmsg;
			sender->sndflag = FALSE;
			ready(senderpid, RESCHED_YES);
		}
		else
		{
			prptr->prstate = PR_RECV;
			resched();		/* block until message arrives	*/
		}
	}
	msg = prptr->prmsg;		/* retrieve message		*/
	prptr->prhasmsg = FALSE;	/* reset message flag		*/
	restore(mask);
	return msg;
}
开发者ID:mihirjham,项目名称:PurdueCS,代码行数:34,代码来源:receiveb.c


示例18: ready

/*------------------------------------------------------------------------
 *  ready  -  Make a process eligible for CPU service
 *------------------------------------------------------------------------
 */
status	ready(
	  pid32		pid,		/* ID of process to make ready	*/
	  bool8		resch		/* reschedule afterward?	*/
	)
{
	register struct procent *prptr;

	if (isbadpid(pid)) {
		return(SYSERR);
	}

	/* Set process state to indicate ready and add to ready list */

	prptr = &proctab[pid];
	prptr->prstate = PR_READY;

	if (ROUND_ROBIN == 1)
	{
		enqueue(pid, readylist);
	}
	else
	{
		insert(pid, readylist, prptr->prprio);
	}

	if (resch == RESCHED_YES) {
		resched();
	}
	return OK;
}
开发者ID:BridgeNY,项目名称:purdue,代码行数:34,代码来源:ready.c


示例19: sleep10

/*------------------------------------------------------------------------
 * 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);
}
开发者ID:michalt25,项目名称:Courses,代码行数:30,代码来源:sleep10.c


示例20: wait

SYSCALL	wait(int sem)
{	
	if(trace) wait_count[currpid]++;
	STATWORD ps;    
	struct	sentry	*sptr;
	struct	pentry	*pptr;

	disable(ps);
	if (isbadsem(sem) || (sptr= &semaph[sem])->sstate==SFREE) {
		restore(ps);
		return(SYSERR);
	}
	
	if (--(sptr->semcnt) < 0) {
		(pptr = &proctab[currpid])->pstate = PRWAIT;
		pptr->psem = sem;
		enqueue(currpid,sptr->sqtail);
		pptr->pwaitret = OK;
		resched();
		restore(ps);
		return pptr->pwaitret;
	}
	restore(ps);
	
	return(OK);
}
开发者ID:KeleiAzz,项目名称:CSC501,代码行数:26,代码来源:wait.c



注:本文中的resched函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ reschedule函数代码示例发布时间:2022-05-30
下一篇:
C++ resample函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap