Questions about kernel multitasking
Posted: Mon Apr 27, 2020 5:49 pm
Hi.
I want to implement multitasking in my core. To do this, I took the code from this article.
And I have some questions about the code in this article and so on.
There are 2 lines in the createTask() function that I don't understand
What does the first line do? What is pagedir?
What does the second line do? As far as I understand, this is a thread stack.
How can I release a dedicated page when I don't need it? When do I call free to release a selected page(allocPage() as far as I understand allocates one page of memory)?
Explain how this code works.
I'm also wondering how I can automatically switch between threads, maybe use timers or something like that.
The article says that this is not quite "correct" multitasking, what should I use for my tasks?
Thanks.
I want to implement multitasking in my core. To do this, I took the code from this article.
And I have some questions about the code in this article and so on.
There are 2 lines in the createTask() function that I don't understand
Code: Select all
task->regs.cr3 = (uint32_t) pagedir;
task->regs.esp = (uint32_t) allocPage() + 0x1000;
What does the second line do? As far as I understand, this is a thread stack.
How can I release a dedicated page when I don't need it? When do I call free to release a selected page(allocPage() as far as I understand allocates one page of memory)?
Explain how this code works.
I'm also wondering how I can automatically switch between threads, maybe use timers or something like that.
The article says that this is not quite "correct" multitasking, what should I use for my tasks?
Thanks.