Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

about system calls

7 views
Skip to first unread message

I love fish

unread,
Sep 27, 2009, 9:26:10 PM9/27/09
to
Below is a simple description about how the linux system call
implemented.

the main reason is int 0x80 software interrupt.

my question is why we should use the software interrupt but not we
can write some user model assembly language to do what the entry.S
does as as following says.

Thanks!

2.11 How System Calls Are Implemented on i386 Architecture?

There are two mechanisms under Linux for implementing system calls:


lcall7/lcall27 call gates;
int 0x80 software interrupt.
Native Linux programs use int 0x80 whilst binaries from foreign
flavours of UNIX (Solaris, UnixWare 7 etc.) use the lcall7
mechanism. The name 'lcall7' is historically misleading because it
also covers lcall27 (e.g. Solaris/x86), but the handler function is
called lcall7_func.

When the system boots, the function
arch/i386/kernel/traps.c:trap_init() is called which sets up the
IDT so that vector 0x80 (of type 15, dpl 3) points to the address
of system_call entry from arch/i386/kernel/entry.S.

When a userspace application makes a system call, the arguments are
passed via registers and the application executes 'int 0x80'
instruction. This causes a trap into kernel mode and processor
jumps to system_call entry point in entry.S. What this does is:


Save registers.
Set %ds and %es to KERNEL_DS, so that all data (and extra segment)
references are made in kernel address space.
If the value of %eax is greater than NR_syscalls (currently 256),
fail with ENOSYS error.
If the task is being ptraced (tsk->ptrace & PF_TRACESYS), do
special processing. This is to support programs like strace
(analogue of SVR4 truss(1)) or debuggers.
Call sys_call_table+4*(syscall_number from %eax). This table is
initialised in the same file (arch/i386/kernel/entry.S) to point to
individual system call handlers which under Linux are (usually)
prefixed with sys_, e.g. sys_open, sys_exit, etc. These C system
call handlers will find their arguments on the stack where SAVE_ALL
stored them.
Enter 'system call return path'. This is a separate label because
it is used not only by int 0x80 but also by lcall7, lcall27. This
is concerned with handling tasklets (including bottom halves),
checking if a schedule() is needed (tsk->need_resched != 0),
checking if there are signals pending and if so handling them.
Linux supports up to 6 arguments for system calls. They are passed
in %ebx, %ecx, %edx, %esi, %edi (and %ebp used temporarily, see
_syscall6() in asm-i386/unistd.h). The system call number is passed
via %eax.

--

[m [33m锟斤拷 锟斤拷源:锟斤拷水木锟斤拷锟斤拷 http://newsmth.net锟斤拷[FROM: 207.46.92.*] [m

�¶��ĺ������ڼ�į��·��

unread,
Sep 28, 2009, 2:10:59 AM9/28/09
to
Becuase the necessity of promoting execute priviledge

锟斤拷 锟斤拷 lzj2004 (I love fish) 锟侥达拷锟斤拷锟斤拷锟结到: 锟斤拷
: Below is a simple description about how the linux system call

: implemented.
: the main reason is int 0x80 software interrupt.

: ...................

--
[1;33m10793 [31m [0;37mcomealong Dec 24 [1;33m. 锟斤拷 锟斤拷卮锟斤拷锟揭伙拷锟叫⌒★拷锟酵拘★拷锟酵拷锟斤拷蔚潞锟斤拷艿锟絲t? [m


[m [35m锟斤拷 锟斤拷源:锟斤拷水木锟斤拷锟斤拷 http://newsmth.net锟斤拷[FROM: 218.249.47.*] [m

>/dev/null

unread,
Sep 28, 2009, 5:21:35 AM9/28/09
to
锟斤拷然咋锟斤拷去锟斤拷锟节猴拷态锟斤拷

锟斤拷 锟斤拷 lzj2004 (I love fish) 锟侥达拷锟斤拷锟斤拷锟结到: 锟斤拷
: Below is a simple description about how the linux system call
: implemented.
: the main reason is int 0x80 software interrupt.
: ...................

--

[m [36m锟斤拷 锟斤拷源:锟斤拷水木锟斤拷锟斤拷 http://newsmth.net锟斤拷[FROM: 119.42.238.*] [m

0 new messages