Changeset 057e77f in mainline for kernel/generic/src


Ignore:
Timestamp:
2012-07-16T15:31:56Z (13 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0cf813d
Parents:
0594c7ea
Message:

preemption_disable: Removed failed attempt at rescheduling once preemption is enabled (and needed). Once again, preemption_enable() never reschedules.

Location:
kernel/generic/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/preempt/preemption.c

    r0594c7ea r057e77f  
    3737
    3838#include <preemption.h>
    39 #include <proc/scheduler.h>
    4039
    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 that
    58          * occurs right after the check.
    59          *
    60          * Also ensures that code that relies on disabled interrupts
    61          * 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 }
    8340
    8441/** @}
  • kernel/generic/src/time/clock.c

    r0594c7ea r057e77f  
    212212                irq_spinlock_unlock(&THREAD->lock, false);
    213213               
    214                 if (ticks == 0) {
    215                         if (PREEMPTION_ENABLED) {
    216                                 scheduler();
     214                if (ticks == 0 && PREEMPTION_ENABLED) {
     215                        scheduler();
    217216#ifdef CONFIG_UDEBUG
    218                                 /*
    219                                 * Give udebug chance to stop the thread
    220                                 * before it begins executing userspace code.
    221                                 */
    222                                 istate_t *istate = THREAD->udebug.uspace_state;
    223                                 if ((istate) && (istate_from_uspace(istate)))
    224                                         udebug_before_thread_runs();
     217                        /*
     218                         * Give udebug chance to stop the thread
     219                         * before it begins executing userspace code.
     220                         */
     221                        istate_t *istate = THREAD->udebug.uspace_state;
     222                        if ((istate) && (istate_from_uspace(istate)))
     223                                udebug_before_thread_runs();
    225224#endif
    226                         } else {
    227                                 preemption_set_needed();
    228                         }
    229225                }
    230226        }
Note: See TracChangeset for help on using the changeset viewer.