Marc Roessler
09/30/2009 10:59 AM
post39082
|
Ok I digged a bit deeper into this now...
I found the following:
1. reading from the device's memory is no problem. Doing this will _not_ consume all CPU.
2. attaching an interrupt (and getting it) also is no problem. CPU is not hogged.
I'm using InterruptAttach() and MsgReceivePulse() (together with TimerTimeout) for waiting fot the interrupt.
Interrupt handler only runs once - I checked by incrementing a variable in the interrupt handler registered with
InterruptAttach(): value is 1 at program exit. Yes, unclean... but we got only one thread here and we don't modify the
variable from anywhere else. The interrupt is correctly reset from within the int handler.
3. only when you attach an interrupt, wait for that interrupt (wait for a pulse event with timeout, as indicated above)
and then start reading from the device via PCI, the CPU is hogged while the program runs/reads. Still, the interrupt
only occurs exactly once, so there is no flood of interrupts.
4. when starting the tool with "nice -3 ./tool", it does not change anything: cpu is hogged.
5. when you start the tool, let it sleep() for a few seconds after receiving the interrupt (before it starts to read via
PCI) and deliver a "slay -P 7 tool" while it is still sleeping, after the sleep it continues _without_ hogging the CPU.
..!
Any suggestions? Why does this hog the CPU when reading after an interrupt has occured? Why doesn't it hog when reading
without getting an interrupt first? Why does slay with the new prio work, but nice doesn't work? This is a single
threaded application, so there shouldn't be any magic going on here... I'm not creating new threads or processes
anywhere within this application.
Thanks,
Marc
|
|
|