Matthew Fioravante
2009-Dec-31 23:16 UTC
[Xen-devel] disabling irqs in a non-preemptive OS
I''ve been working on a tpm backend driver in mini-os and I''m trying to eliminate all possible race conditions. My question is what exactly do you gain from disabling irqs with local_irq_save() local_irq_restore() From what I''ve gathered, When you disable interupts it sets vcpu->evtchn_upcall_mask = 1, which I assume means mask all event channels. Also, in sched.c, if anything tries to call schedule while irqs are disabled the OS will crash and print and error. mini-os is a uniprocessor and non-preemptive OS so unless your thread blocks, an irq handler (in this case event channel handler) will never be run and thus won''t be able to touch your critical sections. So really what do you get from disabling interrupts? Is it just a nice way of alerting you if something in your code block calls schedule()? Is it just a matter of good form and possibly securing your code in case someone adds preemption to mini os in the future? Or am I completely missing something here? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 31/12/2009 23:16, "Matthew Fioravante" <Matthew.Fioravante@jhuapl.edu> wrote:> mini-os is a uniprocessor and non-preemptive OS so unless your thread > blocks, an irq handler (in this case event channel handler) will never > be run and thus won''t be able to touch your critical sections.What makes you think that? ''Non-preemptive'' doesn''t mean that you can''t be interrupted by irq context. That''s why they''re called interrupts! -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Matthew Fioravante
2010-Jan-03 17:08 UTC
Re: [Xen-devel] disabling irqs in a non-preemptive OS
That I didn''t realize. Now it makes sense, thanks! Keir Fraser wrote:> On 31/12/2009 23:16, "Matthew Fioravante" <Matthew.Fioravante@jhuapl.edu> > wrote: > > >> mini-os is a uniprocessor and non-preemptive OS so unless your thread >> blocks, an irq handler (in this case event channel handler) will never >> be run and thus won''t be able to touch your critical sections. >> > > What makes you think that? ''Non-preemptive'' doesn''t mean that you can''t be > interrupted by irq context. That''s why they''re called interrupts! > > -- Keir > > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel