cpuallocator

package
v0.0.0-...-a2e9de6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

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

func (cpuAllocator *CPUAllocator) Allocate(uuid uuid.UUID, numCPUs int) ([]int, error)

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL