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

Re: Learning from Eratosthenes



Previously Jonathan Walther wrote:
> The arguments were reversed!  One needs to invoke it as lseek(fd, offset,
> SEEK_SET), not lseek(fd, SEEK_SET, offset).  Since some experienced
> developers hadn't noticed that error, I didn't feel so bad about making it
> myself.

Maybe it just means the experienced people ignored you, since it really
is an obvious mistake :)

> Following the time honored procedure, I started my seive with higher and
> higher limits.  All was good until I hit 0xFFFFFFFF.  Puzzled.  Backed
> down again; it worked.  Hmm, I know, it must be that mmap!  Yeah! Its
> buggy!

Check which libc and kernel you're using. Your mmap is probably a 32bit
version, and you need mmap64 (or just mmap and the old one renamed to
old_mmap, not sure) for more then 2Gb.

> Theres lotsa RAM here; why don't I just malloc() the memory I need and
> operate on it directly? 

Sorry, you can't malloc more then 980Mb or so on i386 due to the way memory
with ELF binaries is mapped. This should be changed in glibc2.2 since that
should use mmap instead of brk for allocating memory, but last time I tried
that it didn't do that correctly.

Wichert.

-- 
  _________________________________________________________________
 /       Nothing is fool-proof to a sufficiently talented fool     \
| wichert@wiggy.net                   http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0  2805 3CB8 9250 2FA3 BC2D |



Reply to: