Changeset 057e77f in mainline for kernel/generic/src/preempt/preemption.c
- Timestamp:
- 2012-07-16T15:31:56Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0cf813d
- Parents:
- 0594c7ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/preempt/preemption.c
r0594c7ea r057e77f 37 37 38 38 #include <preemption.h> 39 #include <proc/scheduler.h>40 39 41 42 /** Determines if we are executing an exception/interrupt handler. */43 static bool in_exc_handler(void)44 {45 /* Err on the safe side until all exception processing code is audited. */46 return true;47 }48 49 /** Preemption was enabled. Calls scheduler(). */50 void preemption_enabled_scheduler(void)51 {52 ASSERT(PREEMPTION_ENABLED);53 ASSERT(PREEMPTION_NEEDED);54 55 /*56 * Avoid a race between a thread about to invoke the scheduler()57 * after checking THREAD->need_resched and an interrupt that58 * occurs right after the check.59 *60 * Also ensures that code that relies on disabled interrupts61 * to suppress preemption continues to work.62 */63 if (!interrupts_disabled() && !in_exc_handler()) {64 preemption_clear_needed();65 /* We may be preempted here, so we'll scheduler() again. Too bad. */66 scheduler();67 }68 }69 70 /** Sets a flag to reschedule the next time preemption is enabled. */71 void preemption_set_needed(void)72 {73 /* No need to disable interrupts. */74 THE->preemption |= PREEMPTION_NEEDED_FLAG;75 }76 77 /** Instructs not to reschedule immediately when preemption is enabled. */78 void preemption_clear_needed(void)79 {80 /* No need to disable interrupts. */81 THE->preemption &= ~PREEMPTION_NEEDED_FLAG;82 }83 40 84 41 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.