Changeset 25a76ab8 in mainline for kernel/generic/src/proc/scheduler.c
- Timestamp:
- 2010-05-08T07:53:23Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 051bc69a
- Parents:
- 6c39a907 (diff), 1317380 (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
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/scheduler.c
r6c39a907 r25a76ab8 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 spinlock_lock(&CPU->lock);205 CPU->idle = true;206 spinlock_unlock(&CPU->lock);207 208 cpu_sleep(); 209 interrupts_disable(); 208 210 goto loop; 209 211 } 210 211 interrupts_disable();212 212 213 213 for (i = 0; i < RQ_COUNT; i++) { … … 382 382 int priority; 383 383 DEADLOCK_PROBE_INIT(p_joinwq); 384 task_t *old_task = TASK; 385 as_t *old_as = AS; 384 386 385 387 ASSERT(CPU != NULL); 386 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 387 399 if (THREAD) { 388 400 /* must be run after the switch to scheduler stack */ … … 476 488 */ 477 489 if (TASK != THREAD->task) { 478 as_t *as1 = NULL; 479 as_t *as2; 480 481 if (TASK) { 482 spinlock_lock(&TASK->lock); 483 as1 = TASK->as; 484 spinlock_unlock(&TASK->lock); 485 } 486 487 spinlock_lock(&THREAD->task->lock); 488 as2 = THREAD->task->as; 489 spinlock_unlock(&THREAD->task->lock); 490 as_t *new_as = THREAD->task->as; 490 491 491 492 /* … … 493 494 * space. 494 495 */ 495 if ( as1 != as2) {496 if (old_as != new_as) { 496 497 /* 497 498 * Both tasks and address spaces are different. 498 499 * Replace the old one with the new one. 499 500 */ 500 as_switch( as1, as2);501 as_switch(old_as, new_as); 501 502 } 503 502 504 TASK = THREAD->task; 503 505 before_task_runs(); 504 506 } 505 507 508 if (old_task) 509 task_release(old_task); 510 if (old_as) 511 as_release(old_as); 512 506 513 spinlock_lock(&THREAD->lock); 507 514 THREAD->state = Running;
Note:
See TracChangeset
for help on using the changeset viewer.