lkml.org 
[lkml]   [2000]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: pid hash question
Date
On Fri, 17 Mar 2000 00:21:15 +0100, you wrote:

>Hi,
>
>The pid hash function in include/linux/sched.h looks like this:
>
>#define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
>
>What is the point of the >> 8 ? Since pids are assigned linearly (more
>or less), wouldn't ((x) & (PIDHASH_SZ - 1)) be just as good?

You are overlooking that XOR operator, I think?

Without the ((x)>>8), an 8 bit hash would map PIDs 2 and 258 to 2;
with it, 2 maps to 2, 258 maps to 3.

Not a huge difference, perhaps, but it does make the hash less linear
than the PIDs, at least.


James.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.031 / U:1.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site