Multitasking Issues

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Multitasking Issues

Post by Octacone »

For the past two days I am fight with the multitasking. I started working on it yesterday and I haven't progressed much. I've been getting general protection faults and triple faults.
There are there types of not working typos:
1.When I do this: ,I get nothing, multitasking initializes but no task switching.

Code: Select all

InitializeMultitasking();
		while(1)
		{
			IdleTask();
		}
2.When I do this: ,I keep getting triple faults with physical address not available

Code: Select all

while(1)
		{
			Preempt();
			//IdleTask();
		}
3.When I remove my while loop and remove preempt I get global protection fault.

I have no idea what is going on in here (I understand the concept behind it), I can seem to fix it.
I followed this wiki tutorial. I also noticed that create task method does nothing aka does not insert just created task into the loop so I added

Code: Select all

currentTask->next = task;
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Multitasking Issues

Post by Octacone »

bump?

Code: Select all

(0).[217024761] ??? (physical address not available)
Next at t=217024762
(0).[217024762] ??? (physical address not available)
<bochs:2> info tss
tr:s=0x0, base=0x0000000000000000, valid=1
bx_dbg_info_tss_command: failed to get physical address for TSS.BASE !<bochs:3>   
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Multitasking Issues

Post by BrightLight »

Don't bump your thread half an hour after it was created; getting a reply after 6-8 hours is normal for this forum.
Multitasking is something very closely tied to your kernel; you shouldn't base it off a tutorial or you'll regret it later. Do you get any exceptions before the GPF? What's the error code? You should try to debug it yourself for several days for even thinking of posting here.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Multitasking Issues

Post by Octacone »

omarrx024 wrote:Don't bump your thread half an hour after it was created; getting a reply after 6-8 hours is normal for this forum.
Multitasking is something very closely tied to your kernel; you shouldn't base it off a tutorial or you'll regret it later. Do you get any exceptions before the GPF? What's the error code? You should try to debug it yourself for several days for even thinking of posting here.
6-8 hours is a lot.
I know I shouldn't but I decided to use that one because it was round robin based. I only get GPF exception 13 that is.

Note: I only get GPF when not calling Preempt()
Last edited by Octacone on Tue Aug 30, 2016 7:14 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Multitasking Issues

Post by BrightLight »

octacone wrote:I know I shouldn't but I decided to use that one because it was round robin based. I only get GPF exception 13 that is.
GPF pushes an error code onto the stack. What is it?
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Multitasking Issues

Post by Octacone »

omarrx024 wrote:
octacone wrote:I know I shouldn't but I decided to use that one because it was round robin based. I only get GPF exception 13 that is.
GPF pushes an error code onto the stack. What is it?
Note: I only get GPF when not calling Preempt()
I don't see any error codes... Is there a way to find that error code with Bochs? Like info tss or regs?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Multitasking Issues

Post by BrightLight »

octacone wrote:I don't see any error codes... Is there a way to find that error code with Bochs? Like info tss or regs?
Maybe you should learn how the x86 exception handling works before attempting to write a scheduler. :roll:
Exceptions.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Multitasking Issues

Post by Octacone »

omarrx024 wrote:
octacone wrote:I don't see any error codes... Is there a way to find that error code with Bochs? Like info tss or regs?
Maybe you should learn how the x86 exception handling works before attempting to write a scheduler. :roll:
Exceptions.
I am an idiot. #-o #-o #-o #-o
I forgot to print the error code...
It is error code 40.
Last edited by Octacone on Tue Aug 30, 2016 7:56 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Multitasking Issues

Post by BrightLight »

OSDev Wiki wrote:Some exceptions will push a 32-bit "error code" on to the top of the stack, which provides additional information about the error. This value must be pulled from the stack before returning control back to the currently running program. (i.e. before calling IRET)
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Multitasking Issues

Post by Octacone »

omarrx024 wrote:
OSDev Wiki wrote:Some exceptions will push a 32-bit "error code" on to the top of the stack, which provides additional information about the error. This value must be pulled from the stack before returning control back to the currently running program. (i.e. before calling IRET)
Post up top. ^^ It is 40.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Multitasking Issues

Post by BrightLight »

octacone wrote:Post up top. ^^ It is 40.
OK. For today's homework: figure out what that error code means. The Exceptions wiki entry explains everything clearly.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Multitasking Issues

Post by Octacone »

omarrx024 wrote:
octacone wrote:Post up top. ^^ It is 40.
OK. For today's homework: figure out what that error code means. The Exceptions wiki entry explains everything clearly.
It doesn't really say. There are only couple of error codes but they don't match. :?:
Why is GPF an issue? It only occurs when I don't call Preempt()
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: Multitasking Issues

Post by Ch4ozz »

Where is the problem logging EIP and checking it in IDA or some other kind of disassembler?
Logging registers in QEMU for tripple faults is easy:

Code: Select all

-d cpu_reset -D qemu.log
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

Re: Multitasking Issues

Post by Ycep »

Slow down runner! You go to multitasking without having any filesystem, ELF/PE executer nor memory manager!
That multitasking on wiki almost isn't multitasking at all. It only switches registers and task when one task finishes it task. Multitasking is more like, for example giving one high priority task 800ms (so called 80% of CPU) and 200ms (20%) to low priority tasks, and breaking them in execution if their time is done and going to next task!
"Copying and pasting code without knowing what it does..." ...is bad.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Multitasking Issues

Post by Octacone »

Lukand wrote:Slow down runner! You go to multitasking without having any filesystem, ELF/PE executer nor memory manager!
That multitasking on wiki almost isn't multitasking at all. It only switches registers and task when one task finishes it task. Multitasking is more like, for example giving one high priority task 800ms (so called 80% of CPU) and 200ms (20%) to low priority tasks, and breaking them in execution if their time is done and going to next task!
"Copying and pasting code without knowing what it does..." ...is bad.
Why did you respond to this doe? This topic is paused until I figure out some other more important stuff. Again I HAVE a working memory manager. I do NOT need an executor at the moment. No, that is a concept called priority multitasking. Multitasking is really what you want it to be. Don't worry I know what the code does (expect for couple of machine instructions), I fully understand the concept of multitasking. I think that not "syncing" the code causes this issue. (not all the parts are aware of each other) I think I will be able to figure this out in couple of weeks, as I said need to get some other things to work first.
Edit: can a file system without ability to read/write/manage files on a hard drive really be called so?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Post Reply