What determines the direction of respiratory gas movement?

What determines the direction of respiratory gas movement?