Harmonize kthread func naming

This commit is contained in:
Mathieu Maret 2020-04-24 00:12:12 +02:00
parent 59a8d3b582
commit 0c389afa8f
3 changed files with 14 additions and 14 deletions

View File

@ -7,13 +7,13 @@
static struct kthread *currentThread; static struct kthread *currentThread;
void kthread_exit(){ void kthreadExit(){
struct kthread *current = currentThread; struct kthread *current = currentThread;
struct kthread *next = selectNextKthread(); struct kthread *next = kthreadSelectNext();
if (next == current) if (next == current)
assert("cannot exit thread"); assert("cannot exit thread");
currentThread = next; currentThread = next;
cpu_context_exit_to(next->cpuState, (cpu_kstate_function_arg1_t *)deleteKthread, (uint32_t)current); cpu_context_exit_to(next->cpuState, (cpu_kstate_function_arg1_t *)kthreadDelete, (uint32_t)current);
return; return;
} }
@ -28,7 +28,7 @@ int kthreadSetup(vaddr_t mainStack, size_t mainStackSize){
return 0; return 0;
} }
struct kthread *createKthread(const char *name, cpu_kstate_function_arg1_t func, struct kthread *kthreadCreate(const char *name, cpu_kstate_function_arg1_t func,
void *args) void *args)
{ {
struct kthread *thread = (struct kthread *)malloc(sizeof(struct kthread)); struct kthread *thread = (struct kthread *)malloc(sizeof(struct kthread));
@ -48,7 +48,7 @@ struct kthread *createKthread(const char *name, cpu_kstate_function_arg1_t func,
if(cpu_kstate_init(&thread->cpuState, (cpu_kstate_function_arg1_t *)func, (vaddr_t)args, if(cpu_kstate_init(&thread->cpuState, (cpu_kstate_function_arg1_t *)func, (vaddr_t)args,
thread->stackAddr, thread->stackSize, thread->stackAddr, thread->stackSize,
(cpu_kstate_function_arg1_t *)kthread_exit, 0)) (cpu_kstate_function_arg1_t *)kthreadExit, 0))
goto free_mem; goto free_mem;
list_add_tail(currentThread, thread); list_add_tail(currentThread, thread);
@ -59,21 +59,21 @@ free_mem:
return NULL; return NULL;
} }
void deleteKthread(struct kthread *thread){ void kthreadDelete(struct kthread *thread){
list_delete(currentThread, thread); list_delete(currentThread, thread);
free((void *)thread->stackAddr); free((void *)thread->stackAddr);
free((void *)thread); free((void *)thread);
} }
struct kthread *selectNextKthread(){ struct kthread *kthreadSelectNext(){
struct kthread *nextThread = currentThread->next; struct kthread *nextThread = currentThread->next;
return nextThread; return nextThread;
} }
struct cpu_state *switchKthread(struct cpu_state *prevCpu){ struct cpu_state *switchKthread(struct cpu_state *prevCpu){
currentThread->cpuState = prevCpu; currentThread->cpuState = prevCpu;
struct kthread *nextThread = selectNextKthread(); struct kthread *nextThread = kthreadSelectNext();
printStringDetails(nextThread->name, RED, BLACK, 40, VGA_HEIGHT - 1); printStringDetails(nextThread->name, RED, BLACK, 40, VGA_HEIGHT - 1);
currentThread = nextThread; currentThread = nextThread;
return nextThread->cpuState; return nextThread->cpuState;

View File

@ -17,12 +17,12 @@ struct kthread {
int kthreadSetup(vaddr_t mainStack, size_t mainStackSize); int kthreadSetup(vaddr_t mainStack, size_t mainStackSize);
void kthread_exit(); void kthreadExit();
struct kthread *createKthread(const char *name, cpu_kstate_function_arg1_t func, struct kthread *kthreadCreate(const char *name, cpu_kstate_function_arg1_t func,
void *args); void *args);
void deleteKthread(struct kthread *thread); void kthreadDelete(struct kthread *thread);
struct kthread *selectNextKthread(); struct kthread *kthreadSelectNext();
struct cpu_state *switchKthread(struct cpu_state *prevCpu); struct cpu_state *switchKthread(struct cpu_state *prevCpu);

View File

@ -119,7 +119,7 @@ void kmain(unsigned long magic, unsigned long addr)
serialSetup(115200); serialSetup(115200);
allocInit(); allocInit();
kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1)); kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
createKthread("idle", idleThread, NULL); kthreadCreate("idle", idleThread, NULL);
irqSetRoutine(IRQ_TIMER, pit_handler); irqSetRoutine(IRQ_TIMER, pit_handler);
#ifdef RUN_TEST #ifdef RUN_TEST
run_test(); run_test();
@ -128,5 +128,5 @@ void kmain(unsigned long magic, unsigned long addr)
// There is no real caller behind this point // There is no real caller behind this point
// So finish this by ourself // So finish this by ourself
kthread_exit(); kthreadExit();
} }