Re: thread loops: prevent from 100% cpu usage?
- From: "Claudio Polegato Jr." <linux_djos hotmail com>
- To: jcupitt gmail com, f kater2 gmx net
- Cc: gtk-app-devel-list gnome org
- Subject: Re: thread loops: prevent from 100% cpu usage?
- Date: Thu, 01 Jul 2004 16:20:29 -0300
Hi,
When you are waiting for a signal, use signals routines. You can try use
select or poll if you are opening a file descriptor device.
[]'s
Claudio Polegato Junior
> my cpu uses 100% of the power due to a loop in a thread I use. How can I
> prevent from that? (The loop is waiting for a digital-I/O signal from an
> external device.)
You could try sleeping for a few milliseconds between tests. If you
can get an interrupt from the device, that's even better.
Use usleep(10000) to wait for 10 ms. Other threads will run while you
sleep.
_________________________________________________________________
MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]