All of lore.kernel.org
 help / color / mirror / Atom feed
* Idle time
@ 2006-02-06 20:39 Marco Gerards
  2006-02-09 22:34 ` Yoshinori K. Okuji
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Gerards @ 2006-02-06 20:39 UTC (permalink / raw)
  To: grub-devel

Hi,

When GRUB is idle (for example, waiting for keyboard input) it is
very active with busy waiting.  This has some problems and besides
that, we can make good use of this time.

First the problems.  One GRUB user on some IRC channel I am in was
complaining that GRUB on qemu consumed a lot of CPU power.  He was
entering GRUB commands on the GRUB console and his machine got slow.
With a timeout GRUB will consume power on laptops.  Perhaps it's not
much, but it would be nice if we could fix this somehow.

My main motivation is that it would be nice if sometimes events can be
handled.  For example, Okuji and Vincent were talking about the play
command and how it should keep playing music in the background.  My
motivation to ask this is to handle network events (ARP and ICMP).

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.

So we need some functions to register and deregister callback
functions.  And in input loops we have to add grub_idle.  That's all
and it will fix the problems above and give us a nice feature (one
that should be handled with a *LOT* of care).

Please let me know if you have problems with such interface.

--
Marco




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

* Re: Idle time
  2006-02-06 20:39 Idle time Marco Gerards
@ 2006-02-09 22:34 ` Yoshinori K. Okuji
  2006-04-16 19:00   ` Marco Gerards
  0 siblings, 1 reply; 4+ messages in thread
From: Yoshinori K. Okuji @ 2006-02-09 22:34 UTC (permalink / raw)
  To: The development of GRUB 2

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



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

* Re: Idle time
  2006-02-09 22:34 ` Yoshinori K. Okuji
@ 2006-04-16 19:00   ` Marco Gerards
  2006-04-16 20:22     ` Yoshinori K. Okuji
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Gerards @ 2006-04-16 19:00 UTC (permalink / raw)
  To: The development of GRUB 2

"Yoshinori K. Okuji" <okuji@enbug.org> writes:

> 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.

I think there is some CPU based functionality for this as well.

> However, it is easy to make a fake component for this, so I don't object to 
> this. For example:

I had a slightly different model in mind, although it looks like
yours.  How about me start getting coding, submit a patch and we can
talk about that?

After this I can do some networking hacking.  Which I want to submit
within a month or so.

Thanks,
Marco




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

* Re: Idle time
  2006-04-16 19:00   ` Marco Gerards
@ 2006-04-16 20:22     ` Yoshinori K. Okuji
  0 siblings, 0 replies; 4+ messages in thread
From: Yoshinori K. Okuji @ 2006-04-16 20:22 UTC (permalink / raw)
  To: The development of GRUB 2

On Sunday 16 April 2006 21:00, Marco Gerards wrote:
> I had a slightly different model in mind, although it looks like
> yours.  How about me start getting coding, submit a patch and we can
> talk about that?

No problem.

Okuji



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

end of thread, other threads:[~2006-04-16 20:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-06 20:39 Idle time Marco Gerards
2006-02-09 22:34 ` Yoshinori K. Okuji
2006-04-16 19:00   ` Marco Gerards
2006-04-16 20:22     ` Yoshinori K. Okuji

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.