In a semiconductor laser, a [p-n junction](https://) diode is used to generate light. When a forward bias voltage is applied, electrons from the n-type region and holes from the p-type region are injected into the active region. These carriers recombine and release [photons](https://), creating a population inversion necessary for [laser action](https://). The emitted light is then amplified by the optical gain medium and confined by mirrors to produce a coherent beam of light.