Mercurial > emacs
comparison src/msdos.c @ 15033:9e174c2b4ba6
(check_timer): Removed; use gettime instead.
(sys_select): Call __dpmi_yield while waiting for input to
improve multitasking behaviour.
Do not check timer when no timeout.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 16 Apr 1996 20:41:24 +0000 |
parents | 3bafb8029b86 |
children | e6464ccca756 |
comparison
equal
deleted
inserted
replaced
15032:0d32c8a2ae39 | 15033:9e174c2b4ba6 |
---|---|
2694 unrequest_sigio () {} | 2694 unrequest_sigio () {} |
2695 | 2695 |
2696 #ifndef HAVE_SELECT | 2696 #ifndef HAVE_SELECT |
2697 #include "sysselect.h" | 2697 #include "sysselect.h" |
2698 | 2698 |
2699 static struct time last_time = {120, 120, 120, 120}; | |
2700 | |
2701 static void | |
2702 check_timer (t) | |
2703 struct time *t; | |
2704 { | |
2705 int sec, min, hour, hund; | |
2706 | |
2707 gettime (t); | |
2708 sec = t->ti_sec; | |
2709 hund = t->ti_hund; | |
2710 hour = t->ti_hour; | |
2711 min = t->ti_min; | |
2712 | |
2713 /* Any chance of not getting here 24 hours or more since last time? */ | |
2714 if (hour == last_time.ti_hour | |
2715 && min == last_time.ti_min | |
2716 && sec == last_time.ti_sec) | |
2717 return; | |
2718 | |
2719 last_time = *t; | |
2720 } | |
2721 | |
2722 #ifndef EMACS_TIME_ZERO_OR_NEG_P | 2699 #ifndef EMACS_TIME_ZERO_OR_NEG_P |
2723 #define EMACS_TIME_ZERO_OR_NEG_P(time) \ | 2700 #define EMACS_TIME_ZERO_OR_NEG_P(time) \ |
2724 ((long)(time).tv_sec < 0 \ | 2701 ((long)(time).tv_sec < 0 \ |
2725 || ((time).tv_sec == 0 \ | 2702 || ((time).tv_sec == 0 \ |
2726 && (long)(time).tv_usec <= 0)) | 2703 && (long)(time).tv_usec <= 0)) |
2755 | 2732 |
2756 /* If we are looking only for the terminal, with no timeout, | 2733 /* If we are looking only for the terminal, with no timeout, |
2757 just read it and wait -- that's more efficient. */ | 2734 just read it and wait -- that's more efficient. */ |
2758 if (!timeout) | 2735 if (!timeout) |
2759 { | 2736 { |
2760 do | 2737 while (!detect_input_pending ()) |
2761 check_timer (&t); /* check timer even if some input is pending */ | 2738 { |
2762 while (!detect_input_pending ()); | 2739 #if __DJGPP__ >= 2 |
2740 __dpmi_yield (); | |
2741 #endif | |
2742 } | |
2763 } | 2743 } |
2764 else | 2744 else |
2765 { | 2745 { |
2766 EMACS_TIME clnow, cllast, cldiff; | 2746 EMACS_TIME clnow, cllast, cldiff; |
2767 | 2747 |
2768 check_timer (&t); | 2748 gettime (&t); |
2769 EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L); | 2749 EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L); |
2770 | 2750 |
2771 while (!check_input || !detect_input_pending ()) | 2751 while (!check_input || !detect_input_pending ()) |
2772 { | 2752 { |
2773 check_timer (&t); | 2753 gettime (&t); |
2774 EMACS_SET_SECS_USECS (clnow, t.ti_sec, t.ti_hund * 10000L); | 2754 EMACS_SET_SECS_USECS (clnow, t.ti_sec, t.ti_hund * 10000L); |
2775 EMACS_SUB_TIME (cldiff, clnow, cllast); | 2755 EMACS_SUB_TIME (cldiff, clnow, cllast); |
2776 | 2756 |
2777 /* When seconds wrap around, we assume that no more than | 2757 /* When seconds wrap around, we assume that no more than |
2778 1 minute passed since last `check_timer'. */ | 2758 1 minute passed since last `gettime'. */ |
2779 if (EMACS_TIME_NEG_P (cldiff)) | 2759 if (EMACS_TIME_NEG_P (cldiff)) |
2780 EMACS_SET_SECS (cldiff, EMACS_SECS (cldiff) + 60); | 2760 EMACS_SET_SECS (cldiff, EMACS_SECS (cldiff) + 60); |
2781 EMACS_SUB_TIME (*timeout, *timeout, cldiff); | 2761 EMACS_SUB_TIME (*timeout, *timeout, cldiff); |
2782 | 2762 |
2783 /* Stop when timeout value crosses zero. */ | 2763 /* Stop when timeout value crosses zero. */ |
2784 if (EMACS_TIME_ZERO_OR_NEG_P (*timeout)) | 2764 if (EMACS_TIME_ZERO_OR_NEG_P (*timeout)) |
2785 return 0; | 2765 return 0; |
2786 cllast = clnow; | 2766 cllast = clnow; |
2767 #if __DJGPP__ >= 2 | |
2768 __dpmi_yield (); | |
2769 #endif | |
2787 } | 2770 } |
2788 } | 2771 } |
2789 | 2772 |
2790 FD_SET (0, rfds); | 2773 FD_SET (0, rfds); |
2791 return 1; | 2774 return 1; |