Vortex shedding and lock-on of a circular cylinder in oscillatory flow