From: "Rafał Miłecki" <zajec5@gmail.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: schedule (wait_event) vs. while
Date: Sat, 27 Feb 2010 10:52:09 +0100 [thread overview]
Message-ID: <b170af451002270152u228a46abr3b316da75b2fa3f0@mail.gmail.com> (raw)
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ł
next reply other threads:[~2010-02-27 9:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-27 9:52 Rafał Miłecki [this message]
2010-02-27 20:11 ` Roland Dreier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b170af451002270152u228a46abr3b316da75b2fa3f0@mail.gmail.com \
--to=zajec5@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®