so far my kernel is multi-tasking.
I am busy trying to implement multi threading into my kernel and i am having trouble understanding how to switch between tasks and then threads the task owns.
ive really hit a massive wall on this.
ive read through a few examples and this is what i think it is so far.
instead of switching between tasks using the timer you switch between threads.?
the user themselfs cause the task switching?
can anyone please explain this just in basic english for me please.
Multi threading
cheers.
ive been workin on this bit of code, its not all there as i just wanted to show the bit i was working on.
this should switch the to task the thread belongs to when the thread is switch
typedef struct
{
thread_t *thread;
int timeslice;
struct dispatch_t *previous;
struct dispatch_t *next;
} dispatch_t;
typedef struct
{
int id;
struct process_t *parent;
tss_t *tss;
struct thread_t *previous;
struct thread_t *next;
} thread_t;
typedef struct
{
int id;
bool state;
char name[PROCESS_NAME_LENGTH];
spinlock_t lock;
thread_t *thread_list;
struct process_t *previous;
struct process_t *next;
} process_t;
thread_t *dispatch_current_thread = NULL;
process_t *dispatch_current_process = NULL;
static dispatch_t *dispatch_current = NULL;
in schedualer handler
/* Go go the next task. */
dispatch_current = (dispatch_t *) dispatch_current->next;
dispatch_current_thread = dispatch_current->thread;
dispatch_current_process = (process_t *) dispatch_current->thread->parent;
is this correct??
ive been workin on this bit of code, its not all there as i just wanted to show the bit i was working on.
this should switch the to task the thread belongs to when the thread is switch
typedef struct
{
thread_t *thread;
int timeslice;
struct dispatch_t *previous;
struct dispatch_t *next;
} dispatch_t;
typedef struct
{
int id;
struct process_t *parent;
tss_t *tss;
struct thread_t *previous;
struct thread_t *next;
} thread_t;
typedef struct
{
int id;
bool state;
char name[PROCESS_NAME_LENGTH];
spinlock_t lock;
thread_t *thread_list;
struct process_t *previous;
struct process_t *next;
} process_t;
thread_t *dispatch_current_thread = NULL;
process_t *dispatch_current_process = NULL;
static dispatch_t *dispatch_current = NULL;
in schedualer handler
/* Go go the next task. */
dispatch_current = (dispatch_t *) dispatch_current->next;
dispatch_current_thread = dispatch_current->thread;
dispatch_current_process = (process_t *) dispatch_current->thread->parent;
is this correct??