  By analyzing the Rossi X-ray Timing Explorer data on SAX J1808.4-3658 we show
that the X-ray emission in accretion powered millisecond pulsars can be
produced by Comptonization in a hot slab (radiative shock) of Thomson optical
depth tau~1 at the neutron star surface. The escaping radiation consists of two
components: a black body and a hard Comptonized tail. These components have
very different angular distribution: the black body peaks along the slab normal
(a ``pencil''--like emission pattern), while the tail has a broader angular
distribution (a ``fan''--like pattern). This results in very different
variability properties. We construct a detailed model of the X-ray production
accounting for the Doppler boosting, relativistic aberration and gravitational
light bending. We are able to reproduce the pulse profiles at different
energies, corresponding phase lags, as well as the time-averaged spectrum. We
obtain constraints on the neutron star radius: R~11 km if its mass M=1.6 Msun,
and R~8.5 km if M=1.4 M_sun. We present simple analytical formulae for
computing the light curves and oscillation amplitudes expected from hot spots
in X-ray bursters and accretion powered millisecond pulsars. We also propose an
analytical expression that can be used to determine the size of the black body
emission region from the observed properties.
