Ignore:
File:
1 edited

Legend:

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

    rda1bafb re1b6742  
    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  */
    65 #define THREAD_FLAG_WIRED  (1 << 0)
    66 
     63 */
     64#define THREAD_FLAG_WIRED       (1 << 0)
    6765/** Thread was migrated to another CPU and has not run yet. */
    68 #define THREAD_FLAG_STOLEN  (1 << 1)
    69 
     66#define THREAD_FLAG_STOLEN      (1 << 1)
    7067/** Thread executes in userspace. */
    71 #define THREAD_FLAG_USPACE  (1 << 2)
    72 
     68#define THREAD_FLAG_USPACE      (1 << 2)
    7369/** Thread will be attached by the caller. */
    74 #define THREAD_FLAG_NOATTACH  (1 << 3)
     70#define THREAD_FLAG_NOATTACH    (1 << 3)
    7571
    7672/** Thread structure. There is one per thread. */
    7773typedef struct thread {
    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        
     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
    8278        /** Threads linkage to the threads_tree. */
    8379        avltree_node_t threads_tree_node;
     
    8783         * Protects the whole thread structure except list links above.
    8884         */
    89         IRQ_SPINLOCK_DECLARE(lock);
    90        
     85        SPINLOCK_DECLARE(lock);
     86
    9187        char name[THREAD_NAME_BUFLEN];
    92        
     88
    9389        /** Function implementing the thread. */
    9490        void (* thread_code)(void *);
    9591        /** Argument passed to thread_code() function. */
    9692        void *thread_arg;
    97        
     93
    9894        /**
    9995         * From here, the stored context is restored when the thread is
     
    111107         */
    112108        context_t sleep_interruption_context;
    113        
     109
    114110        /** If true, the thread can be interrupted from sleep. */
    115111        bool sleep_interruptible;
     
    119115        timeout_t sleep_timeout;
    120116        /** Flag signalling sleep timeout in progress. */
    121         volatile bool timeout_pending;
    122        
     117        volatile int timeout_pending;
     118
    123119        /**
    124120         * True if this thread is executing copy_from_uspace().
     
    136132         * thread_exit() before returning to userspace.
    137133         */
    138         bool interrupted;
     134        bool interrupted;                       
    139135       
    140136        /** If true, thread_join_timeout() cannot be used on this thread. */
     
    144140        /** Link used in the joiner_head list. */
    145141        link_t joiner_link;
    146        
     142
    147143        fpu_context_t *saved_fpu_context;
    148144        int fpu_context_exists;
    149        
     145
    150146        /*
    151147         * Defined only if thread doesn't run.
     
    154150         */
    155151        int fpu_context_engaged;
    156        
     152
    157153        rwlock_type_t rwlock_holder_type;
    158        
     154
    159155        /** Callback fired in scheduler before the thread is put asleep. */
    160156        void (* call_me)(void *);
    161157        /** Argument passed to call_me(). */
    162158        void *call_me_with;
    163        
     159
    164160        /** Thread's state. */
    165161        state_t state;
    166162        /** Thread's flags. */
    167         unsigned int flags;
     163        int flags;
    168164       
    169165        /** Thread's CPU. */
     
    171167        /** Containing task. */
    172168        task_t *task;
    173        
     169
    174170        /** Ticks before preemption. */
    175171        uint64_t ticks;
     
    180176        /** Last sampled cycle. */
    181177        uint64_t last_cycle;
    182         /** Thread doesn't affect accumulated accounting. */
     178        /** Thread doesn't affect accumulated accounting. */   
    183179        bool uncounted;
    184        
     180
    185181        /** Thread's priority. Implemented as index to CPU->rq */
    186182        int priority;
     
    190186        /** Architecture-specific data. */
    191187        thread_arch_t arch;
    192        
     188
    193189        /** Thread's kernel stack. */
    194190        uint8_t *kstack;
    195        
     191
    196192#ifdef CONFIG_UDEBUG
    197193        /** Debugging stuff */
    198194        udebug_thread_t udebug;
    199 #endif /* CONFIG_UDEBUG */
     195#endif
     196
    200197} thread_t;
    201198
     
    206203 *
    207204 */
    208 IRQ_SPINLOCK_EXTERN(threads_lock);
     205SPINLOCK_EXTERN(threads_lock);
    209206
    210207/** AVL tree containing all threads. */
     
    212209
    213210extern void thread_init(void);
    214 extern thread_t *thread_create(void (*)(void *), void *, task_t *,
    215     unsigned int, const char *, bool);
     211extern thread_t *thread_create(void (*)(void *), void *, task_t *, int,
     212    const char *, bool);
    216213extern void thread_attach(thread_t *, task_t *);
    217214extern void thread_ready(thread_t *);
     
    221218extern void thread_create_arch(thread_t *);
    222219#endif
    223 
    224220#ifndef thr_constructor_arch
    225221extern void thr_constructor_arch(thread_t *);
    226222#endif
    227 
    228223#ifndef thr_destructor_arch
    229224extern void thr_destructor_arch(thread_t *);
     
    235230#define thread_join(t) \
    236231        thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    237 
    238 extern int thread_join_timeout(thread_t *, uint32_t, unsigned int);
     232extern int thread_join_timeout(thread_t *, uint32_t, int);
    239233extern void thread_detach(thread_t *);
    240234
    241235extern void thread_register_call_me(void (*)(void *), void *);
    242236extern void thread_print_list(void);
    243 extern void thread_destroy(thread_t *, bool);
     237extern void thread_destroy(thread_t *);
    244238extern thread_t *thread_find_by_id(thread_id_t);
    245239extern void thread_update_accounting(bool);
Note: See TracChangeset for help on using the changeset viewer.