Page 1 of 1
What are syscalls for?
Posted: Sun Jul 08, 2007 1:10 pm
by d4n1l0d
What are syscalls for?
Posted: Sun Jul 08, 2007 4:35 pm
by Brynet-Inc
Wow, You could of at least searched around a bit..
There is an article about it on the Wiki, and countless forum discussions..
http://www.osdev.org/wiki/System_Calls
http://en.wikipedia.org/wiki/System_call
Good luck
Posted: Sun Jul 08, 2007 4:39 pm
by d4n1l0d
sorry, I was in a hurry =//
Thank you for the links
Posted: Sun Jul 08, 2007 4:47 pm
by deadmutex
User applications and other non-privileged code use system calls in order to access system services that are controlled by the kernel. User code and Kernel code should be completely separated with the system calls as an interface. This way, the user can't touch the sensitive stuff in the kernel. Without system calls, a userland program wouldn't be able to do much besides calculate stuff...
Some examples of system calls are:
yield(): Give up control of processor
sleep(): Sleep for x msecs
read(): Read a file
write(): Write to a file
sendMsg(): Send a message to another process
sbrk(): Extend end of heap pointer
Posted: Sun Jul 08, 2007 5:08 pm
by pcmattman
Typically your kernel sets up an interrupt (Linux uses 0x80, Windows 0x21) and user space code calls these interrupts, generally with a function number in EAX. My syscall interface uses a switch() statement to choose what to execute.
For instance, my kernel has, on syscall 0x01, "Print String". Instead of rewriting my console i/o code into userland programs, I just call int 0x80 (my kernel's interrupt) with EAX=1 and ESI=addy of string.
Posted: Sun Jul 08, 2007 5:43 pm
by Brynet-Inc
I found this page from the FreeBSD developers handbook informative..
http://www.freebsd.org/doc/en_US.ISO885 ... calls.html
Posted: Sun Jul 08, 2007 6:02 pm
by d4n1l0d
thank you very much
so, when the user calls a syscall function the processor goes to ring 0 and execute kernel code??
Posted: Sun Jul 08, 2007 7:28 pm
by pcmattman
Pretty much...
Posted: Sun Jul 08, 2007 7:35 pm
by d4n1l0d
xD