The cooling power of cryocoolers is determined by the work done by the compressor and the entropy produced by the irreversible processes in the various components of the system. In this paper we discuss the thermodynamics of pulse tubes, but many of the relationships are equally valid for other cryocoolers such as Stirling or Gifford-McMahon coolers. First general equations will be derived staying as close as possible to first principles, i.e. the first and second law of thermodynamics. General estimations of the entropy productions are made and the consequences for the design of coolers are discussed. No assumptions are made with respect to the nature of the gas and the relationships are valid for large pressure variations. Much attention is paid to reversible and irreversible processes in the regenerator. The energy balance equations lead to a characteristic length and a characteristic time. In the case of ideal heat exchange between the gas and the matrix the equations imply solutions in which the temperature profile moves through the regenerator as a wave.