Changeset c47e1a8 in mainline for kernel/generic/src/proc/scheduler.c
- Timestamp:
- 2010-05-21T07:50:04Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d51ee2b
- Parents:
- cf8cc36 (diff), 15b592b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
kernel/generic/src/proc/scheduler.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/scheduler.c
rcf8cc36 rc47e1a8 1 1 /* 2 * Copyright (c) 20 01-2007Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 187 187 188 188 loop: 189 interrupts_enable();190 189 191 190 if (atomic_get(&CPU->nrdy) == 0) { … … 196 195 */ 197 196 198 /* 197 /* Mark CPU as it was idle this clock tick */ 198 spinlock_lock(&CPU->lock); 199 CPU->idle = true; 200 spinlock_unlock(&CPU->lock); 201 202 interrupts_enable(); 203 /* 199 204 * An interrupt might occur right now and wake up a thread. 200 205 * In such case, the CPU will continue to go to sleep 201 206 * even though there is a runnable thread. 202 207 */ 203 204 208 cpu_sleep(); 209 interrupts_disable(); 205 210 goto loop; 206 211 } 207 208 interrupts_disable();209 212 210 213 for (i = 0; i < RQ_COUNT; i++) { … … 313 316 spinlock_lock(&THREAD->lock); 314 317 315 /* Update thread accounting */316 THREAD-> cycles += get_cycle() - THREAD->last_cycle;318 /* Update thread kernel accounting */ 319 THREAD->kcycles += get_cycle() - THREAD->last_cycle; 317 320 318 321 #ifndef CONFIG_FPU_LAZY … … 379 382 int priority; 380 383 DEADLOCK_PROBE_INIT(p_joinwq); 384 task_t *old_task = TASK; 385 as_t *old_as = AS; 381 386 382 387 ASSERT(CPU != NULL); 383 388 389 /* 390 * Hold the current task and the address space to prevent their 391 * possible destruction should thread_destroy() be called on this or any 392 * other processor while the scheduler is still using them. 393 */ 394 if (old_task) 395 task_hold(old_task); 396 if (old_as) 397 as_hold(old_as); 398 384 399 if (THREAD) { 385 400 /* must be run after the switch to scheduler stack */ … … 473 488 */ 474 489 if (TASK != THREAD->task) { 475 as_t *as1 = NULL; 476 as_t *as2; 477 478 if (TASK) { 479 spinlock_lock(&TASK->lock); 480 as1 = TASK->as; 481 spinlock_unlock(&TASK->lock); 482 } 483 484 spinlock_lock(&THREAD->task->lock); 485 as2 = THREAD->task->as; 486 spinlock_unlock(&THREAD->task->lock); 490 as_t *new_as = THREAD->task->as; 487 491 488 492 /* … … 490 494 * space. 491 495 */ 492 if ( as1 != as2) {496 if (old_as != new_as) { 493 497 /* 494 498 * Both tasks and address spaces are different. 495 499 * Replace the old one with the new one. 496 500 */ 497 as_switch( as1, as2);501 as_switch(old_as, new_as); 498 502 } 503 499 504 TASK = THREAD->task; 500 505 before_task_runs(); 501 506 } 502 507 508 if (old_task) 509 task_release(old_task); 510 if (old_as) 511 as_release(old_as); 512 503 513 spinlock_lock(&THREAD->lock); 504 514 THREAD->state = Running; … … 542 552 { 543 553 thread_t *t; 544 int count, average, j, k = 0; 554 int count; 555 atomic_count_t average; 545 556 unsigned int i; 557 int j; 558 int k = 0; 546 559 ipl_t ipl; 547 560
Note:
See TracChangeset
for help on using the changeset viewer.
