Stability of surface layers from a study of the mean-square displacements of surface atoms