Page 1 of 2

Multitasking Issues

Posted: Tue Aug 30, 2016 6:32 am
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;

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:00 am
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>   

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:04 am
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.

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:13 am
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()

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:14 am
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?

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:17 am
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?

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:37 am
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.

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:54 am
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.

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:56 am
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)

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:57 am
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.

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 7:58 am
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.

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 8:02 am
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()

Re: Multitasking Issues

Posted: Tue Aug 30, 2016 10:36 am
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

Re: Multitasking Issues

Posted: Thu Sep 08, 2016 10:05 am
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.

Re: Multitasking Issues

Posted: Thu Sep 08, 2016 10:39 am
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?