What are syscalls for?
What are syscalls for?
What are syscalls for?
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
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
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
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
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
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
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.
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.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
I found this page from the FreeBSD developers handbook informative..
http://www.freebsd.org/doc/en_US.ISO885 ... calls.html
http://www.freebsd.org/doc/en_US.ISO885 ... calls.html