C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-07-2006, 03:57 AM   #1
Just kidding....
 
fnoyan's Avatar
 
Join Date: Jun 2003
Posts: 223
system call

Hi

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.
Code:
(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....
fnoyan is offline   Reply With Quote
Old 06-07-2006, 05:50 AM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,705
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.

Salem is offline   Reply With Quote
Old 06-07-2006, 10:53 AM   #3
Just kidding....
 
fnoyan's Avatar
 
Join Date: Jun 2003
Posts: 223
Ahaa! I missed the point! Thanks...

Next time I should check the code more carefully before posting to forum
fnoyan is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My calculation, delete and update functions dont work (Programming language C) TKaeWoods C Programming 2 03-05-2009 10:25 AM
Troubleshooting Input Function SiliconHobo C Programming 14 12-05-2007 07:18 AM
Inline asm brietje698 C++ Programming 5 11-11-2007 02:54 PM
nanosleep() -system call does some confusing things jtk Linux Programming 5 08-30-2007 04:15 AM
temperature sensors danko C Programming 22 07-10-2007 07:26 PM


All times are GMT -6. The time now is 10:15 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22