The thermodynamics of the internal combustion engine can be represented on a pressure v volume graph as seen below

This is a simplified Otto cycle: Q represents heat and W represents work. The difference between work and heat is that heating is chaotic and work done is ordered.

From 1 to 2: this stage is an adiabatic compression (adiabatic means work is constant). This stage occurs as the piston is rising in the cylinder during the compression stroke. This stage occurs relatively slowly.

From 2 to 3: this is an isochoric heating (isochoric means at constant volume). This occurs as the fuel is ignited, there is a rapid rise in temperature. The piston is at top dead centre.

From 3 to 4: again this stage is slow and adiabatic but here it is an adiabatic expansion. This is the power stroke. The gases do no work on the piston. The power is transferred from the piston to the cam shaft. 

From 4 to 1: this step is isochoric cooling, it happens rapidly and completes the cycle. As the exhaust stroke occurs the piston drops to the bottom of the cylinder returning the cylinder to atmospheric pressure.

It should be noted that this is an dramatic simplification of the internal combustion engine and not all the processes are reversible in a real life situation. The Otto cycle is a thermodynamic ideal of the internal combustion engine and therefore can be used to calculate the maximum efficiency of an Otto engine. 

For more information follow this link.

(image taken, without permission from http://www.qrg.ils.nwu.edu/thermo/design-library/otto/otto.html)