Esempio n. 1
0
    def test_assoc_set_pid(self, lib):
        "Tests assoc_set_pid() method."
        # pylint: disable=no-self-use

        lib.pqos_alloc_assoc_set_pid = MagicMock(return_value=0)

        alloc = PqosAlloc()
        alloc.assoc_set_pid(2, 1)

        lib.pqos_alloc_assoc_set_pid.assert_called_once_with(2, 1)
Esempio n. 2
0
    def test_assoc_set_pid(self, lib):
        "Tests assoc_set_pid() method."
        # pylint: disable=no-self-use

        lib.pqos_alloc_assoc_set_pid = MagicMock(return_value=0)

        alloc = PqosAlloc()
        alloc.assoc_set_pid(2, 1)

        lib.pqos_alloc_assoc_set_pid.assert_called_once_with(2, 1)
Esempio n. 3
0
from pqos import Pqos
from pqos.allocation import PqosAlloc


# Initialize PQoS library
pqos = Pqos()
pqos.init("OS")

alloc = PqosAlloc()

# Get PID of the current process
pid = os.getpid()

# Associate process with COS 1
print('Associating process %d with COS 1...' % pid)
alloc.assoc_set_pid(pid, 1)

# Get all processes associated with COS 1
print('Processes associated with COS 1:')
print(alloc.get_pids(1))

# Release association
print('Releasing association for process %d...' % pid)
alloc.release_pid([pid])

# Current process should not be associated with COS 1
print('Processes associated with COS 1:')
print(alloc.get_pids(1))
print('Is PID %d associated with COS 1?' % pid)
print('Yes' if pid in alloc.get_pids(1) else 'No')