Changeset 0366d09d in mainline for kernel/generic
- Timestamp:
- 2023-02-07T16:49:43Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 78acbc72
- Parents:
- 1eaead4
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-14 14:08:42)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-07 16:49:43)
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/thread.h
r1eaead4 r0366d09d 151 151 link_t joiner_link; 152 152 153 fpu_context_t *saved_fpu_context; 153 #ifdef CONFIG_FPU 154 fpu_context_t fpu_context; 155 #endif 154 156 bool fpu_context_exists; 155 157 -
kernel/generic/src/proc/scheduler.c
r1eaead4 r0366d09d 97 97 fpu_enable(); 98 98 if (THREAD->fpu_context_exists) 99 fpu_context_restore( THREAD->saved_fpu_context);99 fpu_context_restore(&THREAD->fpu_context); 100 100 else { 101 101 fpu_init(); … … 140 140 if (CPU->fpu_owner != NULL) { 141 141 irq_spinlock_lock(&CPU->fpu_owner->lock, false); 142 fpu_context_save( CPU->fpu_owner->saved_fpu_context);142 fpu_context_save(&CPU->fpu_owner->fpu_context); 143 143 144 144 /* Don't prevent migration */ … … 150 150 irq_spinlock_lock(&THREAD->lock, false); 151 151 if (THREAD->fpu_context_exists) { 152 fpu_context_restore( THREAD->saved_fpu_context);152 fpu_context_restore(&THREAD->fpu_context); 153 153 } else { 154 154 fpu_init(); … … 325 325 326 326 #if (defined CONFIG_FPU) && (!defined CONFIG_FPU_LAZY) 327 fpu_context_save( THREAD->saved_fpu_context);327 fpu_context_save(&THREAD->fpu_context); 328 328 #endif 329 329 if (!context_save(&THREAD->saved_context)) { -
kernel/generic/src/proc/thread.c
r1eaead4 r0366d09d 102 102 static slab_cache_t *thread_cache; 103 103 104 #ifdef CONFIG_FPU105 slab_cache_t *fpu_context_cache;106 #endif107 108 104 static void *threads_getkey(odlink_t *); 109 105 static int threads_cmp(void *, void *); … … 164 160 /* call the architecture-specific part of the constructor */ 165 161 thr_constructor_arch(thread); 166 167 #ifdef CONFIG_FPU168 thread->saved_fpu_context = slab_alloc(fpu_context_cache,169 FRAME_ATOMIC | kmflags);170 if (!thread->saved_fpu_context)171 return ENOMEM;172 #endif /* CONFIG_FPU */173 162 174 163 /* … … 198 187 uintptr_t stack_phys = 199 188 frame_alloc(STACK_FRAMES, kmflags, STACK_SIZE - 1); 200 if (!stack_phys) { 201 #ifdef CONFIG_FPU 202 assert(thread->saved_fpu_context); 203 slab_free(fpu_context_cache, thread->saved_fpu_context); 204 #endif 189 if (!stack_phys) 205 190 return ENOMEM; 206 }207 191 208 192 thread->kstack = (uint8_t *) PA2KA(stack_phys); … … 225 209 frame_free(KA2PA(thread->kstack), STACK_FRAMES); 226 210 227 #ifdef CONFIG_FPU228 assert(thread->saved_fpu_context);229 slab_free(fpu_context_cache, thread->saved_fpu_context);230 #endif231 232 211 return STACK_FRAMES; /* number of frames freed */ 233 212 } … … 243 222 244 223 atomic_store(&nrdy, 0); 245 thread_cache = slab_cache_create("thread_t", sizeof(thread_t), 0,224 thread_cache = slab_cache_create("thread_t", sizeof(thread_t), _Alignof(thread_t), 246 225 thr_constructor, thr_destructor, 0); 247 248 #ifdef CONFIG_FPU249 fpu_context_cache = slab_cache_create("fpu_context_t",250 sizeof(fpu_context_t), FPU_CONTEXT_ALIGN, NULL, NULL, 0);251 #endif252 226 253 227 odict_initialize(&threads, threads_getkey, threads_cmp);
Note:
See TracChangeset
for help on using the changeset viewer.