Subject: Re: Syscall number space
To: Darren Reed <darrenr@netbsd.org>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 08/26/2007 22:48:06
On Aug 26, 2007, at 10:01 PM, Darren Reed wrote:
> Jason Thorpe wrote:
>> On Aug 26, 2007, at 8:29 PM, Thor Lancelot Simon wrote:
>>> Because that's the currently configured limit in syscalls.master.
>>
>> The only reason that's set like that was to make the number of
>> system call slots a power of two (512 happened to be the closest
>> power of two). Making it a power of two enables some optimizations
>> in the low-level system call handler.
>>
>> There is no harm in simply making it 1024 (aside from some wasted
>> space).
>
> I looked quickly to see if there was any such beastie but obviously
> i didn't
> look hard enough (or in the right place.) Where should I look to
> see where
> this table is built and used?
makesyscalls.sh builds the system call table from syscalls.master.
It's basically a wrapper around a big awk script, and nsysent is
processed in the END clause:
if (nsysent) {
if (syscall > nsysent) {
printf("%s: line %d: too many syscalls [%d >
%d]\n", infile, NR, syscall, nsysent)
exit 1
}
while (syscall < nsysent) {
printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d
= filler */\n", \
sys_nosys, syscall) > sysent
syscall++
}
}
As you can see, all it does is pad the table out with entries that
call sys_nosys(). It also defines a constant SYS_NSYSENT, which is
when used like so in machine-dependent code:
code &= (SYS_NSYSENT - 1);
callp += code;
(I.e. no test-and-branch for whether or not the system call number is
beyond the end of the table.)
-- thorpej