Implementing Sleep Syscall
Posted: Fri Mar 21, 2008 12:58 pm
Hi!
I have multitasking and I'm building the syscall handler, but I got stuck here.
Which is the better way to implement an sleep syscall?
This is my code so far and it runs in another thread (not task).
Is there any better way to implement it? What do you use in your kernel?
Cheers,
Gonzalo
I have multitasking and I'm building the syscall handler, but I got stuck here.
Which is the better way to implement an sleep syscall?
This is my code so far and it runs in another thread (not task).
Code: Select all
void a(){
while(1){
asm volatile("int $0x30" :: "a"(3));
//Syscall Function 3 - Get System ticks
unsigned int start;
asm volatile("movl %%eax, %0" :: "g"(start));
//Put current ticks in start
unsigned int now;
start+=1000;
//Add 1000 for target time
asm volatile("int $0x30" :: "a"(2), "b"('a'));
//Syscall function 2, prints 'a'
for(;;){
asm volatile("int $0x30" :: "a"(3));
asm volatile("movl %%eax, %0" :: "g"(now));
int a = start-now;
if(a<0) break;
//The 'Wait' function
}
}
}
Cheers,
Gonzalo