by notzed » Wed Aug 20, 2014 12:24 pm
You'll almost certainly save memory by not using the C library because it wasn't designed for size but for standards compliance and portability. There is no shared library mechanism so you wont save a single byte by using a C library function over a replacement either - everything needs to be linked in statically. If you're talking about putting the C library into the shared memory (quite likely the root cause of your problem, as below) then you can also do that with any code you write yourself. It's just up to the linker script and sections you use. But it comes at such a performance penalty it should only be used for code that is very rarely executed.
On your last point thats why you search for someone who has done it already (like knuth) and use theirs? Do you even know if the one in the C library is any "good" or are you just going on trust? If you needed a particularly good PRNG you would have to validate the C library anyway.
As far as I know (but i could be wrong), right now the C library is simply broken if you put any writable storage into the shared memory area because for a given program they will all use the same linked C library instance (and variables). Last time I looked (IIRC, some time ago) the C library itself just isn't built with any support for multi-threading whatsoever. It works fine if every core has it's own private copy because then it isn't physically multi-threading.