kern_synch.c revision 12662
1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_synch.c 8.6 (Berkeley) 1/21/94 39 * $Id: kern_synch.c,v 1.15 1995/12/02 18:58:40 bde Exp $ 40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/proc.h> 45#include <sys/kernel.h> 46#include <sys/buf.h> 47#include <sys/signalvar.h> 48#include <sys/resourcevar.h> 49#include <sys/signalvar.h> 50#include <sys/vmmeter.h> 51#include <vm/vm.h> 52#include <vm/vm_param.h> 53#include <vm/vm_extern.h> 54#ifdef KTRACE 55#include <sys/ktrace.h> 56#endif 57 58#include <machine/cpu.h> 59 60static void rqinit __P((void *)); 61SYSINIT(runqueue, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, rqinit, NULL) 62 63u_char curpriority; /* usrpri of curproc */ 64int lbolt; /* once a second sleep address */ 65 66extern void endtsleep __P((void *)); 67extern void updatepri __P((struct proc *p)); 68 69/* 70 * Force switch among equal priority processes every 100ms. 71 */ 72/* ARGSUSED */ 73void 74roundrobin(arg) 75 void *arg; 76{ 77 78 need_resched(); 79 timeout(roundrobin, NULL, hz / 10); 80} 81 82/* 83 * Constants for digital decay and forget: 84 * 90% of (p_estcpu) usage in 5 * loadav time 85 * 95% of (p_pctcpu) usage in 60 seconds (load insensitive) 86 * Note that, as ps(1) mentions, this can let percentages 87 * total over 100% (I've seen 137.9% for 3 processes). 88 * 89 * Note that hardclock updates p_estcpu and p_cpticks independently. 90 * 91 * We wish to decay away 90% of p_estcpu in (5 * loadavg) seconds. 92 * That is, the system wants to compute a value of decay such 93 * that the following for loop: 94 * for (i = 0; i < (5 * loadavg); i++) 95 * p_estcpu *= decay; 96 * will compute 97 * p_estcpu *= 0.1; 98 * for all values of loadavg: 99 * 100 * Mathematically this loop can be expressed by saying: 101 * decay ** (5 * loadavg) ~= .1 102 * 103 * The system computes decay as: 104 * decay = (2 * loadavg) / (2 * loadavg + 1) 105 * 106 * We wish to prove that the system's computation of decay 107 * will always fulfill the equation: 108 * decay ** (5 * loadavg) ~= .1 109 * 110 * If we compute b as: 111 * b = 2 * loadavg 112 * then 113 * decay = b / (b + 1) 114 * 115 * We now need to prove two things: 116 * 1) Given factor ** (5 * loadavg) ~= .1, prove factor == b/(b+1) 117 * 2) Given b/(b+1) ** power ~= .1, prove power == (5 * loadavg) 118 * 119 * Facts: 120 * For x close to zero, exp(x) =~ 1 + x, since 121 * exp(x) = 0! + x**1/1! + x**2/2! + ... . 122 * therefore exp(-1/b) =~ 1 - (1/b) = (b-1)/b. 123 * For x close to zero, ln(1+x) =~ x, since 124 * ln(1+x) = x - x**2/2 + x**3/3 - ... -1 < x < 1 125 * therefore ln(b/(b+1)) = ln(1 - 1/(b+1)) =~ -1/(b+1). 126 * ln(.1) =~ -2.30 127 * 128 * Proof of (1): 129 * Solve (factor)**(power) =~ .1 given power (5*loadav): 130 * solving for factor, 131 * ln(factor) =~ (-2.30/5*loadav), or 132 * factor =~ exp(-1/((5/2.30)*loadav)) =~ exp(-1/(2*loadav)) = 133 * exp(-1/b) =~ (b-1)/b =~ b/(b+1). QED 134 * 135 * Proof of (2): 136 * Solve (factor)**(power) =~ .1 given factor == (b/(b+1)): 137 * solving for power, 138 * power*ln(b/(b+1)) =~ -2.30, or 139 * power =~ 2.3 * (b + 1) = 4.6*loadav + 2.3 =~ 5*loadav. QED 140 * 141 * Actual power values for the implemented algorithm are as follows: 142 * loadav: 1 2 3 4 143 * power: 5.68 10.32 14.94 19.55 144 */ 145 146/* calculations for digital decay to forget 90% of usage in 5*loadav sec */ 147#define loadfactor(loadav) (2 * (loadav)) 148#define decay_cpu(loadfac, cpu) (((loadfac) * (cpu)) / ((loadfac) + FSCALE)) 149 150/* decay 95% of `p_pctcpu' in 60 seconds; see CCPU_SHIFT before changing */ 151fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ 152 153/* 154 * If `ccpu' is not equal to `exp(-1/20)' and you still want to use the 155 * faster/more-accurate formula, you'll have to estimate CCPU_SHIFT below 156 * and possibly adjust FSHIFT in "param.h" so that (FSHIFT >= CCPU_SHIFT). 157 * 158 * To estimate CCPU_SHIFT for exp(-1/20), the following formula was used: 159 * 1 - exp(-1/20) ~= 0.0487 ~= 0.0488 == 1 (fixed pt, *11* bits). 160 * 161 * If you dont want to bother with the faster/more-accurate formula, you 162 * can set CCPU_SHIFT to (FSHIFT + 1) which will use a slower/less-accurate 163 * (more general) method of calculating the %age of CPU used by a process. 164 */ 165#define CCPU_SHIFT 11 166 167/* 168 * Recompute process priorities, every hz ticks. 169 */ 170/* ARGSUSED */ 171void 172schedcpu(arg) 173 void *arg; 174{ 175 register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]); 176 register struct proc *p; 177 register int s; 178 register unsigned int newcpu; 179 180 wakeup((caddr_t)&lbolt); 181 for (p = (struct proc *)allproc; p != NULL; p = p->p_next) { 182 /* 183 * Increment time in/out of memory and sleep time 184 * (if sleeping). We ignore overflow; with 16-bit int's 185 * (remember them?) overflow takes 45 days. 186 */ 187 p->p_swtime++; 188 if (p->p_stat == SSLEEP || p->p_stat == SSTOP) 189 p->p_slptime++; 190 p->p_pctcpu = (p->p_pctcpu * ccpu) >> FSHIFT; 191 /* 192 * If the process has slept the entire second, 193 * stop recalculating its priority until it wakes up. 194 */ 195 if (p->p_slptime > 1) 196 continue; 197 s = splstatclock(); /* prevent state changes */ 198 /* 199 * p_pctcpu is only for ps. 200 */ 201#if (FSHIFT >= CCPU_SHIFT) 202 p->p_pctcpu += (hz == 100)? 203 ((fixpt_t) p->p_cpticks) << (FSHIFT - CCPU_SHIFT): 204 100 * (((fixpt_t) p->p_cpticks) 205 << (FSHIFT - CCPU_SHIFT)) / hz; 206#else 207 p->p_pctcpu += ((FSCALE - ccpu) * 208 (p->p_cpticks * FSCALE / hz)) >> FSHIFT; 209#endif 210 p->p_cpticks = 0; 211 newcpu = (u_int) decay_cpu(loadfac, p->p_estcpu) + p->p_nice; 212 p->p_estcpu = min(newcpu, UCHAR_MAX); 213 resetpriority(p); 214 if (p->p_priority >= PUSER) { 215#define PPQ (128 / NQS) /* priorities per queue */ 216 if ((p != curproc) && 217 p->p_stat == SRUN && 218 (p->p_flag & P_INMEM) && 219 (p->p_priority / PPQ) != (p->p_usrpri / PPQ)) { 220 remrq(p); 221 p->p_priority = p->p_usrpri; 222 setrunqueue(p); 223 } else 224 p->p_priority = p->p_usrpri; 225 } 226 splx(s); 227 } 228 vmmeter(); 229 timeout(schedcpu, (void *)0, hz); 230} 231 232/* 233 * Recalculate the priority of a process after it has slept for a while. 234 * For all load averages >= 1 and max p_estcpu of 255, sleeping for at 235 * least six times the loadfactor will decay p_estcpu to zero. 236 */ 237void 238updatepri(p) 239 register struct proc *p; 240{ 241 register unsigned int newcpu = p->p_estcpu; 242 register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]); 243 244 if (p->p_slptime > 5 * loadfac) 245 p->p_estcpu = 0; 246 else { 247 p->p_slptime--; /* the first time was done in schedcpu */ 248 while (newcpu && --p->p_slptime) 249 newcpu = (int) decay_cpu(loadfac, newcpu); 250 p->p_estcpu = min(newcpu, UCHAR_MAX); 251 } 252 resetpriority(p); 253} 254 255/* 256 * We're only looking at 7 bits of the address; everything is 257 * aligned to 4, lots of things are aligned to greater powers 258 * of 2. Shift right by 8, i.e. drop the bottom 256 worth. 259 */ 260#define TABLESIZE 128 261#define LOOKUP(x) (((int)(x) >> 8) & (TABLESIZE - 1)) 262struct slpque { 263 struct proc *sq_head; 264 struct proc **sq_tailp; 265} slpque[TABLESIZE]; 266 267/* 268 * During autoconfiguration or after a panic, a sleep will simply 269 * lower the priority briefly to allow interrupts, then return. 270 * The priority to be used (safepri) is machine-dependent, thus this 271 * value is initialized and maintained in the machine-dependent layers. 272 * This priority will typically be 0, or the lowest priority 273 * that is safe for use on the interrupt stack; it can be made 274 * higher to block network software interrupts after panics. 275 */ 276int safepri; 277 278/* 279 * General sleep call. Suspends the current process until a wakeup is 280 * performed on the specified identifier. The process will then be made 281 * runnable with the specified priority. Sleeps at most timo/hz seconds 282 * (0 means no timeout). If pri includes PCATCH flag, signals are checked 283 * before and after sleeping, else signals are not checked. Returns 0 if 284 * awakened, EWOULDBLOCK if the timeout expires. If PCATCH is set and a 285 * signal needs to be delivered, ERESTART is returned if the current system 286 * call should be restarted if possible, and EINTR is returned if the system 287 * call should be interrupted by the signal (return EINTR). 288 */ 289int 290tsleep(ident, priority, wmesg, timo) 291 void *ident; 292 int priority, timo; 293 char *wmesg; 294{ 295 register struct proc *p = curproc; 296 register struct slpque *qp; 297 register s; 298 int sig, catch = priority & PCATCH; 299 300#ifdef KTRACE 301 if (KTRPOINT(p, KTR_CSW)) 302 ktrcsw(p->p_tracep, 1, 0); 303#endif 304 s = splhigh(); 305 if (cold || panicstr) { 306 /* 307 * After a panic, or during autoconfiguration, 308 * just give interrupts a chance, then just return; 309 * don't run any other procs or panic below, 310 * in case this is the idle process and already asleep. 311 */ 312 splx(safepri); 313 splx(s); 314 return (0); 315 } 316#ifdef DIAGNOSTIC 317 if (ident == NULL || p->p_stat != SRUN || p->p_back) 318 panic("tsleep"); 319#endif 320 p->p_wchan = ident; 321 p->p_wmesg = wmesg; 322 p->p_slptime = 0; 323 p->p_priority = priority & PRIMASK; 324 qp = &slpque[LOOKUP(ident)]; 325 if (qp->sq_head == 0) 326 qp->sq_head = p; 327 else 328 *qp->sq_tailp = p; 329 *(qp->sq_tailp = &p->p_forw) = 0; 330 if (timo) 331 timeout(endtsleep, (void *)p, timo); 332 /* 333 * We put ourselves on the sleep queue and start our timeout 334 * before calling CURSIG, as we could stop there, and a wakeup 335 * or a SIGCONT (or both) could occur while we were stopped. 336 * A SIGCONT would cause us to be marked as SSLEEP 337 * without resuming us, thus we must be ready for sleep 338 * when CURSIG is called. If the wakeup happens while we're 339 * stopped, p->p_wchan will be 0 upon return from CURSIG. 340 */ 341 if (catch) { 342 p->p_flag |= P_SINTR; 343 if ((sig = CURSIG(p))) { 344 if (p->p_wchan) 345 unsleep(p); 346 p->p_stat = SRUN; 347 goto resume; 348 } 349 if (p->p_wchan == 0) { 350 catch = 0; 351 goto resume; 352 } 353 } else 354 sig = 0; 355 p->p_stat = SSLEEP; 356 p->p_stats->p_ru.ru_nvcsw++; 357 mi_switch(); 358resume: 359 curpriority = p->p_usrpri; 360 splx(s); 361 p->p_flag &= ~P_SINTR; 362 if (p->p_flag & P_TIMEOUT) { 363 p->p_flag &= ~P_TIMEOUT; 364 if (sig == 0) { 365#ifdef KTRACE 366 if (KTRPOINT(p, KTR_CSW)) 367 ktrcsw(p->p_tracep, 0, 0); 368#endif 369 return (EWOULDBLOCK); 370 } 371 } else if (timo) 372 untimeout(endtsleep, (void *)p); 373 if (catch && (sig != 0 || (sig = CURSIG(p)))) { 374#ifdef KTRACE 375 if (KTRPOINT(p, KTR_CSW)) 376 ktrcsw(p->p_tracep, 0, 0); 377#endif 378 if (p->p_sigacts->ps_sigintr & sigmask(sig)) 379 return (EINTR); 380 return (ERESTART); 381 } 382#ifdef KTRACE 383 if (KTRPOINT(p, KTR_CSW)) 384 ktrcsw(p->p_tracep, 0, 0); 385#endif 386 return (0); 387} 388 389/* 390 * Implement timeout for tsleep. 391 * If process hasn't been awakened (wchan non-zero), 392 * set timeout flag and undo the sleep. If proc 393 * is stopped, just unsleep so it will remain stopped. 394 */ 395void 396endtsleep(arg) 397 void *arg; 398{ 399 register struct proc *p; 400 int s; 401 402 p = (struct proc *)arg; 403 s = splhigh(); 404 if (p->p_wchan) { 405 if (p->p_stat == SSLEEP) 406 setrunnable(p); 407 else 408 unsleep(p); 409 p->p_flag |= P_TIMEOUT; 410 } 411 splx(s); 412} 413 414/* 415 * Short-term, non-interruptable sleep. 416 */ 417void 418sleep(ident, priority) 419 void *ident; 420 int priority; 421{ 422 register struct proc *p = curproc; 423 register struct slpque *qp; 424 register s; 425 426#ifdef DIAGNOSTIC 427 if (priority > PZERO) { 428 printf("sleep called with priority %d > PZERO, wchan: %p\n", 429 priority, ident); 430 panic("old sleep"); 431 } 432#endif 433 s = splhigh(); 434 if (cold || panicstr) { 435 /* 436 * After a panic, or during autoconfiguration, 437 * just give interrupts a chance, then just return; 438 * don't run any other procs or panic below, 439 * in case this is the idle process and already asleep. 440 */ 441 splx(safepri); 442 splx(s); 443 return; 444 } 445#ifdef DIAGNOSTIC 446 if (ident == NULL || p->p_stat != SRUN || p->p_back) 447 panic("sleep"); 448#endif 449 p->p_wchan = ident; 450 p->p_wmesg = NULL; 451 p->p_slptime = 0; 452 p->p_priority = priority; 453 qp = &slpque[LOOKUP(ident)]; 454 if (qp->sq_head == 0) 455 qp->sq_head = p; 456 else 457 *qp->sq_tailp = p; 458 *(qp->sq_tailp = &p->p_forw) = 0; 459 p->p_stat = SSLEEP; 460 p->p_stats->p_ru.ru_nvcsw++; 461#ifdef KTRACE 462 if (KTRPOINT(p, KTR_CSW)) 463 ktrcsw(p->p_tracep, 1, 0); 464#endif 465 mi_switch(); 466#ifdef KTRACE 467 if (KTRPOINT(p, KTR_CSW)) 468 ktrcsw(p->p_tracep, 0, 0); 469#endif 470 curpriority = p->p_usrpri; 471 splx(s); 472} 473 474/* 475 * Remove a process from its wait queue 476 */ 477void 478unsleep(p) 479 register struct proc *p; 480{ 481 register struct slpque *qp; 482 register struct proc **hp; 483 int s; 484 485 s = splhigh(); 486 if (p->p_wchan) { 487 hp = &(qp = &slpque[LOOKUP(p->p_wchan)])->sq_head; 488 while (*hp != p) 489 hp = &(*hp)->p_forw; 490 *hp = p->p_forw; 491 if (qp->sq_tailp == &p->p_forw) 492 qp->sq_tailp = hp; 493 p->p_wchan = 0; 494 } 495 splx(s); 496} 497 498/* 499 * Make all processes sleeping on the specified identifier runnable. 500 */ 501void 502wakeup(ident) 503 register void *ident; 504{ 505 register struct slpque *qp; 506 register struct proc *p, **q; 507 int s; 508 509 s = splhigh(); 510 qp = &slpque[LOOKUP(ident)]; 511restart: 512 for (q = &qp->sq_head; *q; ) { 513 p = *q; 514#ifdef DIAGNOSTIC 515 if (p->p_back || (p->p_stat != SSLEEP && p->p_stat != SSTOP)) 516 panic("wakeup"); 517#endif 518 if (p->p_wchan == ident) { 519 p->p_wchan = 0; 520 *q = p->p_forw; 521 if (qp->sq_tailp == &p->p_forw) 522 qp->sq_tailp = q; 523 if (p->p_stat == SSLEEP) { 524 /* OPTIMIZED EXPANSION OF setrunnable(p); */ 525 if (p->p_slptime > 1) 526 updatepri(p); 527 p->p_slptime = 0; 528 p->p_stat = SRUN; 529 if (p->p_flag & P_INMEM) 530 setrunqueue(p); 531 /* 532 * Since curpriority is a user priority, 533 * p->p_priority is always better than 534 * curpriority. 535 */ 536 if ((p->p_flag & P_INMEM) == 0) 537 wakeup((caddr_t)&proc0); 538 else 539 need_resched(); 540 /* END INLINE EXPANSION */ 541 goto restart; 542 } 543 } else 544 q = &p->p_forw; 545 } 546 splx(s); 547} 548 549/* 550 * The machine independent parts of mi_switch(). 551 * Must be called at splstatclock() or higher. 552 */ 553void 554mi_switch() 555{ 556 register struct proc *p = curproc; /* XXX */ 557 register struct rlimit *rlim; 558 register long s, u; 559 struct timeval tv; 560 561 /* 562 * Compute the amount of time during which the current 563 * process was running, and add that to its total so far. 564 */ 565 microtime(&tv); 566 u = p->p_rtime.tv_usec + (tv.tv_usec - runtime.tv_usec); 567 s = p->p_rtime.tv_sec + (tv.tv_sec - runtime.tv_sec); 568 if (u < 0) { 569 u += 1000000; 570 s--; 571 } else if (u >= 1000000) { 572 u -= 1000000; 573 s++; 574 } 575 p->p_rtime.tv_usec = u; 576 p->p_rtime.tv_sec = s; 577 578 /* 579 * Check if the process exceeds its cpu resource allocation. 580 * If over max, kill it. In any case, if it has run for more 581 * than 10 minutes, reduce priority to give others a chance. 582 */ 583 if (p->p_stat != SZOMB) { 584 rlim = &p->p_rlimit[RLIMIT_CPU]; 585 if (s >= rlim->rlim_cur) { 586 if (s >= rlim->rlim_max) 587 psignal(p, SIGKILL); 588 else { 589 psignal(p, SIGXCPU); 590 if (rlim->rlim_cur < rlim->rlim_max) 591 rlim->rlim_cur += 5; 592 } 593 } 594 if (s > 10 * 60 && p->p_ucred->cr_uid && p->p_nice == NZERO) { 595 p->p_nice = NZERO + 4; 596 resetpriority(p); 597 } 598 } 599 600 /* 601 * Pick a new current process and record its start time. 602 */ 603 cnt.v_swtch++; 604 cpu_switch(p); 605 microtime(&runtime); 606} 607 608/* 609 * Initialize the (doubly-linked) run queues 610 * to be empty. 611 */ 612/* ARGSUSED*/ 613static void 614rqinit(dummy) 615 void *dummy; 616{ 617 register int i; 618 619 for (i = 0; i < NQS; i++) { 620 qs[i].ph_link = qs[i].ph_rlink = (struct proc *)&qs[i]; 621 rtqs[i].ph_link = rtqs[i].ph_rlink = (struct proc *)&rtqs[i]; 622 idqs[i].ph_link = idqs[i].ph_rlink = (struct proc *)&idqs[i]; 623 } 624} 625 626/* 627 * Change process state to be runnable, 628 * placing it on the run queue if it is in memory, 629 * and awakening the swapper if it isn't in memory. 630 */ 631void 632setrunnable(p) 633 register struct proc *p; 634{ 635 register int s; 636 637 s = splhigh(); 638 switch (p->p_stat) { 639 case 0: 640 case SRUN: 641 case SZOMB: 642 default: 643 panic("setrunnable"); 644 case SSTOP: 645 case SSLEEP: 646 unsleep(p); /* e.g. when sending signals */ 647 break; 648 649 case SIDL: 650 break; 651 } 652 p->p_stat = SRUN; 653 if (p->p_flag & P_INMEM) 654 setrunqueue(p); 655 splx(s); 656 if (p->p_slptime > 1) 657 updatepri(p); 658 p->p_slptime = 0; 659 if ((p->p_flag & P_INMEM) == 0) 660 wakeup((caddr_t)&proc0); 661 else if (p->p_priority < curpriority) 662 need_resched(); 663} 664 665/* 666 * Compute the priority of a process when running in user mode. 667 * Arrange to reschedule if the resulting priority is better 668 * than that of the current process. 669 */ 670void 671resetpriority(p) 672 register struct proc *p; 673{ 674 register unsigned int newpriority; 675 676 if (p->p_rtprio.type == RTP_PRIO_NORMAL) { 677 newpriority = PUSER + p->p_estcpu / 4 + 2 * p->p_nice; 678 newpriority = min(newpriority, MAXPRI); 679 p->p_usrpri = newpriority; 680 if (newpriority < curpriority) 681 need_resched(); 682 } else { 683 need_resched(); 684 } 685} 686