Re: [AD] Windowed drivers color conversion

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, May 03, 2001 at 11:59:06PM +0200, Angelo Mottola wrote:
> About QNX Allegro, I've changed the events handling code to use a separated
> thread via pthreads, and now the port is a LOT more stable... Peter and
> George should be interested; also, can someone tell me how to assign
> priority to threads using pthreads? And how to give CPU time away? I've used
> sched_yield() but that doesn't seem to help as the CPU meter is still always
> set to 100%...

I don't know about priorities, it may be in the threading
attributes.  I think this sort of thing requires root privileges
though.

`sched_yield' relinquishes the CPU to any process in the same or
higher priority state.  If there are none, the current process
will continue.  I think this is also not a good thing to use in
this case because I think it is done on a process-by-process
basis, not thread-by-thread.

The best way to surrender the CPU is to use `select' or `poll'
to wait for input data on a file descriptor -- this should work
well for things like the keyboard.  In addition, the timer
driver could calculate the delay until its next `interrupt' and
use select's timeout (or usleep) to sleep for that period.  A
hitch here is that if the next interrupt isn't due for a while,
and the process installs a new timer handler, you want the timer
thread to wake up immediately and recalculate the delay (the new
handler might need to fire sooner than the old ones did).  In
this case, I think you can make the select or poll call wait for
data on a FIFO, and the main thread can just drop a byte into
the FIFO to wake up the thread early.

I hope that all makes sense. :)  How much of this code is
reusable in the Unix versions?  I'd been procrastinating doing
this, so I'm glad you've already done it now. :)

George




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/