Ignore:
File:
1 edited

Legend:

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

    re1b6742 ree42e43  
    4040#include <time/timeout.h>
    4141#include <cpu.h>
    42 #include <synch/rwlock.h>
    4342#include <synch/spinlock.h>
    4443#include <adt/avl.h>
     
    5049#include <sysinfo/abi.h>
    5150
    52 #define THREAD_STACK_SIZE       STACK_SIZE
    53 #define THREAD_NAME_BUFLEN      20
     51#define THREAD_STACK_SIZE   STACK_SIZE
     52#define THREAD_NAME_BUFLEN  20
    5453
    5554extern const char *thread_states[];
     
    6160 * When using this flag, the caller must set cpu in the thread_t
    6261 * structure manually before calling thread_ready (even on uniprocessor).
    63  */
    64 #define THREAD_FLAG_WIRED       (1 << 0)
     62 *
     63 */
     64#define THREAD_FLAG_WIRED  (1 << 0)
     65
    6566/** Thread was migrated to another CPU and has not run yet. */
    66 #define THREAD_FLAG_STOLEN      (1 << 1)
     67#define THREAD_FLAG_STOLEN  (1 << 1)
     68
    6769/** Thread executes in userspace. */
    68 #define THREAD_FLAG_USPACE      (1 << 2)
     70#define THREAD_FLAG_USPACE  (1 << 2)
     71
    6972/** Thread will be attached by the caller. */
    70 #define THREAD_FLAG_NOATTACH    (1 << 3)
     73#define THREAD_FLAG_NOATTACH  (1 << 3)
    7174
    7275/** Thread structure. There is one per thread. */
    7376typedef 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 
     77        link_t rq_link;  /**< Run queue link. */
     78        link_t wq_link;  /**< Wait queue link. */
     79        link_t th_link;  /**< Links to threads within containing task. */
     80       
    7881        /** Threads linkage to the threads_tree. */
    7982        avltree_node_t threads_tree_node;
     
    8386         * Protects the whole thread structure except list links above.
    8487         */
    85         SPINLOCK_DECLARE(lock);
    86 
     88        IRQ_SPINLOCK_DECLARE(lock);
     89       
    8790        char name[THREAD_NAME_BUFLEN];
    88 
     91       
    8992        /** Function implementing the thread. */
    9093        void (* thread_code)(void *);
    9194        /** Argument passed to thread_code() function. */
    9295        void *thread_arg;
    93 
     96       
    9497        /**
    9598         * From here, the stored context is restored when the thread is
     
    107110         */
    108111        context_t sleep_interruption_context;
    109 
     112       
    110113        /** If true, the thread can be interrupted from sleep. */
    111114        bool sleep_interruptible;
     
    115118        timeout_t sleep_timeout;
    116119        /** Flag signalling sleep timeout in progress. */
    117         volatile int timeout_pending;
    118 
     120        volatile bool timeout_pending;
     121       
    119122        /**
    120123         * True if this thread is executing copy_from_uspace().
     
    132135         * thread_exit() before returning to userspace.
    133136         */
    134         bool interrupted;                       
     137        bool interrupted;
    135138       
    136139        /** If true, thread_join_timeout() cannot be used on this thread. */
     
    140143        /** Link used in the joiner_head list. */
    141144        link_t joiner_link;
    142 
     145       
    143146        fpu_context_t *saved_fpu_context;
    144147        int fpu_context_exists;
    145 
     148       
    146149        /*
    147150         * Defined only if thread doesn't run.
     
    150153         */
    151154        int fpu_context_engaged;
    152 
    153         rwlock_type_t rwlock_holder_type;
    154 
    155         /** Callback fired in scheduler before the thread is put asleep. */
    156         void (* call_me)(void *);
    157         /** Argument passed to call_me(). */
    158         void *call_me_with;
    159 
     155       
    160156        /** Thread's state. */
    161157        state_t state;
    162158        /** Thread's flags. */
    163         int flags;
     159        unsigned int flags;
    164160       
    165161        /** Thread's CPU. */
     
    167163        /** Containing task. */
    168164        task_t *task;
    169 
     165       
    170166        /** Ticks before preemption. */
    171167        uint64_t ticks;
     
    176172        /** Last sampled cycle. */
    177173        uint64_t last_cycle;
    178         /** Thread doesn't affect accumulated accounting. */   
     174        /** Thread doesn't affect accumulated accounting. */
    179175        bool uncounted;
    180 
     176       
    181177        /** Thread's priority. Implemented as index to CPU->rq */
    182178        int priority;
     
    186182        /** Architecture-specific data. */
    187183        thread_arch_t arch;
    188 
     184       
    189185        /** Thread's kernel stack. */
    190186        uint8_t *kstack;
    191 
     187       
    192188#ifdef CONFIG_UDEBUG
    193189        /** Debugging stuff */
    194190        udebug_thread_t udebug;
    195 #endif
    196 
     191#endif /* CONFIG_UDEBUG */
    197192} thread_t;
    198193
     
    203198 *
    204199 */
    205 SPINLOCK_EXTERN(threads_lock);
     200IRQ_SPINLOCK_EXTERN(threads_lock);
    206201
    207202/** AVL tree containing all threads. */
     
    209204
    210205extern void thread_init(void);
    211 extern thread_t *thread_create(void (*)(void *), void *, task_t *, int,
    212     const char *, bool);
     206extern thread_t *thread_create(void (*)(void *), void *, task_t *,
     207    unsigned int, const char *, bool);
    213208extern void thread_attach(thread_t *, task_t *);
    214209extern void thread_ready(thread_t *);
     
    218213extern void thread_create_arch(thread_t *);
    219214#endif
     215
    220216#ifndef thr_constructor_arch
    221217extern void thr_constructor_arch(thread_t *);
    222218#endif
     219
    223220#ifndef thr_destructor_arch
    224221extern void thr_destructor_arch(thread_t *);
     
    230227#define thread_join(t) \
    231228        thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    232 extern int thread_join_timeout(thread_t *, uint32_t, int);
     229
     230extern int thread_join_timeout(thread_t *, uint32_t, unsigned int);
    233231extern void thread_detach(thread_t *);
    234232
    235 extern void thread_register_call_me(void (*)(void *), void *);
    236 extern void thread_print_list(void);
    237 extern void thread_destroy(thread_t *);
     233extern void thread_print_list(bool);
     234extern void thread_destroy(thread_t *, bool);
    238235extern thread_t *thread_find_by_id(thread_id_t);
    239236extern void thread_update_accounting(bool);
Note: See TracChangeset for help on using the changeset viewer.