We study the ergodic control problem of switching diffusions represent
ing a typical hybrid system that arises in numerous applications such
as fault-tolerant control systems, flexible manufacturing systems, etc
. Under fairly general conditions, we Establish the existence of a sta
ble, nonrandomized Markov policy which almost surely minimizes the pat
hwise long-run average cost. We then study the corresponding Hamilton-
Jacobi-Bellman (HJB) equation and establish the existence of a unique
solution in a certain class. Using this, we characterize the optimal p
olicy as a minimizing selector of the Hamiltonian associated with the
HJB equations. As an example we apply the results to a failure-prone m
anufacturing system and obtain closed form solutions for the optimal p
olicy.