Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I do something I think is simpler, and it is extremely portable. I use this on Linux and *BSD.

I just call nanosleep(2) based upon the amount if data processed. This is set by a parameter file that contains the sleep time and amount of data to determine when to sleep.

In programs I know will execute for a very long time, if the parameter file changes, parameters are adjusted during the run. Plus I will catch cancel signals to create a restart file should the program be cancelled.



Why?


Just saw this :)

Why ? On a laptop I have a program that will read an 8 billion record text file and matches it against a 1 billion record text file and doing some calculations based upon the data found between the 2 records.

So, slowing it down will prevent my laptop from overheating, it just runs quietly via a cron job.


cpulimit

Not all systems have cpulimit. I know NetBSD does not have it, there are people who do not live only on Linux.

I need something 100% portable between systems, what I do meets that requirement :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: