[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interrupt disabled rules

Ted U wrote:

> On Wed, 30 May 2001, Cedric Berger wrote:
> > It is a bad idea because malloc call splimp() internally, and you are not
> > allowed to lower the priority level. i.e. you cannot call malloc if you're
> > running higher than splimp. (splimp and splhigh may be the same on some
> > arch, though)
> > On the other end, if your malloc call cannot succeeed immediately because
> > of low memory condition, malloc() will call tsleep, which will release the
> > implicit lock before sleeping, meaning any other thread can run at that point,
> thanks.  so there shouldn't be any calls to malloc with interrupts
> disabled (at least as much as splimp)?

Nobody should call malloc from any level higher than splimp (which are
splhigh, splserial, splsched, splclock, splstatclock)

More generaly, besides splx() and spllowersoftclock(), you should never
call a spl* function that will lower the current level. That should be easy
to test with an automated system. You don't even need to have special
rules for malloc().

The term "interrupt disabled" is not a very good one, because *all* spl*
functions, on most arch, disable some of the interrupts.

on http://www.openbsd.org/cgi-bin/man.cgi, type "spl"