[GRASS-dev] Re: [GRASS-user] [bug #3087] (grass) high cpu usage on mouse ops

Glynn Clements glynn at gclements.plus.com
Sat Jun 24 10:17:52 EDT 2006


Markus Neteler wrote:

> > > >>This bug's URL:
> > > >>http://intevation.de/rt/webrt?serial_num=3087
> > > >>
> ...
> > 
> > One portable method to sleep for a fraction of a second is to use
> > select() with all descriptor sets NULL, e.g.:
> > 
> >            struct timeval tv;
> > 
> >            tv.tv_sec = 0;
> >            tv.tv_usec = 500000;
> > 
> >            retval = select(0, NULL, NULL, NULL, &tv);
> 
> Surprising question:
>  Do we want to turn this somehow into a G_nanosleep()?

Probably, although G_usleep() would be more useful. I doubt that we
will ever need sub-microsecond precision, and using nanoseconds means
that you can't specify any value longer than ~4.3 seconds as a 32-bit
integer (whereas using microseconds allows ~72 minutes).

Also, the calls to sleep() (which isn't available on Windows) should
be replaced by G_sleep() (which can be implemented on top of
G_usleep()). The following files use sleep():

	display/d.colors/interact.c
	general/g.mapsets/main_cmd.c
	imagery/i.class/curses.c
	imagery/i.class/signature.c
	imagery/i.ortho.photo/menu/run.c
	imagery/i.ortho.photo/photo.2image/curses.c
	imagery/i.ortho.photo/photo.2target/curses.c
	imagery/i.ortho.photo/photo.2target/digit.c
	imagery/i.ortho.photo/photo.2target/mark.c
	imagery/i.ortho.photo/photo.rectify/ask_files.c
	imagery/i.ortho.photo/photo.rectify/env.c
	imagery/i.points/curses.c
	imagery/i.points/digit.c
	imagery/i.rectify/env.c
	imagery/i.vpoints/analyze.c
	imagery/i.vpoints/curses.c
	imagery/i.vpoints/digit.c
	imagery/i.vpoints/main.c
	lib/gis/sleep.c
	lib/raster/parse_mon.c
	lib/vask/V_error.c
	raster/r.le/r.le.setup/ask_group.c
	raster/r.le/r.le.setup/setup.c
	raster/r.le/r.le.trace/main.c
	vector/v.transform/ask_trans.c

BTW, nothing appears to use the *_ltp() functions in lib/gis/sleep.c.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list