Performance study of the CMS barrel resistive plate chambers with cosmic rays