unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan D." <jan.h.d@swipnet.se>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: alarm_signal_handler is called too frequently
Date: Fri, 29 Oct 2004 09:00:14 +0200	[thread overview]
Message-ID: <4181EA7E.2020309@swipnet.se> (raw)
In-Reply-To: <wlwtxaz4m3.wl@church.math.s.chiba-u.ac.jp>

YAMAMOTO Mitsuharu wrote:

> There may be some confusion between two kinds of timers: the OS-level
> alarm timer and the Emacs-level (cooperative?) timer.  The timer for
> Xt timeout events is the former, and the cursor blinking uses the
> latter.  The function timer_check is also for the latter.

Sorry, I misunderstood.  The timer_check is not run from popup_get_selection 
for popup menus because the argument do_timers is 0:

       if (do_timers && !XtAppPending (Xt_app_con))
         timer_check (1);

But for dialogs, do_timer is 1, so timers do get checked when a dialog is 
popped up.  However, idle timers are disabled because the event that popups the 
dialog makes Emacs non-idle.  But non-idle timers are run.  The check for 
INPUT_BLOCKED_P proposed by Richard in Feval does detect this:

   if (handling_signal || INPUT_BLOCKED_P)
     abort ();

I guess we just have to get rid of the call to timer_check in popup_get_selection.

> 
>>Since popups are within BLOCK/UNBLOCK__INPUT, the signal handler
>>just reschedules the alarm without running any timer code.
> 
> 
> Actually, the signal handler only sets the interval timer value
> (set_alarm) without calling schedule_atimer in this situation.  The
> new interval may become a small value, 1msec, by the following code in
> set_alarm.
> 
>       /* Don't set the interval to 0; this disables the timer.  */
>       if (EMACS_TIME_LE (atimers->expiration, now))
> 	{
> 	  EMACS_SET_SECS (time, 0);
> 	  EMACS_SET_USECS (time, 1000);
> 	}
> 
>       bzero (&it, sizeof it);
>       it.it_value = time;
>       setitimer (ITIMER_REAL, &it, 0);

By "reschedules the alarm" I meant that the code arranges for another SIGALRM 
to be delivered.  And yes, the time is 1 millisecond.

> 
> That's the reason why I did the following question:
> 
>   I think we don't have to call set_alarm when pending_atimers is
>   non-zero because do_pending_atimers is supposed to be called
>   eventually in such a case.  Is that correct?

You mean like this?

Index: atimer.c
*** atimer.c.~1.16.~    2004-07-19 12:53:25.000000000 +0200
--- atimer.c    2004-10-29 08:56:37.000000000 +0200
***************
*** 397,402 ****
--- 397,403 ----
         EMACS_GET_TIME (now);
       }

+   if (! (pending_atimers && interrupt_input_blocked))
       set_alarm ();
   }


That works and should save a couple of CPU cycles.

	Jan D.

  reply	other threads:[~2004-10-29  7:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-13  1:15 alarm_signal_handler is called too frequently YAMAMOTO Mitsuharu
2004-10-13 14:43 ` Richard Stallman
2004-10-14  5:16   ` YAMAMOTO Mitsuharu
2004-10-17  9:36     ` YAMAMOTO Mitsuharu
2004-10-25 13:13       ` Richard Stallman
2004-10-25 14:38         ` Jan D.
2004-10-27 10:47           ` Richard Stallman
2004-10-28 18:02             ` Jan D.
2004-10-29  1:37               ` YAMAMOTO Mitsuharu
2004-10-29  7:00                 ` Jan D. [this message]
2004-10-29  8:24                   ` YAMAMOTO Mitsuharu
2004-11-01  7:24                   ` Richard Stallman
2004-11-01  9:06                     ` Jan D.
2004-11-01 12:21                       ` Jan D.
2004-11-02 14:08                       ` Richard Stallman
2004-11-02 21:56                         ` Jan D.
2004-11-03 17:04                           ` Richard Stallman
2004-11-03 17:26                             ` Jan D.
2004-11-04 20:42                               ` Richard Stallman
2004-11-04 22:41                             ` Jan D.
2004-11-05 12:36                               ` Kim F. Storm
2004-11-06  5:22                                 ` Richard Stallman
2004-11-04 13:02                         ` Jan D.
2004-10-31  9:42               ` Richard Stallman
2004-10-31 15:11                 ` Jan D.

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4181EA7E.2020309@swipnet.se \
    --to=jan.h.d@swipnet.se \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).