Radiative lifetime measurements have been performed, with a time-resolved laser-induced fluorescence technique, for 12 levels of Os I and for 9 levels of Os II. For 9 levels of Os I and 4 levels of Os II, there were no previous experimental data available. From a comparison with new theoretical calculations, taking configuration interactions and core-polarization effects into account, it has been possible to deduce oscillator strengths for 129 transitions of Os I and 137 transitions of Os II of astrophysical interest appearing in the wavelength range 180.0-870.0 nm. These results have allowed us to revise the abundance of osmium in the solar photosphere (log ε Os = 1.25 ± 0.11). The newly derived oscillator strengths have been applied as well to derive the osmium abundance in the carbon-rich metal-poor star HD 187861.