Changeset 248fc1a in mainline
- Timestamp:
- 2006-02-05T13:56:01Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 444ec64
- Parents:
- e22f561
- Location:
- generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/cpu.h
re22f561 r248fc1a 51 51 context_t saved_context; 52 52 53 volatile count_t nrdy;53 atomic_t nrdy; 54 54 runq_t rq[RQ_COUNT]; 55 55 volatile count_t needs_relink; -
generic/src/mm/slab.c
re22f561 r248fc1a 253 253 list_remove(&slab->link); 254 254 list_prepend(&slab->link, &cache->partial_slabs); 255 spinlock_unlock(&cache->slablock);256 }255 } 256 spinlock_unlock(&cache->slablock); 257 257 return 0; 258 258 } … … 537 537 int i; 538 538 int pages; 539 ipl_t ipl; 539 540 540 541 memsetb((__address)cache, sizeof(*cache), 0); … … 581 582 cache->flags |= SLAB_CACHE_SLINSIDE; 582 583 584 /* Add cache to cache list */ 585 ipl = interrupts_disable(); 583 586 spinlock_lock(&slab_cache_lock); 584 587 … … 586 589 587 590 spinlock_unlock(&slab_cache_lock); 591 interrupts_restore(ipl); 588 592 } 589 593 … … 759 763 slab_cache_t *cache; 760 764 link_t *cur; 761 765 ipl_t ipl; 766 767 ipl = interrupts_disable(); 762 768 spinlock_lock(&slab_cache_lock); 763 769 printf("SLAB name\tOsize\tPages\tObj/pg\tSlabs\tCached\tAllocobjs\tCtl\n"); … … 772 778 } 773 779 spinlock_unlock(&slab_cache_lock); 780 interrupts_restore(ipl); 774 781 } 775 782 -
generic/src/proc/scheduler.c
re22f561 r248fc1a 120 120 thread_t *t; 121 121 runq_t *r; 122 int i , n;122 int i; 123 123 124 124 ASSERT(CPU != NULL); 125 125 126 126 loop: 127 interrupts_disable();128 129 spinlock_lock(&CPU->lock);130 n = CPU->nrdy;131 spinlock_unlock(&CPU->lock);132 133 127 interrupts_enable(); 134 128 135 if ( n== 0) {129 if (atomic_get(&CPU->nrdy) == 0) { 136 130 /* 137 131 * For there was nothing to run, the CPU goes to sleep … … 146 140 147 141 i = 0; 148 retry:149 142 for (; i<RQ_COUNT; i++) { 150 143 r = &CPU->rq[i]; … … 158 151 } 159 152 160 /* avoid deadlock with relink_rq() */ 161 if (!spinlock_trylock(&CPU->lock)) { 162 /* 163 * Unlock r and try again. 164 */ 165 spinlock_unlock(&r->lock); 166 goto retry; 167 } 168 CPU->nrdy--; 169 spinlock_unlock(&CPU->lock); 170 153 atomic_dec(&CPU->nrdy); 171 154 atomic_dec(&nrdy); 172 155 r->n--; … … 465 448 { 466 449 thread_t *t; 467 int count, i, j, k = 0;450 int count, average, i, j, k = 0; 468 451 ipl_t ipl; 469 452 … … 480 463 * passes. Each time get the most up to date counts. 481 464 */ 482 ipl = interrupts_disable(); 483 spinlock_lock(&CPU->lock); 484 count = atomic_get(&nrdy) / config.cpu_active; 485 count -= CPU->nrdy; 486 spinlock_unlock(&CPU->lock); 487 interrupts_restore(ipl); 488 489 if (count <= 0) 465 average = atomic_get(&nrdy) / config.cpu_active; 466 count = average - atomic_get(&CPU->nrdy); 467 468 if (count < 0) 490 469 goto satisfied; 470 471 if (!count) { /* Try to steal threads from CPU's that have more then average count */ 472 count = 1; 473 average += 1; 474 } 491 475 492 476 /* … … 506 490 */ 507 491 if (CPU == cpu) 508 continue; 492 continue; 493 if (atomic_get(&cpu->nrdy) <= average) 494 continue; 509 495 510 496 restart: ipl = interrupts_disable(); … … 545 531 goto restart; 546 532 } 547 cpu->nrdy--;533 atomic_dec(&cpu->nrdy); 548 534 spinlock_unlock(&cpu->lock); 549 535 … … 567 553 spinlock_lock(&t->lock); 568 554 #ifdef KCPULB_VERBOSE 569 printf("kcpulb%d: TID %d -> cpu%d, nrdy=%d, avg=%d\n", CPU->id, t->tid, CPU->id, CPU->nrdy, atomic_get(&nrdy) / config.cpu_active);555 printf("kcpulb%d: TID %d -> cpu%d, nrdy=%d, avg=%d\n", CPU->id, t->tid, CPU->id, atomic_get(&CPU->nrdy), atomic_get(&nrdy) / config.cpu_active); 570 556 #endif 571 557 t->flags |= X_STOLEN; … … 590 576 } 591 577 592 if ( CPU->nrdy) {578 if (atomic_get(&CPU->nrdy)) { 593 579 /* 594 580 * Be a little bit light-weight and let migrated threads run. … … 630 616 spinlock_lock(&cpus[cpu].lock); 631 617 printf("cpu%d: nrdy: %d needs_relink: %d\n", 632 cpus[cpu].id, cpus[cpu].nrdy, cpus[cpu].needs_relink);618 cpus[cpu].id, atomic_get(&cpus[cpu].nrdy), cpus[cpu].needs_relink); 633 619 634 620 for (i=0; i<RQ_COUNT; i++) { -
generic/src/proc/thread.c
re22f561 r248fc1a 138 138 atomic_inc(&nrdy); 139 139 avg = atomic_get(&nrdy) / config.cpu_active; 140 141 spinlock_lock(&cpu->lock); 142 if ((++cpu->nrdy) > avg) { 143 /* 144 * If there are idle halted CPU's, this will wake them up. 145 */ 146 ipi_broadcast(VECTOR_WAKEUP_IPI); 147 } 148 spinlock_unlock(&cpu->lock); 140 atomic_inc(&cpu->nrdy); 149 141 150 142 interrupts_restore(ipl);
Note:
See TracChangeset
for help on using the changeset viewer.