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