ASIDE: Why System Calls Look Like Procedure Calls?
You may wonder why a call to a system call, such as open() or read() looks exactly like
a typical procedure call in C; that is, if it looks just like a procedure call, how does the
system know it is a sytem call, and do all the right stuff? The simple reason: it is a procedure
call, but hidden inside that procedure call is the famous trap instruction. More specifically,
when you call open() (for example), you are executing a procedure call into the C library.
Therein, whether for open() or any of the other syscall calls provided, the library uses an
agreed-upon calling convention with the kernel to put the arguments to open in well-known
locations.
时间: 2024-11-06 02:02:40