Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CPUAllocator ¶
type CPUAllocator struct { sync.RWMutex // lock the access to the allocator CPUsUsedByUUIDs map[uuid.UUID]cpusList // per UUID list of allocated CPUs // contains filtered or unexported fields }
CPUAllocator stores information about the CPUs available in the system and provides interface to allocate and free them, per UUID.
func Init ¶
func Init(totalCPUs int, numReserved int) (*CPUAllocator, error)
Init initializes a CPUAllocator instance. totalCPUs is the number of CPUs available is the system, numReserved is the number of CPUs considered to be always free, reserved for the EVE services and VMs with no CPU pinning enabled.
func (*CPUAllocator) Allocate ¶
Allocate a list of CPUs for a given uuid. If the amount of available CPUs is less than the requested amount (numCPUs), return an error and an empty list. If an allocation for a given uuid was already done before, also return an error and an empty list.
func (*CPUAllocator) Free ¶
func (cpuAllocator *CPUAllocator) Free(uuid uuid.UUID) error
Free the CPUs previously allocated for a given uuid. Return an error for an attempt to free CPUs for a uuid that has no allocated CPUs.
func (*CPUAllocator) GetAllFree ¶
func (cpuAllocator *CPUAllocator) GetAllFree() []int
GetAllFree returns all free CPUs (except the reserved ones)