How is the balance of oxygen and carbon dioxide maintained in the atmosphere?

how is the balance of oxygen and carbon dioxide maintained in the atmosphere?