Changeset 70527f1 in mainline for src/proc/thread.c
- Timestamp:
- 2005-06-03T14:51:05Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 673104e
- Parents:
- ac5d02b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/proc/thread.c
rac5d02b r70527f1 51 51 #include <arch/faddr.h> 52 52 53 char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; 53 char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; /**< Thread states */ 54 54 55 55 spinlock_t threads_lock; … … 59 59 __u32 last_tid = 0; 60 60 61 /* 62 * cushion() is provided to ensure that every thread 61 62 /** Thread wrapper 63 * 64 * This wrapper is provided to ensure that every thread 63 65 * makes a call to thread_exit() when its implementing 64 66 * function returns. 65 67 * 66 * cpu_priority_high()'d 68 * cpu_priority_high() is assumed. 69 * 67 70 */ 68 71 void cushion(void) … … 82 85 } 83 86 87 88 /** Initialize threads 89 * 90 * Initialize kernel threads support. 91 * 92 */ 84 93 void thread_init(void) 85 94 { … … 90 99 } 91 100 101 102 /** Make thread ready 103 * 104 * Switch thread t to the ready state. 105 * 106 * @param t Thread to make ready. 107 * 108 */ 92 109 void thread_ready(thread_t *t) 93 110 { … … 109 126 spinlock_unlock(&t->lock); 110 127 111 128 /* 112 129 * Append t to respective ready queue on respective processor. 113 130 */ … … 134 151 } 135 152 153 154 /** Create new thread 155 * 156 * Create a new thread. 157 * 158 * @param func Thread's implementing function. 159 * @param arg Thread's implementing function argument. 160 * @param task Task to which the thread belongs. 161 * @param flags Thread flags. 162 * 163 * @return New thread's structure on success, NULL on failure. 164 * 165 */ 136 166 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags) 137 167 { … … 214 244 } 215 245 246 247 /** Make thread exiting 248 * 249 * End current thread execution and switch it to the exiting 250 * state. All pending timeouts are executed. 251 * 252 */ 216 253 void thread_exit(void) 217 254 { … … 231 268 } 232 269 270 271 /** Thread sleep 272 * 273 * Suspend execution of the current thread. 274 * 275 * @param sec Number of seconds to sleep. 276 * 277 */ 233 278 void thread_sleep(__u32 sec) 234 279 { 235 280 thread_usleep(sec*1000000); 236 281 } 237 238 /* 239 * Suspend execution of current thread for usec microseconds. 240 */ 282 283 284 /** Thread usleep 285 * 286 * Suspend execution of the current thread. 287 * 288 * @param usec Number of microseconds to sleep. 289 * 290 */ 241 291 void thread_usleep(__u32 usec) 242 292 { … … 248 298 } 249 299 300 301 /** Register thread out-of-context invocation 302 * 303 * Register a function and its argument to be executed 304 * on next context switch to the current thread. 305 * 306 * @param call_me Out-of-context function. 307 * @param call_me_with Out-of-context function argument. 308 * 309 */ 250 310 void thread_register_call_me(void (* call_me)(void *), void *call_me_with) 251 311 {
Note:
See TracChangeset
for help on using the changeset viewer.