File cmb_resourcepool.h

Parent directory (include)

A counting semaphore that supports acquire(), release(), and preempt() in specific amounts against a fixed resource capacity, where a process also can acquire more of a resource it already holds some amount of, or release parts of its holding. Several processes can be holding parts of the resource capacity at the same time, possibly also different amounts.

Definition (include/cmb_resourcepool.h)

Detailed Description

The resource pool adds numeric values for capacity and usage to the simple cmb_resource. These values are unsigned integers to avoid any rounding issues from floating-point calculations, both faster and higher resolution (if scaled properly to 64-bit range).

It assigns requested amounts to processes in a greedy fashion. The acquiring process will first grab whatever amount is available, then wait for some more to become available, repeat until the requested amount is acquired, and it eventually returns from the call.

Preemption is similar to acquisition, except that the preempting process also will grab resources from any lower-priority processes holding some.

The holders list is now a hashheap, since we may need to handle many separate processes acquiring, holding, releasing, and preempting various amounts of the resource capacity. The hashheap is sorted to keep the holder most likely to be preempted at the front, i.e., the lowest priority and last in.

Includes

Included By

Classes

Functions