Thread: system call

  1. #1
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Still in the egg

    system call


    As I know, if I invoke a system call, it uses a special instruction (called as trap instruction) to change the kernel mode. When I use fork() to create a new process, I neither see any special instruction that changes the mode nor any jmp to any other function like sys_fork!

    Here is the gdb dump of the statically compiled C code that uses a fork call.
    (gdb) disas fork
    Dump of assembler code for function fork:
    0x08053350 <fork+0>:    push   %ebp
    0x08053351 <fork+1>:    mov    $0x0,%edx
    0x08053356 <fork+6>:    mov    %esp,%ebp
    0x08053358 <fork+8>:    sub    $0x8,%esp
    0x0805335b <fork+11>:   test   %edx,%edx
    0x0805335d <fork+13>:   mov    %ebx,0xfffffffc(%ebp)
    0x08053360 <fork+16>:   je     0x8053375 <fork+37>
    0x08053362 <fork+18>:   movl   $0x80b05c0,(%esp)
    0x08053369 <fork+25>:   call   0x0
    0x0805336e <fork+30>:   mov    0xfffffffc(%ebp),%ebx
    0x08053371 <fork+33>:   mov    %ebp,%esp
    0x08053373 <fork+35>:   pop    %ebp
    0x08053374 <fork+36>:   ret
    0x08053375 <fork+37>:   mov    $0x2,%eax
    0x0805337a <fork+42>:   int    $0x80
    0x0805337c <fork+44>:   cmp    $0xfffff000,%eax
    0x08053381 <fork+49>:   mov    %eax,%ebx
    0x08053383 <fork+51>:   ja     0x8053389 <fork+57>
    0x08053385 <fork+53>:   mov    %ebx,%eax
    0x08053387 <fork+55>:   jmp    0x805336e <fork+30>
    0x08053389 <fork+57>:   neg    %ebx
    0x0805338b <fork+59>:   call   0x80489c0 <__errno_location>
    ---Type <return> to continue, or q <return> to quit---
    0x08053390 <fork+64>:   mov    %ebx,(%eax)
    0x08053392 <fork+66>:   mov    $0xffffffff,%ebx
    0x08053397 <fork+71>:   jmp    0x8053385 <fork+53>
    Thanks in advice....

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    What's this look like?
    0x08053375 <fork+37>: mov $0x2,%eax
    0x0805337a <fork+42>: int $0x80
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Still in the egg
    Ahaa! I missed the point! Thanks...

    Next time I should check the code more carefully before posting to forum

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  3. Inline asm
    By brietje698 in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2007, 02:54 PM
  4. nanosleep() -system call does some confusing things
    By jtk in forum Linux Programming
    Replies: 5
    Last Post: 08-30-2007, 04:15 AM
  5. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM