How do the lungs function in the circulatory system?

I think you want to know lung’s role w.r.t. . In veretebrates, blood circulation around lungs is important for unloading and loading of respiratory gases.
Blood carries respiratory gases: it picks up oxygen from lungs, distributes it to body tissues and picks up carbondioxide from tissues to offload it in lungs.
Alveoli of lungs remain separated from blood capillaries by two thin layers of squamous epithelia sandwiched together to form respiratory membrane.
Diffusion of gases between alveolar space and blood takes place through respiratory membrane.