Carbonyl sulfide (OCS) is a key molecule in astrobiology that acts as a catalyst in peptide synthesis by coupling amino acids. Experimental studies suggest that hydrogen sulfide (H2S), a precursor of OCS, could be present in astrophysical environments. In the present study, we used a microwave-discharge hydrogen-flow lamp, simulating the interstellar UV field, and a monochromatic synchrotron light beam to irradiate CO:H2S and CO2:H2S ice mixtures at 14 K with vacuum ultraviolet (VUV) or extreme ultraviolet (EUV) photons in order to study the effect of the photon energy and carbon source on the formation mechanisms and production yields of S-containing products (CS2, OCS, SO2, etc.). Results show that (1) the photo-induced OCS production efficiency in CO:H2S ice mixtures is higher than that of CO2:H2S ice mixtures; (2) a lower concentration of H2S enhances the production efficiency of OCS in both ice mixtures; and (3) the formation pathways of CS2 differ significantly upon VUV and EUV irradiations. Furthermore, CS2 was produced only after VUV photoprocessing of CO:H2S ices, while the VUV-induced production of SO2 occurred only in CO2:H2S ice mixtures. More generally, the production yields of OCS, H2S2, and CS2 were studied as a function of the irradiation photon energy. Heavy S-bearing compounds were also observed using mass spectrometry during the warm-up of VUV/EUV-irradiated CO:H2S ice mixtures. The presence of S-polymers in dust grains may account for the missing sulfur in dense clouds and circumstellar environments.