Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
RATECHECK(9)		    Kernel Developer's Manual		    RATECHECK(9)

NAME
     ratecheck, ppsratecheck -- event rate limiting

SYNOPSIS
     #include <sys/time.h>

     int
     ratecheck(struct timeval *lasttime, const struct timeval *mininterval);

     int
     ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps);

DESCRIPTION
     The  ratecheck and ppsratecheck functions facilitate rate-limiting of arbi-
     trary events.  The former enforces a minimum interval between events  while
     the latter enforces a maximum number of events per second.

     The ratecheck function compares the current time to the value pointed to by
     lasttime.	 If  the  difference is equal to or greater than mininterval, it
     returns a non-zero value and updates lasttime to the current time.   Other-
     wise, it returns zero.

     The  ppsratecheck function first compares the current time to lasttime.  If
     at least a full second has passed, the value pointed to by the curpps argu-
     ment is reset to 1 and lasttime is updated to the current time.  Otherwise,
     curpps is incremented and lasttime is  left  untouched.   In  either  case,
     ppsratecheck  returns a non-zero value if and only if the updated curpps is
     less than or equal to maxpps or maxpps is negative.

SEE ALSO
     counter(9)

HISTORY
     The ratecheck and ppsratecheck functions first appeared in FreeBSD 5.1.

FreeBSD 15.1			 March 11, 2022 		    RATECHECK(9)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=ppsratecheck&manpath=FreeBSD+15.1-RELEASE+and+Ports.quarterly>

home | help