Help in Tasking
Posted: Wed Feb 10, 2016 8:46 am
I need some help in tasking stuff :/ because simply I don't understand a lot of stuff, neither cant I find it on the net :/
these are:
1. How to get the EIP of the STACK before switching the stack so that I can save it for the next cycle (scheduling)
2. How to actually Do CONTEXT switching because I tried these: Changing the Stack as well as moving the EIP to somewhere else (Because I don't know how to save the EIP location, what should I do :/ )
Also I tried initializing the STACK of every process like this :
And just saving the old stack and loading the new one by:
asm volatile("mov %%esp,%0;" ::"r"(old_task->esp));
asm volatile("mov %0,%%esp;" : "=r"(current_task->esp));
But this dosent make any effect :/ I have but the task switching function in a IRQ timer and this function just does the above thing + switching between current_task .
Help me please in implementing multitasking ( A simple multitasking, nothing else).
these are:
1. How to get the EIP of the STACK before switching the stack so that I can save it for the next cycle (scheduling)
2. How to actually Do CONTEXT switching because I tried these: Changing the Stack as well as moving the EIP to somewhere else (Because I don't know how to save the EIP location, what should I do :/ )
Also I tried initializing the STACK of every process like this :
Code: Select all
stack=kmalloc_a(4096)+4096; // ugh.. hope this works..
memset((void*)stack-4096,0,4096);
NewTask->eip=func;
// processor data
*--stack = 0x202; // EFLAGS
*--stack = 0x08; // CS
*--stack = func; // EIP
NewTask->eip=stack;
*--stack = 0; //
*--stack = 0;
// pusha
*--stack = 0; // EDI
*--stack = 0; // ESI
*--stack = 0; // EBP
*--stack = 0; // NULL
*--stack = 0; // EBX
*--stack = 0; // EDX
*--stack = 0; // ECX
*--stack = 0; // EAX
// data segments
*--stack = 0; // DS
*--stack = 0; // ES
*--stack = 0; // FS
*--stack = 0; // GS*/
NewTask->esp = stack; // Just initialize the stack :D
asm volatile("mov %%esp,%0;" ::"r"(old_task->esp));
asm volatile("mov %0,%%esp;" : "=r"(current_task->esp));
But this dosent make any effect :/ I have but the task switching function in a IRQ timer and this function just does the above thing + switching between current_task .
Help me please in implementing multitasking ( A simple multitasking, nothing else).