TLS and thread_child_tid (Shimada-san)
This commit is contained in:
@@ -12,6 +12,12 @@ struct malloc_header {
|
||||
unsigned long size;
|
||||
};
|
||||
|
||||
#include <aal/lock.h>
|
||||
#define CPU_STATUS_DISABLE (0)
|
||||
#define CPU_STATUS_IDLE (1)
|
||||
#define CPU_STATUS_RUNNING (2)
|
||||
extern aal_spinlock_t cpu_status_lock;
|
||||
|
||||
struct cpu_local_var {
|
||||
/* malloc */
|
||||
struct malloc_header free_list;
|
||||
@@ -26,6 +32,9 @@ struct cpu_local_var {
|
||||
|
||||
struct syscall_params scp;
|
||||
struct ikc_scd_init_param iip;
|
||||
|
||||
int status;
|
||||
int fs;
|
||||
} __attribute__((aligned(64)));
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ struct vm_regions {
|
||||
unsigned long brk_start, brk_end;
|
||||
unsigned long map_start, map_end;
|
||||
unsigned long stack_start, stack_end;
|
||||
unsigned long tlsblock_base, tlsblock_limit;
|
||||
};
|
||||
|
||||
struct process_vm {
|
||||
@@ -45,6 +46,10 @@ struct process {
|
||||
|
||||
aal_mc_kernel_context_t ctx;
|
||||
aal_mc_user_context_t *uctx;
|
||||
|
||||
struct thread {
|
||||
int *clear_child_tid;
|
||||
} thread;
|
||||
};
|
||||
|
||||
struct process *create_process(unsigned long user_pc);
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#define dkprintf(...)
|
||||
#endif
|
||||
|
||||
extern long do_arch_prctl(unsigned long code, unsigned long address);
|
||||
|
||||
void init_process_vm(struct process_vm *vm)
|
||||
{
|
||||
aal_atomic_set(&vm->refcount, 1);
|
||||
@@ -225,6 +227,10 @@ void destroy_process(struct process *proc)
|
||||
|
||||
static void idle(void)
|
||||
{
|
||||
//unsigned int flags;
|
||||
//flags = aal_mc_spinlock_lock(&cpu_status_lock);
|
||||
cpu_local_var(status) = CPU_STATUS_IDLE;
|
||||
//aal_mc_spinlock_unlock(&cpu_status_lock, flags);
|
||||
while (1) {
|
||||
cpu_enable_interrupt();
|
||||
schedule();
|
||||
@@ -244,6 +250,7 @@ void sched_init(void)
|
||||
aal_mc_init_context(&idle_process->ctx, NULL, idle);
|
||||
|
||||
cpu_local_var(next) = idle_process;
|
||||
cpu_local_var(status) = CPU_STATUS_RUNNING;
|
||||
}
|
||||
|
||||
void schedule(void)
|
||||
@@ -270,6 +277,8 @@ void schedule(void)
|
||||
prev ? prev->pid : 0, next ? next->pid : 0);
|
||||
|
||||
aal_mc_load_page_table(next->vm->page_table);
|
||||
|
||||
do_arch_prctl(ARCH_SET_FS, next->vm->region.tlsblock_base);
|
||||
|
||||
if (prev) {
|
||||
aal_mc_switch_context(&prev->ctx, &next->ctx);
|
||||
|
||||
Reference in New Issue
Block a user