- Timestamp:
- 2005-06-03T14:51:05Z (21 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 673104e
- Parents:
- ac5d02b
- Location:
- src/proc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/proc/scheduler.c
rac5d02b r70527f1 57 57 volatile int nrdy; 58 58 59 60 /** Initialize context switching 61 * 62 * Initialize context switching and lazy FPU 63 * context switching. 64 * 65 */ 59 66 void before_thread_runs(void) 60 67 { … … 64 71 65 72 73 /** Initialize scheduler 74 * 75 * Initialize kernel scheduler. 76 * 77 */ 66 78 void scheduler_init(void) 67 79 { … … 69 81 } 70 82 71 /* cpu_priority_high()'d */ 83 84 /** Get thread to be scheduled 85 * 86 * Get the optimal thread to be scheduled 87 * according thread accounting and scheduler 88 * policy. 89 * 90 * @return Thread to be scheduled. 91 * 92 */ 72 93 struct thread *find_best_thread(void) 73 94 { … … 156 177 } 157 178 158 /* 159 * This function prevents low priority threads from starving in rq's. 160 * When it decides to relink rq's, it reconnects respective pointers 161 * so that in result threads with 'pri' greater or equal 'start' are 162 * moved to a higher-priority queue. 179 180 /** Prevent rq starvation 181 * 182 * Prevent low priority threads from starving in rq's. 183 * 184 * When the function decides to relink rq's, it reconnects 185 * respective pointers so that in result threads with 'pri' 186 * greater or equal 'start' are moved to a higher-priority queue. 187 * 188 * @param start Threshold priority. 189 * 163 190 */ 164 191 void relink_rq(int start) … … 193 220 } 194 221 195 /* 196 * The scheduler. 222 223 /** The scheduler 224 * 225 * The thread scheduling procedure. 226 * 197 227 */ 198 228 void scheduler(void) … … 238 268 } 239 269 270 271 /** Scheduler stack switch wrapper 272 * 273 * Second part of the scheduler() function 274 * using new stack. Handling the actual context 275 * switch to a new thread. 276 * 277 */ 240 278 void scheduler_separated_stack(void) 241 279 { … … 366 404 } 367 405 406 368 407 #ifdef __SMP__ 369 /* 370 * This is the load balancing thread. 371 * It supervises thread supplies for the CPU it's wired to. 408 /** Load balancing thread 409 * 410 * SMP load balancing thread, supervising thread supplies 411 * for the CPU it's wired to. 412 * 413 * @param arg Generic thread argument (unused). 414 * 372 415 */ 373 416 void kcpulb(void *arg) -
src/proc/task.c
rac5d02b r70527f1 40 40 link_t tasks_head; 41 41 42 43 /** Initialize tasks 44 * 45 * Initialize kernel tasks support. 46 * 47 */ 42 48 void task_init(void) 43 49 { … … 47 53 } 48 54 55 56 /** Create new task 57 * 58 * Create new task with no threads. 59 * 60 * @param m Task's virtual memory structure. 61 * 62 * @return New task's structure on success, NULL on failure. 63 * 64 */ 49 65 task_t *task_create(vm_t *m) 50 66 { -
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.
