Work done by the piston versus work done by the surrounding Suppose a massless, frictionless piston assembly initially has a higher pressure than the external (atmospheric) pressure, and it is pinned so that the piston does not move. Once the pin is removed, the piston would expand until the pressure inside the piston becomes the atmospheric pressure. During the process, the work done by the gas inside the piston is
$$W_{\text{piston}}=\int_{V_1}^{V_2} P_{\text{gas}}\cdot \mathrm{d}V$$
and the work done by the surrounding is,
$$W_{\text{ext}}=\int_{V_1}^{V_2}P_{\text{ext}}\cdot \mathrm{d}V = P_{\text{ext}} \left(V_2 - V_1 \right)
\,.$$
We can pull out the external pressure from the integral because it is constant as an atmospheric pressure.
My question is, the work done by the piston is not the same with the work done by the surrounding because $\mathrm{d}V$ is the same, but ${P}_{\text{gas}}$ is greater than ${P}_{\text{ext}}$ during the process, so the work done by the piston is larger than that by the surrounding. Shouldn't they be the same?
 A: The pressure on both sides of the unpinned weightless piston is always the same. In case of any difference, the piston would quickly move pressuring the external gas locally above the atmospheric pressure. Your setup is not static and only can be solved by aerodynamics. However, in the limited scope of your question, the answer is that the pressure is always the same on both sides.
In reality, the piston is not weightless, so the initial pressure difference would be compensated by the inertial force of the piston acceleration untill the dynamic pressure is the same on both sides.
A: If you do a free body diagram on your massless, frictionless piston, you can only conclude that the force exerted by the gas on the inside face of then piston is equal to the external force exerted on the outside face of the piston.  That means that the work is the same.  So, what gives?
Well, first of all, in a rapid irreversible expansion like this, the pressure of the gas within the cylinder is not uniform (spatially).  It is lower at the piston face than on average within the cylinder.  Secondly, a gas experiencing a rapid deformation does not obey the ideal gas law even locally; there are viscous stresses in the gas (proportional to the rate of deformation) which contribute to the force at the inner piston face.  So, without solving the partial differential equations for aerodynamics, we have very little knowledge of the force on the inner piston face.
Also, as safesphere points out, if there is a gas present (like the atmosphere) external to the piston and cylinder, analogous effects can occur within this gas.  However, we typically assume that we have better control over what is happening with the external load (such as through feedback control systems, or by having a vacuum outside and using a piston with mass).  So, whereas, the knowledge of the internal force on the piston requires solution of the partial differential equations for aerodynamics, for textbook thermodynamics problems, we usually assume that we can impose the external load precisely.  We are thereby able to more easily calculate the amount of work done by the gas on the surroundings.  
Of course, if the expansion is done reversibly (say, by imposing a very gradually varying external force on the gas within the cylinder), the work can be calculated using the ideal gas law to determine the force on the inner piston face, since, in that case, viscous stresses and non-uniformities within the gas are negligible.
A: The only problem consists in the fact that you consider that the atmospheric pressure will remain constant. In fact it increases. Let me explain:
When your piston expands it reduces the atmosphere volume as a whole from $V_{0\mathrm{atm}}$ to
$$V_{1\mathrm{atm}}=V_{0\mathrm{atm}}- \Delta V
\,.$$This reduction in volume results in an increase of the atmospheric pressure from $p_{0\text{ext}}$ to
$$p_{1\text{ext}}= \frac{p_{0\mathrm{atm}}}{1- \frac{\Delta V}{V_{0\text{atm}}}}
\,.$$Even thought the increase in pressure is tiny when we consider $\Delta V \ll V_{0\mathrm{atm}}$ (as it always is) to the point that one could consider $p_{0\text{ext}}$ constant, the missing energy will be dispersed throughout the planet as potential energy, just as much as you store energy in a pressurized bottle.
In this model I’ve consider that the atmosphere was closed at it's top. Still, Even if you consider the open-top scenario, instead of just an increase in atmospheric pressure, your system’s expansion would push up the top of atmosphere by a certain amount. Anyway, an increase in atmospheric height would result in an increase of its gravitational potential energy and therefore work-energy balance holds.
To make this clear, consider what would happen if the increase in volume of your piston would not be small. Let’s say, it occupied half of the planet. All atmosphere would be displaced to the other part of the planet and atmospheric pressure would double there. The work performed by your system would be stored as pressurized air in the double atmosphere part of the planet.
A: The work done varies because the piston will be accelerated at a higher rate.In case of contant pressure expansion(both internal and external pressures are same at all instances) the piston moves slowly.Because the force will be just enough to move the piston.But in your case the force inside will be sufficiently higher so the piston moves faster(i.e. accelerated).I had the same doubt and still doubtfull about it.
A: Just for a comment;
A very interesting question. It appears to be paradoxical.
Buy, in your problem, conditions are given for friction and the mass of the piston, but there are no constraints for heat transfer in and out or temperature change. So it is an incomplete problem; thanks to this imperfection, it seems to me that there can be a reasonably possible escape route.　Conveniently, there is no mention of the pressure inside and outside the syringe being "different" even after the pin has been removed.
If we now assume that the gas inside the syringe is an ideal gas, then the course of $P_{gas}$ as a function of $V$  satisfies $P_{gas}(V)V=nRT$, so,
$$P_{gas}(V) = nRT/V$$
, but there is no assumption at all that the temperature does not change.
So what would $P_{gas}(V)$ be if we assume a limit where the cylinder gains no energy at all, i.e. so slow that it gains no kinetic energy? In order for this to be the case, it must always be the case that $P_{gas} dV = P_{ext} dV$, so
$$P_{gas}=P_{ext} $$
shall be always satisfied.　The only way to force it to do this is to change the temperature conveniently;  if we carry even a small amount of energy into the kinetic energy of the syringe because of the following "withdrawn statement".
That is, the temperature of the gas in the syringe can and must be applied as a function of $V$ in the following form;
$$P_{gas}(V)=P_{ext} = nRT_{gas}(V)/V$$
So,
$$T_{gas}(V)=P_{ext} V/nR$$
That means, if the temperature in the syringe can be varied in this way, a physically possible situation can be artificially created.
◆The following statement is withdrawn on 28 April 2021：
Let S be the cross-sectional area of the piston.
When the gas inside the syringe expands (i.e. $P_{gas}>P_{ext}$), the piston receives a force of $F_1=P_{gas}S$ from the gas inside the syringe in the direction of the gas expansion.
On the other hand, in this case, the sringe receives a force of $F_2=-P_{ext}S$ from the gas outside the syringe in the direction of gas expansion.
Therefore, the combined force received by the syringe is
$F_{sir} = F_1 + F_2 = (P_{gas} - P_{ext})S$ in the direction of the gas expansion.
Therefore, when moving a small distance $dl$, the syringe obtains the following energy;
$$F_{sir}\ dl = (P_{gas} - P_{ext})S\ dl = (P_{gas} - P_{ext})\ dV$$
So, during your process, the energy the syringe obtains from the gasses will be;
$${W}_{sir}=\int_{V_1}^{V_2}  (P_{gas} - P_{ext}) dV$$
If there is no friction or force braking the piston, then the difference between the $W_{ext}$ and the ${W}_{piston}$ (that is ${W}_{sir}$)seems to have nowhere to go but the kinetic energy of the cylinder.
In such a situation. If the mass of the cylinder is infinitely zero, wouldn't the velocity of the cylinder be infinitely large? It seems to me that this would be a physically impossible situation.
