Changeset 1066041 in mainline for kernel/generic/include/preemption.h


Ignore:
Timestamp:
2012-07-11T07:58:03Z (12 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
935e28c
Parents:
b68ae24
Message:

preemption_disable: Turned functions into macros. Moved THREAD, AS, TASK, CPU into thread.h, as.h, task.h, cpu.h to fix the include hell that ensued.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/preemption.h

    rb68ae24 r1066041  
    3636#define KERN_PREEMPTION_H_
    3737
    38 extern void preemption_disable(void);
    39 extern void preemption_enable(void);
    40 extern void preemption_enable_noresched(void);
    41 extern void preemption_enabled_scheduler(void);
     38#include <arch.h>
     39#include <compiler/barrier.h>
     40#include <debug.h>
     41
     42#define PREEMPTION_INC         (1 << 1)
     43#define PREEMPTION_NEEDED_FLAG (1 << 0)
     44#define PREEMPTION_NEEDED      (THE->preemption & PREEMPTION_NEEDED_FLAG)
     45#define PREEMPTION_DISABLED    (PREEMPTION_INC <= THE->preemption)
     46#define PREEMPTION_ENABLED     (!PREEMPTION_DISABLED)
     47
     48/** Increment preemption disabled counter. */
     49#define preemption_disable() \
     50        do { \
     51                THE->preemption += PREEMPTION_INC; \
     52                compiler_barrier(); \
     53        } while (0)
     54
     55/** Restores preemption and reschedules if out time slice already elapsed.*/
     56#define preemption_enable() \
     57        do { \
     58                preemption_enable_noresched(); \
     59                \
     60                if (PREEMPTION_ENABLED && PREEMPTION_NEEDED) { \
     61                        preemption_enabled_scheduler(); \
     62                } \
     63        } while (0)
     64
     65/** Restores preemption but never reschedules. */
     66#define preemption_enable_noresched() \
     67        do { \
     68                ASSERT(PREEMPTION_DISABLED); \
     69                compiler_barrier(); \
     70                THE->preemption -= PREEMPTION_INC; \
     71        } while (0)
    4272
    4373
     74extern void preemption_enabled_scheduler(void);
     75extern void preemption_set_needed(void);
     76extern void preemption_clear_needed(void);
    4477
    4578#endif
Note: See TracChangeset for help on using the changeset viewer.