Changeset 70527f1 in mainline
- 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
- Location:
- src
- Files:
-
- 7 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 { -
src/smp/ipi.c
rac5d02b r70527f1 32 32 #include <config.h> 33 33 34 35 /** Broadcast IPI message 36 * 37 * Broadcast IPI message to all CPUs. 38 * 39 * @param ipi Message to broadcast. 40 * 41 */ 34 42 void ipi_broadcast(int ipi) 35 43 { -
src/time/clock.c
rac5d02b r70527f1 44 44 #endif 45 45 46 /* 47 * Clock is called from an interrupt and is cpu_priority_high()'d. 46 /** Clock routine 47 * 48 * Clock routine executed from clock interrupt handler 49 * (assuming cpu_priority_high()). Runs expired timeouts 50 * and preemptive scheduling. 51 * 48 52 */ 49 53 void clock(void) -
src/time/delay.c
rac5d02b r70527f1 33 33 #include <arch.h> 34 34 35 /* 36 * Note that the delay loop is calibrated for each and every CPU in the system. 37 * Therefore it is necessary to cpu_priority_high() before calling the asm_delay_loop(). 35 /** Active delay 36 * 37 * Delay the execution for the given number 38 * of microseconds (or slightly more). The delay 39 * is implemented as CPU calibrated active loop. 40 * 41 * @param microseconds Number of usec to sleep. 42 * 38 43 */ 39 44 void delay(__u32 microseconds) 40 45 { 41 46 pri_t pri; 42 47 48 /* The delay loop is calibrated for each and every 49 CPU in the system. Therefore it is necessary to 50 cpu_priority_high() before calling the asm_delay_loop(). */ 43 51 pri = cpu_priority_high(); 44 52 asm_delay_loop(microseconds * CPU->delay_loop_const); -
src/time/timeout.c
rac5d02b r70527f1 39 39 #include <arch.h> 40 40 41 42 /** Initialize timeouts 43 * 44 * Initialize kernel timeouts. 45 * 46 */ 41 47 void timeout_init(void) 42 48 { … … 46 52 47 53 54 /** Initialize empty timeout list 55 * 56 * Initialize the timeout list to be empty. 57 * 58 * @param t Timeout list to be initialized. 59 * 60 */ 48 61 void timeout_reinitialize(timeout_t *t) 49 62 { … … 55 68 } 56 69 70 71 /** Initialize timeout list 72 * 73 * Initialize the timeout list and its spinlock. 74 * 75 * @param t Timeout list to be initialized. 76 * 77 */ 57 78 void timeout_initialize(timeout_t *t) 58 79 { … … 61 82 } 62 83 63 /* 64 * This function registers f for execution in about time microseconds. 84 85 /** Register timeout callback 86 * 87 * Insert the timeout handler f (with argument arg) 88 * to the timeout list and make it execute in 89 * time microseconds (or slightly more). 90 * 91 * @param t Timeout list. 92 * @patam time Number of usec in the future to execute 93 * the handler. 94 * @param f Timeout handler function. 95 * @param arg Timeout handler argument. 96 * 65 97 */ 66 98 void timeout_register(timeout_t *t, __u64 time, timeout_handler f, void *arg) … … 122 154 } 123 155 156 157 /** Unregister timeout callback 158 * 159 * Remove timeout from timeout list. 160 * 161 * @param t Timeout to unregister. 162 * 163 */ 124 164 int timeout_unregister(timeout_t *t) 125 165 {
Note:
See TracChangeset
for help on using the changeset viewer.