There are a dozen or more different ways that this can be done.
Most modern codeshares now have a "free flow" codeshare whereby there is a common inventory pool that is mirrored under each code and controlled either by the operating carrier or mutually (when no anti-trust issues exist). The big boys (Sabre, SITA, Amadeus, Travelport) are quite capable of seamlessly linking between each other now, although some are undoubtedly better at doing this than others. The links themselves may be basic AVS or NAVS exchange, Direct Access or other types of advanced Type B links.
There are of course plenty of other ways to run a codeshare relationship. These include "hard blocks" (marketing carrier has a fixed quota of seats available exclusively to them), "soft blocks" (marketing carrier has a minimum/maximum quota of seats to sell), "sell and report" (marketing carrier keeps selling and passing names along to the operating carrier regardless of inventory controls), "stop sale" (marketing carrier sells until they receive a stop sale message in response), "return request" (marketing carrier requests space without seeing actual availability and operating carrier responds with either positive or negative) and many others down to the most basic "pick up the phone and call" system.