how the Arduino Uno power automatically slected between USB and external power?

fdn340p is a p-Channel mosfet.
0v at the gate will turn it on