Spectral and timing properties of the X-ray emission from the millisecond pulsar PSR B1821-24