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

Re: interrupt disabled rules

Ted U wrote:

> i'm not familiar with all of the kernel functions.  but i'd like to know
> which ones should not be called with interrupts disabled.

> i'm assuming
> {
> splhigh();
> malloc(size, type, M_WAITOK);
> splx(s);
> }
> is a bad idea.  is this true?

Yes, it is a bad idea, but probably not for the reason you think.

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,
and I don't see how it could cause a denial-of-service?

> we're working on automated system checking here at stanford, and need some
> rules to check for.  any other rules would be appreciated too.

That would be a great tool!