diff options
author | amurai <amurai@FreeBSD.org> | 1995-03-11 15:18:55 +0000 |
---|---|---|
committer | amurai <amurai@FreeBSD.org> | 1995-03-11 15:18:55 +0000 |
commit | 4e41b74b9d21768a96f51254ed346d04bb4405af (patch) | |
tree | 37ea926bbfbf0a7fb4adb214f5262d8872ba5a52 /usr.sbin/ppp/timer.c | |
parent | 9b4b6386ecfab11f456999cadd482f36e97e6938 (diff) | |
download | FreeBSD-src-4e41b74b9d21768a96f51254ed346d04bb4405af.zip FreeBSD-src-4e41b74b9d21768a96f51254ed346d04bb4405af.tar.gz |
1.Reducing cpu usage at off connection.
2.Implment Redail function as working correctly.
3.Clean up a code as I notice.
4.Now, RTT getting close to 50ms with ISDN/TA 38400bps !!
Reviewed by: amurai@spec.co.jp
Submitted by: amurai@spec.co.jp
Diffstat (limited to 'usr.sbin/ppp/timer.c')
-rw-r--r-- | usr.sbin/ppp/timer.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c index 3792103..b91fbcd 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id:$ + * $Id: timer.c,v 1.2 1995/02/26 12:18:01 amurai Exp $ * * TODO: */ @@ -85,8 +85,10 @@ struct pppTimer *tp; tp->next = t; if (pt) { pt->next = tp; - } else + } else { + InitTimerService(); TimerList = tp; + } if (t) t->rest -= tp->rest; @@ -120,10 +122,13 @@ struct pppTimer *tp; for (t = TimerList; t != tp && t !=NULL ; t = t->next) pt = t; if (t) { - if (pt) + if (pt) { pt->next = t->next; - else + } else { TimerList = t->next; + if ( TimerList == NULL ) /* Last one ? */ + TermTimerService(); /* Terminate Timer Service */ + } if (t->next) t->next->rest += tp->rest; } else { @@ -160,6 +165,8 @@ TimerService() } while (tp && (tp->rest == 0)); TimerList = tp; + if ( TimerList == NULL ) /* No timers ? */ + TermTimerService(); /* Terminate Timer Service */ #ifdef DEBUG logprintf("TimerService: next is %x(%d)\n", TimerList, TimerList? TimerList->rest : 0); @@ -222,9 +229,6 @@ u_int sleep( u_int sec ) /* Calculate timeout value for select */ to.tv_sec = sld / 1000000; to.tv_usec = sld % 1000000; - - /* Forwarding signal as normal */ - kill(getpid(), SIGALRM); } } } @@ -255,9 +259,29 @@ void usleep( u_int usec) to.tv_sec = sld / 1000000; to.tv_usec = sld % 1000000; - /* Forwarding signal as normal */ - kill(getpid(), SIGALRM); } } } + +void InitTimerService( void ) { + struct itimerval itimer; + + signal(SIGALRM, (void (*)(int))TimerService); + itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0; + itimer.it_interval.tv_usec = itimer.it_value.tv_usec = TICKUNIT; + setitimer(ITIMER_REAL, &itimer, NULL); +} + +void TermTimerService( void ) { + struct itimerval itimer; + + itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0; + itimer.it_value.tv_usec = itimer.it_value.tv_sec = 0; + setitimer(ITIMER_REAL, &itimer, NULL); + /* + * Notes: after disabling timer here, we will get one + * SIGALRM will be got. + */ + signal(SIGALRM, SIG_IGN); +} #endif |