Changeset 91a8f83 in mainline
- Timestamp:
- 2018-10-31T18:15:56Z (6 years ago)
- Children:
- 071cb36
- Parents:
- 482f968
- Location:
- kernel
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/abs32le/include/arch/asm.h
r482f968 r91a8f83 192 192 /* 193 193 * On real hardware this returns the address of the bottom 194 * of the current CPU stack. The the_t structure is stored194 * of the current CPU stack. The current_t structure is stored 195 195 * on the bottom of stack and this is used to identify the 196 196 * current CPU, current task, current thread and current -
kernel/generic/include/arch.h
r482f968 r91a8f83 40 40 41 41 /* 42 * THE is not an abbreviation, but the English definite article written in 43 * capital letters. It means the current pointer to something, e.g. thread, 44 * processor or address space. Kind reader of this comment shall appreciate 45 * the wit of constructs like THE->thread and similar. 42 * The context pointer. The current_t structure holds pointers to various parts 43 * of the current execution context, like running task, thread, address space, 44 * etc. 46 45 */ 47 #define THE ((the_t * )(get_stack_base()))46 #define CURRENT ((current_t * )(get_stack_base())) 48 47 49 48 #define MAGIC UINT32_C(0xfacefeed) … … 53 52 #define DEFAULT_CONTAINER 0 54 53 #define CONTAINER \ 55 (( THE->task) ? (THE->task->container) : (DEFAULT_CONTAINER))54 ((CURRENT->task) ? (CURRENT->task->container) : (DEFAULT_CONTAINER)) 56 55 57 56 /* Fwd decl. to avoid include hell. */ … … 76 75 struct as *as; /**< Current address space. */ 77 76 uint32_t magic; /**< Magic value */ 78 } the_t;77 } current_t; 79 78 80 79 typedef struct { … … 96 95 #define ARCH_OP(op) ARCH_STRUCT_OP(arch_ops, op) 97 96 98 extern void the_initialize(the_t *);99 extern void the_copy(the_t *, the_t *);97 extern void current_initialize(current_t *); 98 extern void current_copy(current_t *, current_t *); 100 99 101 100 extern void calibrate_delay_loop(void); -
kernel/generic/include/cpu.h
r482f968 r91a8f83 45 45 #include <arch.h> 46 46 47 #define CPU THE->cpu47 #define CPU CURRENT->cpu 48 48 49 49 /** CPU structure. -
kernel/generic/include/mm/as.h
r482f968 r91a8f83 50 50 #include <lib/refcount.h> 51 51 52 #define AS THE->as52 #define AS CURRENT->as 53 53 54 54 /** -
kernel/generic/include/preemption.h
r482f968 r91a8f83 41 41 42 42 #define PREEMPTION_INC (1 << 0) 43 #define PREEMPTION_DISABLED (PREEMPTION_INC <= THE->preemption)43 #define PREEMPTION_DISABLED (PREEMPTION_INC <= CURRENT->preemption) 44 44 #define PREEMPTION_ENABLED (!PREEMPTION_DISABLED) 45 45 … … 47 47 #define preemption_disable() \ 48 48 do { \ 49 THE->preemption += PREEMPTION_INC; \49 CURRENT->preemption += PREEMPTION_INC; \ 50 50 compiler_barrier(); \ 51 51 } while (0) … … 56 56 assert(PREEMPTION_DISABLED); \ 57 57 compiler_barrier(); \ 58 THE->preemption -= PREEMPTION_INC; \58 CURRENT->preemption -= PREEMPTION_INC; \ 59 59 } while (0) 60 60 -
kernel/generic/include/proc/task.h
r482f968 r91a8f83 63 63 #include <cap/cap.h> 64 64 65 #define TASK THE->task65 #define TASK CURRENT->task 66 66 67 67 struct thread; -
kernel/generic/include/proc/thread.h
r482f968 r91a8f83 52 52 #include <arch.h> 53 53 54 #define THREAD THE->thread54 #define THREAD CURRENT->thread 55 55 56 56 #define THREAD_NAME_BUFLEN 20 -
kernel/generic/include/synch/rcu.h
r482f968 r91a8f83 132 132 static inline void rcu_read_lock(void) 133 133 { 134 THE->rcu_nesting += RCU_CNT_INC;134 CURRENT->rcu_nesting += RCU_CNT_INC; 135 135 compiler_barrier(); 136 136 } … … 140 140 { 141 141 compiler_barrier(); 142 THE->rcu_nesting -= RCU_CNT_INC;143 144 if (RCU_WAS_PREEMPTED == THE->rcu_nesting) {142 CURRENT->rcu_nesting -= RCU_CNT_INC; 143 144 if (RCU_WAS_PREEMPTED == CURRENT->rcu_nesting) { 145 145 _rcu_preempted_unlock(); 146 146 } -
kernel/generic/include/time/timeout.h
r482f968 r91a8f83 45 45 IRQ_SPINLOCK_DECLARE(lock); 46 46 47 /** Link to the list of active timeouts on THE->cpu */47 /** Link to the list of active timeouts on CURRENT->cpu */ 48 48 link_t link; 49 49 /** Timeout will be activated in this amount of clock() ticks. */ -
kernel/generic/src/debug/panic.c
r482f968 r91a8f83 94 94 printf("\n"); 95 95 96 printf(" THE=%p: ", THE);97 if ( THE!= NULL) {96 printf("CURRENT=%p: ", CURRENT); 97 if (CURRENT != NULL) { 98 98 printf("pe=%" PRIuPTR " thread=%p task=%p cpu=%p as=%p" 99 " magic=%#" PRIx32 "\n", THE->preemption,100 THE->thread, THE->task, THE->cpu, THE->as, THE->magic);99 " magic=%#" PRIx32 "\n", CURRENT->preemption, 100 CURRENT->thread, CURRENT->task, CURRENT->cpu, CURRENT->as, CURRENT->magic); 101 101 102 if ( THE->thread != NULL)103 printf("thread=\"%s\"\n", THE->thread->name);102 if (CURRENT->thread != NULL) 103 printf("thread=\"%s\"\n", CURRENT->thread->name); 104 104 105 if ( THE->task != NULL)106 printf("task=\"%s\"\n", THE->task->name);105 if (CURRENT->task != NULL) 106 printf("task=\"%s\"\n", CURRENT->task->name); 107 107 } else 108 108 printf("invalid\n"); -
kernel/generic/src/main/main.c
r482f968 r91a8f83 213 213 { 214 214 /* Keep this the first thing. */ 215 the_initialize(THE);215 current_initialize(CURRENT); 216 216 217 217 version_print(); … … 342 342 343 343 /* 344 * The THEstructure is well defined because ctx.sp is used as stack.345 */ 346 the_initialize(THE);344 * The CURRENT structure is well defined because ctx.sp is used as stack. 345 */ 346 current_initialize(CURRENT); 347 347 348 348 ARCH_OP(pre_mm_init); … … 356 356 ARCH_OP(post_cpu_init); 357 357 358 the_copy(THE, (the_t *) CPU->stack);358 current_copy(CURRENT, (current_t *) CPU->stack); 359 359 360 360 /* -
kernel/generic/src/proc/scheduler.c
r482f968 r91a8f83 363 363 364 364 /* 365 * Through the ' THE' structure, we keep track of THREAD, TASK, CPU, AS366 * and preemption counter. At this point THEcould be coming either365 * Through the 'CURRENT' structure, we keep track of THREAD, TASK, CPU, AS 366 * and preemption counter. At this point CURRENT could be coming either 367 367 * from THREAD's or CPU's stack. 368 368 * 369 369 */ 370 the_copy(THE, (the_t *) CPU->stack);370 current_copy(CURRENT, (current_t *) CPU->stack); 371 371 372 372 /* … … 548 548 * thread's stack. 549 549 */ 550 the_copy(THE, (the_t *) THREAD->kstack);550 current_copy(CURRENT, (current_t *) THREAD->kstack); 551 551 552 552 context_restore(&THREAD->saved_context); -
kernel/generic/src/proc/the.c
r482f968 r91a8f83 33 33 /** 34 34 * @file 35 * @brief THEstructure functions.35 * @brief CURRENT structure functions. 36 36 * 37 * This file contains functions to manage the THEstructure.38 * The THEstructure exists at the base address of every kernel37 * This file contains functions to manage the CURRENT structure. 38 * The CURRENT structure exists at the base address of every kernel 39 39 * stack and carries information about current settings 40 40 * (e.g. current CPU, current thread, task and address space … … 45 45 #include <assert.h> 46 46 47 /** Initialize THEstructure47 /** Initialize CURRENT structure 48 48 * 49 * Initialize THEstructure passed as argument.49 * Initialize CURRENT structure passed as argument. 50 50 * 51 * @param the THEstructure to be initialized.51 * @param the CURRENT structure to be initialized. 52 52 * 53 53 */ 54 void the_initialize(the_t *the)54 void current_initialize(current_t *the) 55 55 { 56 56 the->preemption = 0; … … 65 65 } 66 66 67 /** Copy THEstructure67 /** Copy CURRENT structure 68 68 * 69 * Copy the source THE structure to the destination THEstructure.69 * Copy the source CURRENT structure to the destination CURRENT structure. 70 70 * 71 * @param src The source THEstructure.72 * @param dst The destination THEstructure.71 * @param src The source CURRENT structure. 72 * @param dst The destination CURRENT structure. 73 73 * 74 74 */ 75 NO_TRACE void the_copy(the_t *src, the_t *dst)75 NO_TRACE void current_copy(current_t *src, current_t *dst) 76 76 { 77 77 assert(src->magic == MAGIC); -
kernel/generic/src/proc/thread.c
r482f968 r91a8f83 356 356 (uintptr_t) thread->kstack, STACK_SIZE); 357 357 358 the_initialize((the_t *) thread->kstack);358 current_initialize((current_t *) thread->kstack); 359 359 360 360 ipl_t ipl = interrupts_disable(); -
kernel/generic/src/synch/rcu.c
r482f968 r91a8f83 1026 1026 cpu_mask_t *reader_cpus = (cpu_mask_t *)arg; 1027 1027 1028 bool locked = RCU_CNT_INC <= THE->rcu_nesting;1028 bool locked = RCU_CNT_INC <= CURRENT->rcu_nesting; 1029 1029 /* smp_call machinery makes the most current _rcu_cur_gp visible. */ 1030 1030 bool passed_qs = (CPU->rcu.last_seen_gp == _rcu_cur_gp); … … 1054 1054 * with a local copy. 1055 1055 */ 1056 size_t nesting_cnt = local_atomic_exchange(& THE->rcu_nesting, 0);1056 size_t nesting_cnt = local_atomic_exchange(&CURRENT->rcu_nesting, 0); 1057 1057 1058 1058 /* … … 1113 1113 1114 1114 /* Load the thread's saved nesting count from before it was preempted. */ 1115 THE->rcu_nesting = THREAD->rcu.nesting_cnt;1115 CURRENT->rcu_nesting = THREAD->rcu.nesting_cnt; 1116 1116 } 1117 1117 … … 1123 1123 void rcu_thread_exiting(void) 1124 1124 { 1125 assert( THE->rcu_nesting == 0);1125 assert(CURRENT->rcu_nesting == 0); 1126 1126 1127 1127 /* … … 1145 1145 bool rcu_read_locked(void) 1146 1146 { 1147 return RCU_CNT_INC <= THE->rcu_nesting;1147 return RCU_CNT_INC <= CURRENT->rcu_nesting; 1148 1148 } 1149 1149 … … 1151 1151 void _rcu_preempted_unlock(void) 1152 1152 { 1153 assert(0 == THE->rcu_nesting || RCU_WAS_PREEMPTED == THE->rcu_nesting);1154 1155 size_t prev = local_atomic_exchange(& THE->rcu_nesting, 0);1153 assert(0 == CURRENT->rcu_nesting || RCU_WAS_PREEMPTED == CURRENT->rcu_nesting); 1154 1155 size_t prev = local_atomic_exchange(&CURRENT->rcu_nesting, 0); 1156 1156 if (prev == RCU_WAS_PREEMPTED) { 1157 1157 /*
Note:
See TracChangeset
for help on using the changeset viewer.