Changeset da1bafb in mainline for kernel/generic/include/proc


Ignore:
Timestamp:
2010-05-24T18:57:31Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
Location:
kernel/generic/include/proc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/proc/scheduler.h

    r666f492 rda1bafb  
    4747/** Scheduler run queue structure. */
    4848typedef struct {
    49         SPINLOCK_DECLARE(lock);
    50         link_t rq_head;          /**< List of ready threads. */
    51         size_t n;                /**< Number of threads in rq_ready. */
     49        IRQ_SPINLOCK_DECLARE(lock);
     50        link_t rq_head;              /**< List of ready threads. */
     51        size_t n;                    /**< Number of threads in rq_ready. */
    5252} runq_t;
    5353
  • kernel/generic/include/proc/task.h

    r666f492 rda1bafb  
    7070         * threads.
    7171         */
    72         SPINLOCK_DECLARE(lock);
    73 
     72        IRQ_SPINLOCK_DECLARE(lock);
     73       
    7474        char name[TASK_NAME_BUFLEN];
    7575        /** List of threads contained in this task. */
     
    8181        /** Task security context. */
    8282        context_id_t context;
    83 
     83       
    8484        /** Number of references (i.e. threads). */
    8585        atomic_t refcount;
    8686        /** Number of threads that haven't exited yet. */
    8787        atomic_t lifecount;
    88 
     88       
    8989        /** Task capabilities. */
    9090        cap_t capabilities;
    91 
     91       
    9292        /* IPC stuff */
    9393        answerbox_t answerbox;  /**< Communication endpoint */
     
    101101        /** List of synchronous answerboxes. */
    102102        link_t sync_box_head;
    103 
     103       
    104104#ifdef CONFIG_UDEBUG
    105105        /** Debugging stuff. */
    106106        udebug_task_t udebug;
    107 
     107       
    108108        /** Kernel answerbox. */
    109109        kbox_t kb;
    110 #endif
    111 
     110#endif /* CONFIG_UDEBUG */
     111       
    112112        /** Architecture specific task data. */
    113113        task_arch_t arch;
     
    126126} task_t;
    127127
    128 SPINLOCK_EXTERN(tasks_lock);
     128IRQ_SPINLOCK_EXTERN(tasks_lock);
    129129extern avltree_t tasks_tree;
    130130
  • kernel/generic/include/proc/thread.h

    r666f492 rda1bafb  
    5050#include <sysinfo/abi.h>
    5151
    52 #define THREAD_STACK_SIZE       STACK_SIZE
    53 #define THREAD_NAME_BUFLEN      20
     52#define THREAD_STACK_SIZE   STACK_SIZE
     53#define THREAD_NAME_BUFLEN  20
    5454
    5555extern const char *thread_states[];
     
    6161 * When using this flag, the caller must set cpu in the thread_t
    6262 * structure manually before calling thread_ready (even on uniprocessor).
    63  */
    64 #define THREAD_FLAG_WIRED       (1 << 0)
     63 *
     64 */
     65#define THREAD_FLAG_WIRED  (1 << 0)
     66
    6567/** Thread was migrated to another CPU and has not run yet. */
    66 #define THREAD_FLAG_STOLEN      (1 << 1)
     68#define THREAD_FLAG_STOLEN  (1 << 1)
     69
    6770/** Thread executes in userspace. */
    68 #define THREAD_FLAG_USPACE      (1 << 2)
     71#define THREAD_FLAG_USPACE  (1 << 2)
     72
    6973/** Thread will be attached by the caller. */
    70 #define THREAD_FLAG_NOATTACH    (1 << 3)
     74#define THREAD_FLAG_NOATTACH  (1 << 3)
    7175
    7276/** Thread structure. There is one per thread. */
    7377typedef struct thread {
    74         link_t rq_link;         /**< Run queue link. */
    75         link_t wq_link;         /**< Wait queue link. */
    76         link_t th_link;         /**< Links to threads within containing task. */
    77 
     78        link_t rq_link;  /**< Run queue link. */
     79        link_t wq_link;  /**< Wait queue link. */
     80        link_t th_link;  /**< Links to threads within containing task. */
     81       
    7882        /** Threads linkage to the threads_tree. */
    7983        avltree_node_t threads_tree_node;
     
    8387         * Protects the whole thread structure except list links above.
    8488         */
    85         SPINLOCK_DECLARE(lock);
    86 
     89        IRQ_SPINLOCK_DECLARE(lock);
     90       
    8791        char name[THREAD_NAME_BUFLEN];
    88 
     92       
    8993        /** Function implementing the thread. */
    9094        void (* thread_code)(void *);
    9195        /** Argument passed to thread_code() function. */
    9296        void *thread_arg;
    93 
     97       
    9498        /**
    9599         * From here, the stored context is restored when the thread is
     
    107111         */
    108112        context_t sleep_interruption_context;
    109 
     113       
    110114        /** If true, the thread can be interrupted from sleep. */
    111115        bool sleep_interruptible;
     
    115119        timeout_t sleep_timeout;
    116120        /** Flag signalling sleep timeout in progress. */
    117         volatile int timeout_pending;
    118 
     121        volatile bool timeout_pending;
     122       
    119123        /**
    120124         * True if this thread is executing copy_from_uspace().
     
    132136         * thread_exit() before returning to userspace.
    133137         */
    134         bool interrupted;                       
     138        bool interrupted;
    135139       
    136140        /** If true, thread_join_timeout() cannot be used on this thread. */
     
    140144        /** Link used in the joiner_head list. */
    141145        link_t joiner_link;
    142 
     146       
    143147        fpu_context_t *saved_fpu_context;
    144148        int fpu_context_exists;
    145 
     149       
    146150        /*
    147151         * Defined only if thread doesn't run.
     
    150154         */
    151155        int fpu_context_engaged;
    152 
     156       
    153157        rwlock_type_t rwlock_holder_type;
    154 
     158       
    155159        /** Callback fired in scheduler before the thread is put asleep. */
    156160        void (* call_me)(void *);
    157161        /** Argument passed to call_me(). */
    158162        void *call_me_with;
    159 
     163       
    160164        /** Thread's state. */
    161165        state_t state;
    162166        /** Thread's flags. */
    163         int flags;
     167        unsigned int flags;
    164168       
    165169        /** Thread's CPU. */
     
    167171        /** Containing task. */
    168172        task_t *task;
    169 
     173       
    170174        /** Ticks before preemption. */
    171175        uint64_t ticks;
     
    176180        /** Last sampled cycle. */
    177181        uint64_t last_cycle;
    178         /** Thread doesn't affect accumulated accounting. */   
     182        /** Thread doesn't affect accumulated accounting. */
    179183        bool uncounted;
    180 
     184       
    181185        /** Thread's priority. Implemented as index to CPU->rq */
    182186        int priority;
     
    186190        /** Architecture-specific data. */
    187191        thread_arch_t arch;
    188 
     192       
    189193        /** Thread's kernel stack. */
    190194        uint8_t *kstack;
    191 
     195       
    192196#ifdef CONFIG_UDEBUG
    193197        /** Debugging stuff */
    194198        udebug_thread_t udebug;
    195 #endif
    196 
     199#endif /* CONFIG_UDEBUG */
    197200} thread_t;
    198201
     
    203206 *
    204207 */
    205 SPINLOCK_EXTERN(threads_lock);
     208IRQ_SPINLOCK_EXTERN(threads_lock);
    206209
    207210/** AVL tree containing all threads. */
     
    209212
    210213extern void thread_init(void);
    211 extern thread_t *thread_create(void (*)(void *), void *, task_t *, int,
    212     const char *, bool);
     214extern thread_t *thread_create(void (*)(void *), void *, task_t *,
     215    unsigned int, const char *, bool);
    213216extern void thread_attach(thread_t *, task_t *);
    214217extern void thread_ready(thread_t *);
     
    218221extern void thread_create_arch(thread_t *);
    219222#endif
     223
    220224#ifndef thr_constructor_arch
    221225extern void thr_constructor_arch(thread_t *);
    222226#endif
     227
    223228#ifndef thr_destructor_arch
    224229extern void thr_destructor_arch(thread_t *);
     
    230235#define thread_join(t) \
    231236        thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    232 extern int thread_join_timeout(thread_t *, uint32_t, int);
     237
     238extern int thread_join_timeout(thread_t *, uint32_t, unsigned int);
    233239extern void thread_detach(thread_t *);
    234240
    235241extern void thread_register_call_me(void (*)(void *), void *);
    236242extern void thread_print_list(void);
    237 extern void thread_destroy(thread_t *);
     243extern void thread_destroy(thread_t *, bool);
    238244extern thread_t *thread_find_by_id(thread_id_t);
    239245extern void thread_update_accounting(bool);
Note: See TracChangeset for help on using the changeset viewer.