A method for improving the functioning of a turbocharged diesel engine equipped with a cylinder deactivation system, the method comprising detecting when the turbocharged diesel engine is at risk of compressor surge, and then delaying part or all of the cylinder deactivation until risk of compressor surge is not indicated; wherein said detecting is accomplished by calculating estimates of changes in intake manifold pressure for specific CDA conditions, and then comparing those estimates to the compressor surge line for the engine to determine whether deactivation of one or more cylinders will avoid compressor surge; wherein said estimates are calculated by a set of steps comprising: a) measuring or estimating the mass flow rate of fresh air leaving the compressor of a turbocharged diesel engine having n cylinders; b) measuring or estimating the intake manifold pressure of said engine; c) providing information indicating the displacement of the engine, the future number of active cylinders, and the volumetric efficiency of the engine; d) using the mass flow rate information, the intake manifold pressure information, the engine displacement information, and the volumetric efficiency information to estimate changes in intake manifold pressures over time if some or all engine cylinders are deactivated; e) comparing the intake manifold pressure estimates to acceptable intake manifold pressure information to determine whether deactivating cylinders would be expected to produce an unacceptable intake manifold pressure at any relevant time subsequent to a cylinder deactivation; and f) if the comparison of step (e) indicates that one or more cylinders could be deactivated without being expected to produce an unacceptable intake manifold pressure at any relevant time, deactivating the greatest number of cylinders that may be deactivated without producing an unacceptable intake manifold pressure. said detecting is accomplished by calculating estimates of changes in intake manifold pressure for specific CDA conditions, and then comparing those estimates to the compressor surge line for the engine to determine whether deactivation of one or more cylinders will avoid compressor surge; wherein said estimates are calculated by a set of steps comprising: a) measuring or estimating the mass flow rate of fresh air leaving the compressor of a turbocharged diesel engine having n cylinders; b) measuring or estimating the intake manifold pressure of said engine; c) providing information indicating the displacement of the engine, the future number of active cylinders, and the volumetric efficiency of the engine; d) using the mass flow rate information, the intake manifold pressure information, the engine displacement information, and the volumetric efficiency information to estimate changes in intake manifold pressures over time if some or all engine cylinders are deactivated; e) comparing the intake manifold pressure estimates to acceptable intake manifold pressure information to determine whether deactivating cylinders would be expected to produce an unacceptable intake manifold pressure at any relevant time subsequent to a cylinder deactivation; and f) if the comparison of step (e) indicates that one or more cylinders could be deactivated without being expected to produce an unacceptable intake manifold pressure at any relevant time, deactivating the greatest number of cylinders that may be deactivated without producing an unacceptable intake manifold pressure. a) measuring or estimating the mass flow rate of fresh air leaving the compressor of a turbocharged diesel engine having n cylinders; b) measuring or estimating the intake manifold pressure of said engine; c) providing information indicating the displacement of the engine, the future number of active cylinders, and the volumetric efficiency of the engine; d) using the mass flow rate information, the intake manifold pressure information, the engine displacement information, and the volumetric efficiency information to estimate changes in intake manifold pressures over time if some or all engine cylinders are deactivated; e) comparing the intake manifold pressure estimates to acceptable intake manifold pressure information to determine whether deactivating cylinders would be expected to produce an unacceptable intake manifold pressure at any relevant time subsequent to a cylinder deactivation; and f) if the comparison of step (e) indicates that one or more cylinders could be deactivated without being expected to produce an unacceptable intake manifold pressure at any relevant time, deactivating the greatest number of cylinders that may be deactivated without producing an unacceptable intake manifold pressure.