mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* schedule (wait_event) vs. while
@ 2010-02-27  9:52 Rafał Miłecki
  2010-02-27 20:11 ` Roland Dreier
  0 siblings, 1 reply; 2+ messages in thread
From: Rafał Miłecki @ 2010-02-27  9:52 UTC (permalink / raw)
  To: Linux Kernel Mailing List

In radeon engine reclocking code I need to do some calculations and
then wait for VBLANK interrupt. Right after VBLANK interrupt will
happen I need to reclock ASAP.

Interrupts are received by another context and I need some quite fast
synchronization.

1) Schedule solution:
reclocking() {
  calculations();
  radeon->vblank_sync = 0;
  wait_event_timeout(radeon->wq, radeon->vblank_sync, timeout);
  reclock();
}
i-handler() { radeon->vblank_sync = 1; }

2) While solution:
reclocking() {
  calculations();
  del_timer(radeon->fake_vblank);
  radeon->vblank_sync = 0;
  mod_timer(radeon->fake_vblank, 10ms);
  while(!radeon->vblank_sync);
  reclock();
}
i-handler() { radeon->vblank_sync = 1; }
fake-handler() { radeon->vblank_sync = 1; }

Of course first one is much cleaner but internally wait_event_timeout
uses schedule_timeout(). Now according to LDD3:
> Once a process releases the processor with schedule, there are no guarantees that the process will get the processor back anytime soon. Therefore, calling schedule in this manner is not a safe solution to the driver’s needs, in addition to being bad for the computing system as a whole. If you test jitsched while running load50, you can see that the delay associated to each line is extended by a few seconds, because other processes are using the CPU when the timeout expires.

I can not afford any delays because VBLANK is so short timeframe. Is
there any better solution?

-- 
Rafał

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-27 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-27  9:52 schedule (wait_event) vs. while Rafał Miłecki
2010-02-27 20:11 ` Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome