On Sat, Jul 10, 2021 at 11:45:19AM +0800, Patrick Star wrote: > I saw flashrom process use too many cpu time when I use it to write > flashchip. > Then I strace the process, and found too many > "clock_gettime(CLOCK_MONOTONIC...)" system call. > And located it to udelay.c line 39, in function clock_usec_delay(). > So I replace the code with just usleep(), as below, > static void clock_usec_delay(int usecs) > { > usleep(usecs); > } > And it still worked well, and use much less cpu time, and the time spend on > erase&write a chip is basicly the same as before. > > Also I write image to a flashchip and read it out with the modified > flashrom many times, and the read out results are always same as the > original image. > > So why not use usleep() to save cpu time ? >
usleep() will sleep a whole lot longer than a few microseconds when the kernel isn't tickless; this could slow flashrom down drastically if for instance a usleep() will always sleep at least 10 milliseconds on a 100 Hz tick-based kernel. _______________________________________________ flashrom mailing list -- flashrom@flashrom.org To unsubscribe send an email to flashrom-le...@flashrom.org