Changes in kernel/generic/include/proc/thread.h [e1b6742:ee42e43] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/thread.h
re1b6742 ree42e43 40 40 #include <time/timeout.h> 41 41 #include <cpu.h> 42 #include <synch/rwlock.h>43 42 #include <synch/spinlock.h> 44 43 #include <adt/avl.h> … … 50 49 #include <sysinfo/abi.h> 51 50 52 #define THREAD_STACK_SIZE 53 #define THREAD_NAME_BUFLEN 51 #define THREAD_STACK_SIZE STACK_SIZE 52 #define THREAD_NAME_BUFLEN 20 54 53 55 54 extern const char *thread_states[]; … … 61 60 * When using this flag, the caller must set cpu in the thread_t 62 61 * 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 65 66 /** 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 67 69 /** Thread executes in userspace. */ 68 #define THREAD_FLAG_USPACE (1 << 2) 70 #define THREAD_FLAG_USPACE (1 << 2) 71 69 72 /** Thread will be attached by the caller. */ 70 #define THREAD_FLAG_NOATTACH 73 #define THREAD_FLAG_NOATTACH (1 << 3) 71 74 72 75 /** Thread structure. There is one per thread. */ 73 76 typedef struct thread { 74 link_t rq_link; 75 link_t wq_link; 76 link_t th_link; 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 78 81 /** Threads linkage to the threads_tree. */ 79 82 avltree_node_t threads_tree_node; … … 83 86 * Protects the whole thread structure except list links above. 84 87 */ 85 SPINLOCK_DECLARE(lock);86 88 IRQ_SPINLOCK_DECLARE(lock); 89 87 90 char name[THREAD_NAME_BUFLEN]; 88 91 89 92 /** Function implementing the thread. */ 90 93 void (* thread_code)(void *); 91 94 /** Argument passed to thread_code() function. */ 92 95 void *thread_arg; 93 96 94 97 /** 95 98 * From here, the stored context is restored when the thread is … … 107 110 */ 108 111 context_t sleep_interruption_context; 109 112 110 113 /** If true, the thread can be interrupted from sleep. */ 111 114 bool sleep_interruptible; … … 115 118 timeout_t sleep_timeout; 116 119 /** Flag signalling sleep timeout in progress. */ 117 volatile inttimeout_pending;118 120 volatile bool timeout_pending; 121 119 122 /** 120 123 * True if this thread is executing copy_from_uspace(). … … 132 135 * thread_exit() before returning to userspace. 133 136 */ 134 bool interrupted; 137 bool interrupted; 135 138 136 139 /** If true, thread_join_timeout() cannot be used on this thread. */ … … 140 143 /** Link used in the joiner_head list. */ 141 144 link_t joiner_link; 142 145 143 146 fpu_context_t *saved_fpu_context; 144 147 int fpu_context_exists; 145 148 146 149 /* 147 150 * Defined only if thread doesn't run. … … 150 153 */ 151 154 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 160 156 /** Thread's state. */ 161 157 state_t state; 162 158 /** Thread's flags. */ 163 int flags;159 unsigned int flags; 164 160 165 161 /** Thread's CPU. */ … … 167 163 /** Containing task. */ 168 164 task_t *task; 169 165 170 166 /** Ticks before preemption. */ 171 167 uint64_t ticks; … … 176 172 /** Last sampled cycle. */ 177 173 uint64_t last_cycle; 178 /** Thread doesn't affect accumulated accounting. */ 174 /** Thread doesn't affect accumulated accounting. */ 179 175 bool uncounted; 180 176 181 177 /** Thread's priority. Implemented as index to CPU->rq */ 182 178 int priority; … … 186 182 /** Architecture-specific data. */ 187 183 thread_arch_t arch; 188 184 189 185 /** Thread's kernel stack. */ 190 186 uint8_t *kstack; 191 187 192 188 #ifdef CONFIG_UDEBUG 193 189 /** Debugging stuff */ 194 190 udebug_thread_t udebug; 195 #endif 196 191 #endif /* CONFIG_UDEBUG */ 197 192 } thread_t; 198 193 … … 203 198 * 204 199 */ 205 SPINLOCK_EXTERN(threads_lock);200 IRQ_SPINLOCK_EXTERN(threads_lock); 206 201 207 202 /** AVL tree containing all threads. */ … … 209 204 210 205 extern void thread_init(void); 211 extern thread_t *thread_create(void (*)(void *), void *, task_t *, int,212 const char *, bool);206 extern thread_t *thread_create(void (*)(void *), void *, task_t *, 207 unsigned int, const char *, bool); 213 208 extern void thread_attach(thread_t *, task_t *); 214 209 extern void thread_ready(thread_t *); … … 218 213 extern void thread_create_arch(thread_t *); 219 214 #endif 215 220 216 #ifndef thr_constructor_arch 221 217 extern void thr_constructor_arch(thread_t *); 222 218 #endif 219 223 220 #ifndef thr_destructor_arch 224 221 extern void thr_destructor_arch(thread_t *); … … 230 227 #define thread_join(t) \ 231 228 thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 232 extern int thread_join_timeout(thread_t *, uint32_t, int); 229 230 extern int thread_join_timeout(thread_t *, uint32_t, unsigned int); 233 231 extern void thread_detach(thread_t *); 234 232 235 extern void thread_register_call_me(void (*)(void *), void *); 236 extern void thread_print_list(void); 237 extern void thread_destroy(thread_t *); 233 extern void thread_print_list(bool); 234 extern void thread_destroy(thread_t *, bool); 238 235 extern thread_t *thread_find_by_id(thread_id_t); 239 236 extern void thread_update_accounting(bool);
Note:
See TracChangeset
for help on using the changeset viewer.