Subversion Repositories HelenOS-historic

Compare Revisions

Regard whitespace Rev 905 → Rev 906

/kernel/trunk/generic/include/fpu_context.h
33,9 → 33,13
#include <arch/fpu_context.h>
#include <typedefs.h>
 
#if defined(CONFIG_FPU_LAZY) && !defined(ARCH_HAS_FPU)
# error "CONFIG_FPU_LAZY defined, but no ARCH_HAS_FPU"
#endif
 
extern void fpu_context_save(fpu_context_t *);
extern void fpu_context_restore(fpu_context_t *);
extern void fpu_init(fpu_context_t *);
extern void fpu_init(void);
extern void fpu_enable(void);
extern void fpu_disable(void);
 
/kernel/trunk/generic/include/proc/thread.h
39,6 → 39,7
#include <synch/rwlock.h>
#include <config.h>
#include <adt/list.h>
#include <mm/slab.h>
 
#define THREAD_STACK_SIZE STACK_SIZE
 
82,7 → 83,7
timeout_t sleep_timeout; /**< Timeout used for timeoutable sleeping. */
volatile int timeout_pending; /**< Flag signalling sleep timeout in progress. */
 
fpu_context_t saved_fpu_context;
fpu_context_t *saved_fpu_context;
int fpu_context_exists;
 
/*
135,4 → 136,8
extern void thread_print_list(void);
extern void thread_destroy(thread_t *t);
 
 
/* Fpu context slab cache */
extern slab_cache_t *fpu_context_slab;
 
#endif
/kernel/trunk/generic/src/proc/scheduler.c
71,9 → 71,9
#else
fpu_enable();
if (THREAD->fpu_context_exists)
fpu_context_restore(&(THREAD->saved_fpu_context));
fpu_context_restore(THREAD->saved_fpu_context);
else {
fpu_init(&(THREAD->saved_fpu_context));
fpu_init();
THREAD->fpu_context_exists=1;
}
#endif
102,7 → 102,7
/* Save old context */
if (CPU->fpu_owner != NULL) {
spinlock_lock(&CPU->fpu_owner->lock);
fpu_context_save(&CPU->fpu_owner->saved_fpu_context);
fpu_context_save(CPU->fpu_owner->saved_fpu_context);
/* don't prevent migration */
CPU->fpu_owner->fpu_context_engaged=0;
spinlock_unlock(&CPU->fpu_owner->lock);
110,9 → 110,17
 
spinlock_lock(&THREAD->lock);
if (THREAD->fpu_context_exists) {
fpu_context_restore(&THREAD->saved_fpu_context);
fpu_context_restore(THREAD->saved_fpu_context);
} else {
fpu_init(&(THREAD->saved_fpu_context));
/* Allocate FPU context */
if (!THREAD->saved_fpu_context) {
/* Might sleep */
spinlock_unlock(&THREAD->lock);
THREAD->saved_fpu_context = slab_alloc(fpu_context_slab,
0);
spinlock_lock(&THREAD->lock);
}
fpu_init();
THREAD->fpu_context_exists=1;
}
CPU->fpu_owner=THREAD;
275,7 → 283,7
if (THREAD) {
spinlock_lock(&THREAD->lock);
#ifndef CONFIG_FPU_LAZY
fpu_context_save(&(THREAD->saved_fpu_context));
fpu_context_save(THREAD->saved_fpu_context);
#endif
if (!context_save(&THREAD->saved_context)) {
/*
/kernel/trunk/generic/src/proc/thread.c
63,6 → 63,9
__u32 last_tid = 0;
 
static slab_cache_t *thread_slab;
#ifdef ARCH_HAS_FPU
slab_cache_t *fpu_context_slab;
#endif
 
 
/** Thread wrapper
103,9 → 106,24
link_initialize(&t->th_link);
link_initialize(&t->threads_link);
#ifdef ARCH_HAS_FPU
# ifdef CONFIG_FPU_LAZY
t->saved_fpu_context = NULL;
# else
t->saved_fpu_context = slab_alloc(fpu_context_slab,kmflags);
if (!t->saved_fpu_context)
return -1;
# endif
#endif
 
pfn = frame_alloc_rc(ONE_FRAME, FRAME_KA | kmflags,&status);
if (status)
if (status) {
#ifdef ARCH_HAS_FPU
if (t->saved_fpu_context)
slab_free(fpu_context_slab,t->saved_fpu_context);
#endif
return -1;
}
t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn));
 
return 0;
117,6 → 135,10
thread_t *t = (thread_t *)obj;
 
frame_free(ADDR2PFN(KA2PA(t->kstack)));
#ifdef ARCH_HAS_FPU
if (t->saved_fpu_context)
slab_free(fpu_context_slab,t->saved_fpu_context);
#endif
return 1; /* One page freed */
}
 
132,6 → 154,12
thread_slab = slab_cache_create("thread_slab",
sizeof(thread_t),0,
thr_constructor, thr_destructor, 0);
#ifdef ARCH_HAS_FPU
fpu_context_slab = slab_cache_create("fpu_slab",
sizeof(fpu_context_t),
FPU_CONTEXT_ALIGN,
NULL, NULL, 0);
#endif
}