From: "Yoshinori K. Okuji" <okuji@enbug.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: Idle time
Date: Thu, 9 Feb 2006 23:34:53 +0100 [thread overview]
Message-ID: <200602092334.53634.okuji@enbug.org> (raw)
In-Reply-To: <87y80ow7bl.fsf@xs4all.nl>
On Monday 06 February 2006 21:39, Marco Gerards wrote:
> Although it is not very important to handle those events, it can be
> nice and is efficient and easy to do. Here is some proposed function
> and interface:
>
> void grub_idle (int msec);
>
> When this function is called, GRUB will be idle for about MSEC
> milliseconds. When nothing can be sanely done with this time, some
> machine specific function is called instead of an idle loop.
> Otherwise some functions will be called that can be registered to run
> during idle time. But the next function will not be called it MSECS
> have passed.
In my opinion, the essential function would be something similar to pause in
POSIX, since the timer itself is an event.
If you want to stop CPU while waiting, the events must be hardware interrupts,
or triggered by hardware interrupts (such as a timer). Probably the most
difficult architecture is PC in this case, because the interrupt handling is
different between protected mode and real mode, and we may not interfere with
BIOS. Looking at Etherboot's experience, this should be feasible but not
trivial.
However, it is easy to make a fake component for this, so I don't object to
this. For example:
void
grub_pause (void)
{
grub_event_start ();
while (1)
if (grub_event_poll ())
break;
grub_event_stop ();
}
grub_uint32_t start_time;
unsigned long sleep_usecs;
void
grub_timer_event_start (void)
{
start_time = grub_get_rtc ();
}
int
grub_timer_event_poll (void)
{
grub_uint32_t duration;
duration = grub_get_rtc () - start_time;
if (duration * GRUB_TICKS_PER_SECOND * 1000000 >= sleep_usecs)
return 1;
return 0;
}
void
grub_timer_event_stop (void)
{
}
void
grub_usleep (unsigned long usecs)
{
sleep_usecs = usecs;
grub_pause ();
}
Okuji
next prev parent reply other threads:[~2006-02-09 22:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-06 20:39 Idle time Marco Gerards
2006-02-09 22:34 ` Yoshinori K. Okuji [this message]
2006-04-16 19:00 ` Marco Gerards
2006-04-16 20:22 ` Yoshinori K. Okuji
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=200602092334.53634.okuji@enbug.org \
--to=okuji@enbug.org \
--cc=grub-devel@gnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.