![]() |
| | #1 |
| Just kidding.... Join Date: Jun 2003
Posts: 223
| 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. 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> |
| fnoyan is offline | |
| | #2 |
| and the hat of Jobseeking 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 |
| Salem is offline | |
| | #3 |
| Just kidding.... 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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |