EmbLogic's Blog

an overview of how the system call in linux works

0) There is global system_call_table which has offsets of every system call
provided by the kernel (system call is just some function inside kernel). The global
means every process share the same system_call_table
1) User software prepares arguments of the system call, basically it puts them
to the CPU registers
2) User puts system call number to the appropriate CPU register (for example EAX)
3) User passes control to VDSO page
4) Code at this page executes either int $0×80 or syscall CPU instruction and generates
a special trap which is executed within kernel context.
5) The trap handler extracts the system call number from EAX and checks that it is good.
6) The trap handler prepares stack frame (put the values from register to stack)
7) The trap handler calls the code from the system_call_table using value extracted
at step 5 as an index in this table.
8) The system_call_table code returns back to the trap handler code, the trap hander
puts the returned value to the EAX and passes control back to the user space.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>