A way to Solve the multitasking out of memory problem in Optimus Source Code

Topics: Developing Cosmos (Working on Cosmos source code directly), Using Cosmos (Developing your own OS, projects, etc)
Feb 19, 2013 at 12:51 PM
Edited Feb 19, 2013 at 12:59 PM
The Reason why the multitasking stops after a period of time in my OS is because of Iret /IretD instruction.
The Iret instructions overrides the return address of the Pit interrupt. I have tested it by puting
Console.WriteLine("Returned Correctly!") after calling xHAL.InitialiseMultitasking2() method.
If you try it you would see that it does not return from call But if you remove the Iret instruction multitasking is disabled and kernel works fine!.

One solution is to Multitasking the Kernel too.
In order words, the kernel must also be a program but with higher priveleges.

add executable Kernel - Ring 0 (infinite loop)
add executable Prog - Ring 3 (don't care)
add executable Prog2 - Ring 3 (don't care)

When you load a program using your PE loader it should return ESP to the scheduler.

__N.B: all you need to load a binary is the ATA Driver and the existing code to Create a User Task in Optimus Source
The CreateUserTask method loads the data to memory for you.__

Hope this helps!