Why doesn't the work done by atmosphere contribute to increase in internal energy of gas? Say that I have a vertical thermally insulated cylinder which contains an ideal monoatomic gas under a weightless piston and the system is initially in equilibrium. 
Now if a load of weight $W$ is kept on the piston,the piston would fall by some distance and the system would attain a new equilibrium. It is intuitive that the sum of the work done by gravity and the work done by atmospheric pressure would change into internal energy of the gas. 
However, my book mentions that only the work done by gravity goes into the increase in internal energy of gas. It does not say anything about where the atmospheric work would go. Why is it so?
 A: If we carry out a force balance on the piston in the initial equilibrium state of the system, we have $$F_{gi}=P_{atm}A$$where $F_{gi}$ is the force the gas exerts on the piston in the initial state and A is the area of the piston.  Similarly, a force balance on the piston during the irreversible deformation that results when we suddenly apply a mass m to the piston reads:  $$F_g(t)-mg-P_{atm}A=m\frac{dv}{dt}$$where $F_g(t)$ is the force exerted by the gas on the piston at time t during the deformation and v is the piston velocity.  If we multiply this equation by the piston velocity v = dz/dt and then integrate up to time t, we obtain:  $$W_g(t)=\int_0^t{F_g(t)dt}=mg\Delta z+P_{atm}\Delta V+m\frac{v^2}{2}$$where $W_g{t}$ is the work done by the gas on the piston up to time t and the 3rd term on the right hand side of the equation is the kinetic energy of the mass.  
After infinite time passes, the system equilibrates, and the piston and mass come to rest.  At this final steady state, the work done by the gas on its surroundings (the piston) is$$W_g=mg\Delta z+P_{atm}\Delta V$$So there is no doubt that the work done by the gas must include the work done against the external atmosphere. And this is the work that causes the internal energy to change.
