some quesion about assembly when calling fork
Alessandro Rubini
rubini-list at gnudd.com
Wed Sep 16 10:38:10 EDT 2009
> if ((pid = fork()) < 0) {
> 84b4: ebffffb5 bl 8390 <.text-0x48>
> 84b8: e1a03000 mov r3, r0
> 84bc: e50b3010 str r3, [fp, #-16] xx1
> 84c0: e51b3010 ldr r3, [fp, #-16] xx2
> 84c4: e3530000 cmp r3, #0 ; 0x0
You are not optimizing. So the compiler follows the statements
literally: first it stores the result of fork in pid. Then loads pid to
compare with zero.
If you optimize, I'm sure it won't even copy r0 to r3 before comparing.
/alessandro
More information about the linux-arm-kernel
mailing list