Subject: Re: splsoftnet and spl settings.
To: Darren Reed <>
From: Jason Thorpe <>
List: tech-kern
Date: 02/13/1997 10:49:06
On Thu, 13 Feb 1997 22:09:51 +1100 (EST) 
 Darren Reed <> wrote:

 > can code that is running inside splsoftnet() be interrupted by a user
 > context ?  if so, can the user context then swtich to kernel (via some
 > system call) and continue along and call splsoftnet() again ?


Code executing inside the kernel cannot be interrupted by anything
except a higher priority interrput.  It can voluntarily give up the
CPU by calling sleep or tsleep.  If this happens while at some
high-ish spl (i.e. not spl0), the code path will resume execution at
that level when the process is awakened.

 > I notice in the spl.h there is no "set/test and wait", just a setting
 > of the flag and was concerned about what this means...does it (with help
 > from the kernel elsewhere) guarantee a protected region of code ?

Err, you mean on the i386?  Those masks are used to defer the handling
of an interrupt to some later time (to avoid mucking about in the PIC).
It is safe to simply OR in an spl level, since you always want to raise
priority (except on an splx call).

So, if you have code that does:

	s = splsoftnet();
	[ . . . ]

you are guaranteed that no other network software interrupt handers will
run while you execute code in between... if a network hardware interrupt
will touch a data structure you're manipulating, you have to use:

	s = splnet();
	[ . . . ]

Jason R. Thorpe                             
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939