In this paper, we present a methodology for designing embedded controllers based on the so-called anytime control paradigm. A control law is split into a sequence of subroutine calls, each one fulfilling a control goal and refining the result produced by the previous one. We propose a design methodology to define a feedback controller structured in accordance with this paradigm and show how a switching policy of selecting the controller subroutines can be designed that provides stability guarantees for the closed-loop system. The cornerstone of this construction is a stochastic model describing the probability of executing, in each activation of the controller, the different subroutines. We show how this model can be constructed for realistic real-time task sets and provide an experimental validation of the approach.