When I use windows Arduino IDE for Galileo to program on a Galileo board, I find it use 3ms to run a "digitalWrite()".
Compile and run this code as follows(without delay):
void loop( void )
Then I can get a square wave which has a period time of more than 6ms.
But when I use the same code on an ordinary Arduino UNO board using Arduino official IDE, it only takes 4us to run that instruction.
I know that 4us is still not the optimal cost, since code like "PORTB=0XFF" is more efficient in AVR. But how can the Galileo use thousands of bus cycles to execute this simple instruction?
I have tried this on two Galileo boards and get the same result. So maybe the only way out is to find the address of all of the registers in Quark. But it sames rather difficult for I don't know how to find data like this.
Digital pin 2 is connected via a multiplexor which allows several functions on one pin.
Every time you use digitalWrite to that pin it has to configure the multiplexor as well as the pin itself.
Pins 2 and 3 however also provides fast IO - see this post for more details.