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

Re: getloadavg and proc filesystem



> IMHO sprintf is not atomic - and thus a context switch at the wrong time
> will provide you with broken data...

> "%d.%02d %d.%02d %d.%02d %ld/%d %d\n"

In this particular case a context switch
wouldn't matter because all the arguments
are passed by value. There are no pointers.
But I'm actually curious about the sprintf
call not being atomic.

> > Something might happen if the /proc entry is big.
> > In this case, things get more complicated and
> > I still don't understand the details. I'm a newbie.
>
>
> The size of the file should make no difference
> upon whether it works or not, just how often it breaks
> (if it is indeed broken)...

I meant that if the proc entry is big, the callback
function might get called more than once for a single
read. That's how it's defined... But I have no experience
with this.

> Looks like I will have to go ask the kernel mailing list...

Yup please :) And tell us how it goes.

Regards.

--
Homepage : http://geocities.com/arhuaco

The first principle is that you must not fool yourself
and you are the easiest person to fool.
     -- Richard Feynman.



Reply to: