Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Oct 1995 21:02:12 +0200
From:      Mark Murray <mark@grondar.za>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        hackers@FreeBSD.org
Subject:   Re: Creating a /dev/random 
Message-ID:  <199510161902.VAA27145@grumble.grondar.za>

next in thread | raw e-mail | index | archive | help
> To avoid this, use the existing buffer `zbuf', which is freed correctly.
> There is no need for another variable - local variables are per process.
> Perhaps `zbuf' should be renamed `buf'.

I don't understand something here - what happens if the one process is
reading both /dev/zero and /dev/random? will the two not then try to
share buf/zbuf and screw up?

> Hmm, now I know why /dev/zero is so slow.  The buffer is bzeroed for
> every call.  The buffer size is 4K, so reads of about 4K are about
> twice as slow as they could by and reads of 1 byte are very slow
> because 4K is bzeroed for each byte read.  Reserving a page for the
> zero buffer would be a bit wasteful and the copyout to move the data
> is inelegant anyway.  Perhaps there should be a zeroout() function to
> optimize this important (;-) device.

...or only c bytes should be zero'ed out?

M

--
Mark Murray
46 Harvey Rd, Claremont, Cape Town 7700, South Africa
+27 21 61-3768 GMT+0200
Finger mark@grumble.grondar.za for PGP key



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510161902.VAA27145>