In this paper we present a general model of the completion time of a single job on a computer system whose state changes according to a semi-Markov process with possibly infinite state-space. When the state of the system changes the job service is preempted. The job service is then resumed or restarted (with or without resampling) in the new state at, possibly, a different service rate. Different types of preemption disciplines are allowed in the model. Successive aggregation and transform techniques are used to obtain the Laplace–Stieltjes transform of the job completion time. We specialize to the case of Markovian structure-state process. We demonstrate the use of the techniques developed here by means of two applications. In the first we derive the distribution of the response time in an M/M/1 queueing system under the processor-sharing discipline (PS). In the second we derive the distribution of the completion time of a job when executed on a system subject to mixed types of breakdowns and repair.