This article considers an extension of the classic machine-repair problem. The machines, apart from receiving service from a single repairman, now also supply service themselves to queues of products. The extended model can be viewed as a two-layered queueing network, in which the queues of products in the first layer are generally correlated, due to the fact that the machines have to share the repairman’s capacity in the second layer. Of particular interest is the dynamic control problem of how the repairman should allocate his/her capacity to the machines at any point in time so that the long-term average (weighted) sum of the queue lengths of the first-layer queues is minimized. Since the optimal policy for the repairman cannot be found ...