In this paper we consider scheduling the execution of a number of different software tasks implementing a hierarchy of real-time controllers for a given plant. Controllers are considered to be given and ordered according to a measure of the performance they provide. Software tasks implementing higher-performance controllers are assumed to require a larger worst-case execution time. Control tasks are to be scheduled within given availability limits on execution time, which change stochastically in time. The ensuing switching system is prone to instability, unless a very conservative policy is enforced of always using the simplest, least performant controller. The presented method allows to condition the stochastic scheduling of control tasks so as to obtain a better exploitation of computing capabilities, while guaranteeing almost sure stability of the resulting switching system.