Shutter Priority S

Nikon D5100 operation mode dial, SExplanation: Shutter priority means that you choose an exposure time (shutter speed) and the D5100 will set a corresponding aperture.
The exposure time can be selected with the command dial on the back.

If you use the flash you cannot select any shorter exposure times than 1/200 s.

If there is no aperture for your exposure time that results in correct exposure there will be an indicator for over- or underexposure in the viewfinder.

Recommendation: The most important usage of shutter priority S is to select a short exposure time to capture fast moving subjects.

But you can get the same results in mode P by turning the command dial at the back to shift the combination of aperture and exposure time.