Rename some stuff - cleanup
This commit is contained in:
parent
13946b1758
commit
fd0ca6f617
@ -10,7 +10,7 @@
|
||||
|
||||
void thread_function()
|
||||
{
|
||||
int thread_id = get_tid();
|
||||
int thread_id = current_thread()->tid;
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
@ -32,6 +32,6 @@ struct thread_stack
|
||||
|
||||
struct thread *new_thread(void (*function)(void));
|
||||
void yield();
|
||||
int get_tid();
|
||||
struct thread *current_thread();
|
||||
|
||||
void swtch(void *, void *);
|
||||
void switch_stack(void *old_ptr, void *new_ptr);
|
||||
|
@ -1,8 +1,8 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.global swtch
|
||||
.global switch_stack
|
||||
|
||||
swtch:
|
||||
switch_stack:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
push r15
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <thread.h>
|
||||
#include <scheduler.h>
|
||||
|
||||
struct thread dummy;
|
||||
struct thread boot_thread;
|
||||
struct thread *_current_thread = 0;
|
||||
|
||||
uint64_t next_tid = 1;
|
||||
@ -11,6 +11,7 @@ struct thread *new_thread(void (*function)(void))
|
||||
struct thread *th = &stk->tcb;
|
||||
|
||||
th->tid = next_tid++;
|
||||
|
||||
stk->RBP = (uint64_t)&stk->RBP2;
|
||||
stk->ret = (uint64_t)function;
|
||||
th->stack_ptr = (uint64_t)&stk->RBP;
|
||||
@ -31,7 +32,7 @@ void set_current_thread(struct thread *th)
|
||||
void switch_thread(struct thread *old, struct thread *new)
|
||||
{
|
||||
set_current_thread(new);
|
||||
swtch(&old->stack_ptr, &new->stack_ptr);
|
||||
switch_stack(&old->stack_ptr, &new->stack_ptr);
|
||||
}
|
||||
|
||||
void yield()
|
||||
@ -42,13 +43,8 @@ void yield()
|
||||
if(old)
|
||||
ready(old);
|
||||
else
|
||||
old = &dummy;
|
||||
old = &boot_thread;
|
||||
while(!(new = scheduler_next()));
|
||||
|
||||
switch_thread(old, new);
|
||||
}
|
||||
|
||||
int get_tid()
|
||||
{
|
||||
return current_thread()->tid;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user