OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 4:03 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problems following the Brendan's Multi-tasking Tutorial
PostPosted: Sat Apr 18, 2020 1:22 pm 
Offline
Member
Member

Joined: Sun Sep 16, 2018 6:46 am
Posts: 56
I just started reading the tutorial (https://wiki.osdev.org/Brendan%27s_Multi-tasking_Tutorial).
But I have not understood the following sentence:
Quote:
Once you've created an initial data structure for keeping track of a task's information; create an "initialise_multitasking()" function. The idea here (initially) is that there's already a task that has been running since boot, and you only need to create the information for it by allocating some memory for the task's information structure that you just created and setting the fields in that structure as appropriate.

Here he is talking about a structure which holds the page directory and the kernel stack top.
I have a question for both of them:
- I'm using recursive paging so as Page Directory should I use 0xFFFFF000 or the address pointed by it?
- In the case of the first process (the one running from boot) do I have to use the ESP value or I have to allocate another 4K block as the other processes?


Top
 Profile  
 
 Post subject: Re: Problems following the Brendan's Multi-tasking Tutorial
PostPosted: Sat Apr 18, 2020 3:50 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
Thpertic wrote:
- I'm using recursive paging so as Page Directory should I use 0xFFFFF000 or the address pointed by it?
Use the one that in a task switch restores the same paging you're using now (the boot task's). I believe that should be the value in CR3.
Thpertic wrote:
- In the case of the first process (the one running from boot) do I have to use the ESP value or I have to allocate another 4K block as the other processes?
I think Brendan meant the current ESP.

However I'd like to point out that Brendan's advice is not the preferred nor the only way to do multitasking. There are many kernel task switching designs which makes this whole initial task structure mess completely unnecessary. And it won't work with SMP anyway (there each core should have its own stacks, and to store different ESP you'll need as many task structures as number of cores at minimum).

For example in my kernel I use identity mapping for the boot task, and once I switch to the first real task, there's absolutely no reason to switch back to identity mapping ever again. Memory allocated during early stage in boot task is simply accounted for the idle task on the BSP. Hence my kernel doesn't need this dirty initial task hack at all that Brendan is talking about.

Cheers,
bzt


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], SemrushBot [Bot] and 225 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group