For pushrod designs—when cylinder deactivation is called for—the hydraulic valve lifters are collapsed by using solenoids to alter the oil pressure delivered to the lifters. In their collapsed state, the lifters are unable to elevate their companion pushrods under the valve rocker arms, resulting in valves that cannot be actuated and remain closed.
By forcing the engine valves to remain closed, an effective “spring” of air is created inside the deactivated cylinders. Trapped exhaust gasses (from previous cycles before the cylinders were deactivated) are compressed as the pistons travel on their upstroke and then decompressed and push back on the pistons as they return on their down stroke. Because the deactivated cylinders are out of phase, (some pistons traveling up while others are traveling down), the overall effect is equalized. The pistons are actually just going along for the ride.
To complete the process, fuel delivery for each deactivated cylinder is cut-off by electronically disabling the appropriate fuel injection nozzles. The transition between normal operation and deactivation is smoothed by subtle changes in ignition and camshaft timing as well as throttle position all managed by sophisticated electronic control systems. In a well-designed and executed system, the switching back-and-forth between both modes is seamless—you really don’t feel any difference and have to consult the dash gauges to know that it's happened.