How does task sleeping is working in practise
Posted: Tue Nov 26, 2013 7:53 am
Hey! My question is about task sleeping, how is it working in "asm code" ?
I haven't find any information about how may it be implemented. By process sleeping everyone know what does it means but how does it work "inside" ?
My idea is that, and hope you will tell me am I correct or am I wrong about it:
Let's have round robin scheduler (1-way queue). Let's have 4 tasks with attribute byte that tells if process is sleeping or isn't it (1 attribute byte per task):
1. task1 attribute=01h (1st bit set = task not sleeping) CS=50h EIP=0
2. task2 attribute=01h (1st bit set = task not sleeping) CS=58h EIP=0
3. task3 attribute=01h (1st bit set = task not sleeping) CS=62h EIP=0
4. task4 attribute=01h (1st bit set = task not sleeping) CS=72h EIP=0
After 1 cycle that allows task to be executed for some time (like 10 ms each) we gain such EIP status (imagined sitation / values of eip register):
task1; EIP=0x45
task2; EIP=0xf3
task3; EIP=0x9d
task4; EIP=0x3b
Now i want to sleep task3. And i am clearing 1st bit of attribute so
task3 attribute=00h
now task is sleeping, and EIP register won't change (increase or decrease)
And after next cycle of schulder:
task1; EIP=0xb5 ;changed
task2; EIP=0xf9 ; changed
task3; EIP=0x9d; not changed. scheduler is not switching into this task (not executing it) because checked attribute == 0x00 and executing next task (task4) right now
task4; EIP=0xc6 ; changed
Is my conception of process sleeping correct or totally wrong ? Or correct but it may be implemented in better way ?
Greeting,
Danny
I haven't find any information about how may it be implemented. By process sleeping everyone know what does it means but how does it work "inside" ?
My idea is that, and hope you will tell me am I correct or am I wrong about it:
Let's have round robin scheduler (1-way queue). Let's have 4 tasks with attribute byte that tells if process is sleeping or isn't it (1 attribute byte per task):
1. task1 attribute=01h (1st bit set = task not sleeping) CS=50h EIP=0
2. task2 attribute=01h (1st bit set = task not sleeping) CS=58h EIP=0
3. task3 attribute=01h (1st bit set = task not sleeping) CS=62h EIP=0
4. task4 attribute=01h (1st bit set = task not sleeping) CS=72h EIP=0
After 1 cycle that allows task to be executed for some time (like 10 ms each) we gain such EIP status (imagined sitation / values of eip register):
task1; EIP=0x45
task2; EIP=0xf3
task3; EIP=0x9d
task4; EIP=0x3b
Now i want to sleep task3. And i am clearing 1st bit of attribute so
task3 attribute=00h
now task is sleeping, and EIP register won't change (increase or decrease)
And after next cycle of schulder:
task1; EIP=0xb5 ;changed
task2; EIP=0xf9 ; changed
task3; EIP=0x9d; not changed. scheduler is not switching into this task (not executing it) because checked attribute == 0x00 and executing next task (task4) right now
task4; EIP=0xc6 ; changed
Is my conception of process sleeping correct or totally wrong ? Or correct but it may be implemented in better way ?
Greeting,
Danny