Dear friend, can anybody explain me why this kind of Static function used and when it should be used?
static void delay (unsigned long cnt) { while (cnt--); }
The second part of the question: You should almost never perform a delay by busy-looping a fixed number of iterations. The compiler may completely optimize away the loop, since it doesn't have any side effect.
Configure a timer and either busy-loop reading the timer register, or (for longer delays) configure the timer to generate an interrupt.