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