Changeset 46c20c8 in mainline for kernel/generic/include/proc/thread.h
- Timestamp:
- 2010-11-26T20:08:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45df59a
- Parents:
- fb150d78 (diff), ffdd2b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
kernel/generic/include/proc/thread.h (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/thread.h
rfb150d78 r46c20c8 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> … … 48 47 #include <proc/uarg.h> 49 48 #include <udebug/udebug.h> 50 51 #define THREAD_STACK_SIZE STACK_SIZE 52 #define THREAD_NAME_BUFLEN 20 53 54 extern char *thread_states[]; 49 #include <sysinfo/abi.h> 50 51 #define THREAD_STACK_SIZE STACK_SIZE 52 #define THREAD_NAME_BUFLEN 20 53 54 extern const char *thread_states[]; 55 55 56 56 /* Thread flags */ … … 60 60 * When using this flag, the caller must set cpu in the thread_t 61 61 * structure manually before calling thread_ready (even on uniprocessor). 62 */ 63 #define THREAD_FLAG_WIRED (1 << 0) 62 * 63 */ 64 #define THREAD_FLAG_WIRED (1 << 0) 65 64 66 /** Thread was migrated to another CPU and has not run yet. */ 65 #define THREAD_FLAG_STOLEN (1 << 1) 67 #define THREAD_FLAG_STOLEN (1 << 1) 68 66 69 /** Thread executes in userspace. */ 67 #define THREAD_FLAG_USPACE (1 << 2) 70 #define THREAD_FLAG_USPACE (1 << 2) 71 68 72 /** Thread will be attached by the caller. */ 69 #define THREAD_FLAG_NOATTACH (1 << 3) 70 71 /** Thread states. */ 72 typedef enum { 73 /** It is an error, if thread is found in this state. */ 74 Invalid, 75 /** State of a thread that is currently executing on some CPU. */ 76 Running, 77 /** Thread in this state is waiting for an event. */ 78 Sleeping, 79 /** State of threads in a run queue. */ 80 Ready, 81 /** Threads are in this state before they are first readied. */ 82 Entering, 83 /** After a thread calls thread_exit(), it is put into Exiting state. */ 84 Exiting, 85 /** Threads that were not detached but exited are Lingering. */ 86 Lingering 87 } state_t; 73 #define THREAD_FLAG_NOATTACH (1 << 3) 88 74 89 75 /** Thread structure. There is one per thread. */ 90 76 typedef struct thread { 91 link_t rq_link; /**< Run queue link. */92 link_t wq_link; /**< Wait queue link. */93 link_t th_link; /**< Links to threads within containing task. */94 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 95 81 /** Threads linkage to the threads_tree. */ 96 82 avltree_node_t threads_tree_node; … … 100 86 * Protects the whole thread structure except list links above. 101 87 */ 102 SPINLOCK_DECLARE(lock);103 88 IRQ_SPINLOCK_DECLARE(lock); 89 104 90 char name[THREAD_NAME_BUFLEN]; 105 91 106 92 /** Function implementing the thread. */ 107 93 void (* thread_code)(void *); 108 94 /** Argument passed to thread_code() function. */ 109 95 void *thread_arg; 110 96 111 97 /** 112 98 * From here, the stored context is restored when the thread is … … 124 110 */ 125 111 context_t sleep_interruption_context; 126 112 127 113 /** If true, the thread can be interrupted from sleep. */ 128 114 bool sleep_interruptible; … … 132 118 timeout_t sleep_timeout; 133 119 /** Flag signalling sleep timeout in progress. */ 134 volatile inttimeout_pending;135 120 volatile bool timeout_pending; 121 136 122 /** 137 123 * True if this thread is executing copy_from_uspace(). … … 149 135 * thread_exit() before returning to userspace. 150 136 */ 151 bool interrupted; 137 bool interrupted; 152 138 153 139 /** If true, thread_join_timeout() cannot be used on this thread. */ … … 157 143 /** Link used in the joiner_head list. */ 158 144 link_t joiner_link; 159 145 160 146 fpu_context_t *saved_fpu_context; 161 147 int fpu_context_exists; 162 148 163 149 /* 164 150 * Defined only if thread doesn't run. … … 167 153 */ 168 154 int fpu_context_engaged; 169 170 rwlock_type_t rwlock_holder_type; 171 172 /** Callback fired in scheduler before the thread is put asleep. */ 173 void (* call_me)(void *); 174 /** Argument passed to call_me(). */ 175 void *call_me_with; 176 155 177 156 /** Thread's state. */ 178 157 state_t state; 179 158 /** Thread's flags. */ 180 int flags;159 unsigned int flags; 181 160 182 161 /** Thread's CPU. */ … … 184 163 /** Containing task. */ 185 164 task_t *task; 186 165 187 166 /** Ticks before preemption. */ 188 167 uint64_t ticks; 189 168 190 169 /** Thread accounting. */ 191 uint64_t cycles; 170 uint64_t ucycles; 171 uint64_t kcycles; 192 172 /** Last sampled cycle. */ 193 173 uint64_t last_cycle; 194 /** Thread doesn't affect accumulated accounting. */ 174 /** Thread doesn't affect accumulated accounting. */ 195 175 bool uncounted; 196 176 197 177 /** Thread's priority. Implemented as index to CPU->rq */ 198 178 int priority; … … 202 182 /** Architecture-specific data. */ 203 183 thread_arch_t arch; 204 184 205 185 /** Thread's kernel stack. */ 206 186 uint8_t *kstack; 207 187 208 188 #ifdef CONFIG_UDEBUG 209 189 /** Debugging stuff */ 210 190 udebug_thread_t udebug; 211 #endif 212 191 #endif /* CONFIG_UDEBUG */ 213 192 } thread_t; 214 193 … … 219 198 * 220 199 */ 221 SPINLOCK_EXTERN(threads_lock);200 IRQ_SPINLOCK_EXTERN(threads_lock); 222 201 223 202 /** AVL tree containing all threads. */ … … 225 204 226 205 extern void thread_init(void); 227 extern thread_t *thread_create(void (*)(void *), void *, task_t *, int, char *,228 bool);206 extern thread_t *thread_create(void (*)(void *), void *, task_t *, 207 unsigned int, const char *, bool); 229 208 extern void thread_attach(thread_t *, task_t *); 230 209 extern void thread_ready(thread_t *); … … 234 213 extern void thread_create_arch(thread_t *); 235 214 #endif 215 236 216 #ifndef thr_constructor_arch 237 217 extern void thr_constructor_arch(thread_t *); 238 218 #endif 219 239 220 #ifndef thr_destructor_arch 240 221 extern void thr_destructor_arch(thread_t *); … … 246 227 #define thread_join(t) \ 247 228 thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 248 extern int thread_join_timeout(thread_t *, uint32_t, int); 229 230 extern int thread_join_timeout(thread_t *, uint32_t, unsigned int); 249 231 extern void thread_detach(thread_t *); 250 232 251 extern void thread_ register_call_me(void (*)(void *), void *);252 extern void thread_ print_list(void);253 extern void thread_destroy(thread_t *);254 extern void thread_update_accounting( void);233 extern void thread_print_list(bool); 234 extern void thread_destroy(thread_t *, bool); 235 extern thread_t *thread_find_by_id(thread_id_t); 236 extern void thread_update_accounting(bool); 255 237 extern bool thread_exists(thread_t *); 256 238
Note:
See TracChangeset
for help on using the changeset viewer.
