Changeset 32fffef0 in mainline for kernel/generic
- Timestamp:
- 2006-08-29T11:06:57Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0fa6044
- Parents:
- c8ea4a8b
- Location:
- kernel/generic
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/mm/frame.h
rc8ea4a8b r32fffef0 28 28 */ 29 29 30 30 /** @addtogroup genericmm 31 31 * @{ 32 32 */ … … 34 34 */ 35 35 36 #ifndef __FRAME_H__37 #define __FRAME_H__36 #ifndef KERN_FRAME_H_ 37 #define KERN_FRAME_H_ 38 38 39 39 #include <arch/types.h> … … 62 62 #define FRAME_NO_RECLAIM 0x4 /* do not start reclaiming when no free memory */ 63 63 64 #define FRAME_OK 0 /* frame_alloc return status */65 #define FRAME_NO_MEMORY 1 /* frame_alloc return status */66 #define FRAME_ERROR 2 /* frame_alloc return status */67 68 64 static inline uintptr_t PFN2ADDR(pfn_t frame) 69 65 { … … 89 85 #define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame) (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1) 90 86 91 #define frame_alloc(order, flags) 87 #define frame_alloc(order, flags) frame_alloc_generic(order, flags, NULL) 92 88 93 89 extern void frame_init(void); … … 112 108 #endif 113 109 114 110 /** @} 115 111 */ 116 -
kernel/generic/include/proc/thread.h
rc8ea4a8b r32fffef0 53 53 #define THREAD_STACK_SIZE STACK_SIZE 54 54 55 /** <Thread states. */55 /** Thread states. */ 56 56 enum state { 57 57 Invalid, /**< It is an error, if thread is found in this state. */ … … 66 66 extern char *thread_states[]; 67 67 68 /** <Join types. */68 /** Join types. */ 69 69 typedef enum { 70 70 None, … … 73 73 } thread_join_type_t; 74 74 75 #define X_WIRED (1<<0) 76 #define X_STOLEN (1<<1) 75 /* Thread flags */ 76 #define THREAD_FLAG_WIRED (1<<0) /**< Thread cannot be migrated to another CPU. */ 77 #define THREAD_FLAG_STOLEN (1<<1) /**< Thread was migrated to another CPU and has not run yet. */ 78 #define THREAD_FLAG_USPACE (1<<2) /**< Thread executes in userspace. */ 77 79 78 80 #define THREAD_NAME_BUFLEN 20 … … 128 130 * Defined only if thread doesn't run. 129 131 * It means that fpu context is in CPU that last time executes this thread. 130 * This disables migration 132 * This disables migration. 131 133 */ 132 134 int fpu_context_engaged; … … 150 152 thread_arch_t arch; /**< Architecture-specific data. */ 151 153 152 uint8_t *kstack; 154 uint8_t *kstack; /**< Thread's kernel stack. */ 153 155 }; 154 156 … … 171 173 extern void thread_create_arch(thread_t *t); 172 174 #endif 175 #ifndef thr_constructor_arch 176 extern void thr_constructor_arch(thread_t *t); 177 #endif 178 #ifndef thr_destructor_arch 179 extern void thr_destructor_arch(thread_t *t); 180 #endif 173 181 174 182 extern void thread_sleep(uint32_t sec); -
kernel/generic/src/main/kinit.c
rc8ea4a8b r32fffef0 101 101 * Just a beautification. 102 102 */ 103 if ((t = thread_create(kmp, NULL, TASK, 0, "kmp"))) {103 if ((t = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp"))) { 104 104 spinlock_lock(&t->lock); 105 t->flags |= X_WIRED;106 105 t->cpu = &cpus[0]; 107 106 spinlock_unlock(&t->lock); … … 127 126 for (i = 0; i < config.cpu_count; i++) { 128 127 129 if ((t = thread_create(kcpulb, NULL, TASK, 0, "kcpulb"))) {128 if ((t = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb"))) { 130 129 spinlock_lock(&t->lock); 131 t->flags |= X_WIRED;132 130 t->cpu = &cpus[i]; 133 131 spinlock_unlock(&t->lock); -
kernel/generic/src/mm/frame.c
rc8ea4a8b r32fffef0 929 929 * @param order Allocate exactly 2^order frames. 930 930 * @param flags Flags for host zone selection and address processing. 931 * @param status Allocation status (FRAME_OK on success), unused if NULL.932 931 * @param pzone Preferred zone 933 932 * … … 988 987 /** Free a frame. 989 988 * 990 * Find respective frame structure for supplied PFN.989 * Find respective frame structure for supplied physical frame address. 991 990 * Decrement frame reference count. 992 991 * If it drops to zero, move the frame structure to free list. -
kernel/generic/src/proc/scheduler.c
rc8ea4a8b r32fffef0 142 142 spinlock_unlock(&THREAD->lock); 143 143 spinlock_unlock(&CPU->lock); 144 THREAD->saved_fpu_context = slab_alloc(fpu_context_slab, 145 0); 144 THREAD->saved_fpu_context = slab_alloc(fpu_context_slab, 0); 146 145 /* We may have switched CPUs during slab_alloc */ 147 146 goto restart; … … 236 235 237 236 /* 238 * Clear the X_STOLEN flag so that t can be migrated when load balancing needs emerge. 237 * Clear the THREAD_FLAG_STOLEN flag so that t can be migrated 238 * when load balancing needs emerge. 239 239 */ 240 t->flags &= ~ X_STOLEN;240 t->flags &= ~THREAD_FLAG_STOLEN; 241 241 spinlock_unlock(&t->lock); 242 242 … … 350 350 */ 351 351 context_save(&CPU->saved_context); 352 context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), (uintptr_t) CPU->stack, CPU_STACK_SIZE); 352 context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), 353 (uintptr_t) CPU->stack, CPU_STACK_SIZE); 353 354 context_restore(&CPU->saved_context); 354 355 /* not reached */ … … 484 485 485 486 #ifdef SCHEDULER_VERBOSE 486 printf("cpu%d: tid %d (priority=%d,ticks=%lld,nrdy=%ld)\n", CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks, atomic_get(&CPU->nrdy)); 487 printf("cpu%d: tid %d (priority=%d,ticks=%lld,nrdy=%ld)\n", 488 CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks, atomic_get(&CPU->nrdy)); 487 489 #endif 488 490 … … 557 559 /* 558 560 * Not interested in ourselves. 559 * Doesn't require interrupt disabling for kcpulb is X_WIRED.561 * Doesn't require interrupt disabling for kcpulb has THREAD_FLAG_WIRED. 560 562 */ 561 563 if (CPU == cpu) … … 578 580 t = list_get_instance(l, thread_t, rq_link); 579 581 /* 580 * We don't want to steal CPU-wired threads neither threads already stolen. 581 * The latter prevents threads from migrating between CPU's without ever being run. 582 * We don't want to steal threads whose FPU context is still in CPU. 582 * We don't want to steal CPU-wired threads neither threads already 583 * stolen. The latter prevents threads from migrating between CPU's 584 * without ever being run. We don't want to steal threads whose FPU 585 * context is still in CPU. 583 586 */ 584 587 spinlock_lock(&t->lock); 585 if ( (!(t->flags & (X_WIRED | X_STOLEN))) && (!(t->fpu_context_engaged)) ) { 588 if ((!(t->flags & (THREAD_FLAG_WIRED | THREAD_FLAG_STOLEN))) && 589 (!(t->fpu_context_engaged)) ) { 586 590 /* 587 591 * Remove t from r. … … 609 613 spinlock_lock(&t->lock); 610 614 #ifdef KCPULB_VERBOSE 611 printf("kcpulb%d: TID %d -> cpu%d, nrdy=%ld, avg=%nd\n", CPU->id, t->tid, CPU->id, atomic_get(&CPU->nrdy), atomic_get(&nrdy) / config.cpu_active); 615 printf("kcpulb%d: TID %d -> cpu%d, nrdy=%ld, avg=%nd\n", 616 CPU->id, t->tid, CPU->id, atomic_get(&CPU->nrdy), 617 atomic_get(&nrdy) / config.cpu_active); 612 618 #endif 613 t->flags |= X_STOLEN;619 t->flags |= THREAD_FLAG_STOLEN; 614 620 t->state = Entering; 615 621 spinlock_unlock(&t->lock); -
kernel/generic/src/proc/thread.c
rc8ea4a8b r32fffef0 130 130 link_initialize(&t->wq_link); 131 131 link_initialize(&t->th_link); 132 133 /* call the architecture-specific part of the constructor */ 134 thr_constructor_arch(t); 132 135 133 136 #ifdef ARCH_HAS_FPU … … 157 160 { 158 161 thread_t *t = (thread_t *) obj; 162 163 /* call the architecture-specific part of the destructor */ 164 thr_destructor_arch(t); 159 165 160 166 frame_free(KA2PA(t->kstack)); … … 211 217 212 218 cpu = CPU; 213 if (t->flags & X_WIRED) {219 if (t->flags & THREAD_FLAG_WIRED) { 214 220 cpu = t->cpu; 215 221 } … … 296 302 if (!t) 297 303 return NULL; 298 299 thread_create_arch(t);300 304 301 305 /* Not needed, but good for debugging */ … … 324 328 t->priority = -1; /* start in rq[0] */ 325 329 t->cpu = NULL; 326 t->flags = 0;330 t->flags = flags; 327 331 t->state = Entering; 328 332 t->call_me = NULL; … … 348 352 t->fpu_context_exists = 0; 349 353 t->fpu_context_engaged = 0; 354 355 thread_create_arch(t); /* might depend on previous initialization */ 350 356 351 357 /* … … 590 596 } 591 597 592 if ((t = thread_create(uinit, kernel_uarg, TASK, 0, namebuf))) {598 if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf))) { 593 599 tid = t->tid; 594 600 thread_ready(t);
Note:
See TracChangeset
for help on using the changeset viewer.