Changeset 1066041 in mainline for kernel/generic/include


Ignore:
Timestamp:
2012-07-11T07:58:03Z (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:
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.

Location:
kernel/generic/include
Files:
6 edited

Legend:

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

    rb68ae24 r1066041  
    3636#define KERN_ARCH_H_
    3737
    38 #include <arch/arch.h>
    39 #include <proc/thread.h>
    40 #include <proc/task.h>
    41 #include <mm/as.h>
     38#include <arch/arch.h>  /* arch_pre_main() */
     39#include <arch/asm.h>   /* get_stack_base() */
     40
    4241
    4342/*
     
    4948#define THE  ((the_t * )(get_stack_base()))
    5049
    51 #define CPU                  THE->cpu
    52 #define THREAD               THE->thread
    53 #define TASK                 THE->task
    54 #define AS                   THE->as
    55 #define PREEMPTION_DISABLED  (0 != THE->preemption_disabled)
    56 #define PREEMPTION_ENABLED   (0 == THE->preemption_disabled)
    5750#define MAGIC                UINT32_C(0xfacefeed)
    5851
     
    6356        ((THE->task) ? (THE->task->container) : (DEFAULT_CONTAINER))
    6457
     58/* Fwd decl. to avoid include hell. */
     59struct thread;
     60struct task;
     61struct cpu;
     62struct as;
     63
    6564/**
    6665 * For each possible kernel stack, structure
     
    6968 */
    7069typedef struct {
    71         size_t preemption_disabled;  /**< Preemption disabled counter. */
    72         thread_t *thread;            /**< Current thread. */
    73         task_t *task;                /**< Current task. */
    74         cpu_t *cpu;                  /**< Executing cpu. */
    75         as_t *as;                    /**< Current address space. */
    76         uint32_t magic;              /**< Magic value */
     70        size_t preemption;     /**< Preemption disabled counter and flag. */
     71        struct thread *thread; /**< Current thread. */
     72        struct task *task;     /**< Current task. */
     73        struct cpu *cpu;       /**< Executing cpu. */
     74        struct as *as;         /**< Current address space. */
     75        uint32_t magic;        /**< Magic value */
    7776} the_t;
    7877
     
    9291extern void *arch_construct_function(fncptr_t *, void *, void *);
    9392
     93
    9494#endif
    9595
  • kernel/generic/include/cpu.h

    rb68ae24 r1066041  
    4343#include <arch/context.h>
    4444#include <adt/list.h>
     45#include <arch.h>
     46
     47#define CPU                  THE->cpu
     48
    4549
    4650/** CPU structure.
  • kernel/generic/include/mm/as.h

    rb68ae24 r1066041  
    4848#include <adt/btree.h>
    4949#include <lib/elf.h>
     50#include <arch.h>
     51
     52#define AS                   THE->as
     53
    5054
    5155/**
  • 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
  • kernel/generic/include/proc/task.h

    rb68ae24 r1066041  
    5757#include <mm/as.h>
    5858#include <abi/sysinfo.h>
     59#include <arch.h>
     60
     61#define TASK                 THE->task
     62
    5963
    6064struct thread;
  • kernel/generic/include/proc/thread.h

    rb68ae24 r1066041  
    4949#include <udebug/udebug.h>
    5050#include <abi/sysinfo.h>
     51#include <arch.h>
     52
     53
     54#define THREAD              THE->thread
    5155
    5256#define THREAD_NAME_BUFLEN  20
     
    155159        state_t state;
    156160       
    157         /** The thread would have been rescheduled had it not disabled preemption.*/
    158         bool need_resched;
    159        
    160161        /** Thread CPU. */
    161162        cpu_t *cpu;
Note: See TracChangeset for help on using the changeset viewer.