A method and apparatus for scheduling and servicing events using a
calendar structure is described. In accordance with one preferred
embodiment of the present invention, a calendar structure is provided to
implement work-conserving methods (for example, queuing, such as fair
queuing, or, as one specific example, weighted fair queuing (WFQ)). Such
a calendar structure preferably provides two slots per tier and uses a
temporal pointer based on virtual time. In accordance with another
preferred embodiment of the present invention, a calendar structure is
provided to implement shaping of flows of information. Such a calendar
structure preferably provides one slot per tier and uses a temporal
pointer based on real time. For scheduling, a preferred occurrence time
at which an event is preferred to occur is calculated. Events having
preferred occurrence times farther from a current time value denoted by
the temporal pointer are scheduled on a calendar tiers of lower
resolution, while events having preferred occurrence times nearer to the
current time value denoted by the temporal pointer are scheduled on
calendar tiers of higher resolution. For servicing, the events are
selected from slots to which the temporal pointer is pointing. If a slot
is being used to schedule an event pending servicing, the slot is
considered to be an occupied slot. Occupied slots at higher resolution
calendar tiers are serviced exhaustively over occupied slots at lower
resolution calendar tiers.