Theory of bistability and self pulsing in a ring resonator with saturable photorefractive gain and loss