MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_thread_affinity

Function test_thread_affinity

dpdk/app/test/test_threads.c:129–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129static int
130test_thread_affinity(void)
131{
132 rte_thread_t thread_id;
133 rte_cpuset_t cpuset0;
134 rte_cpuset_t cpuset1;
135
136 thread_id_ready = 0;
137 RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, NULL) == 0,
138 "Failed to create thread");
139
140 while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
141 ;
142
143 RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset0) == 0,
144 "Failed to get thread affinity");
145 RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset1) == 0,
146 "Failed to get thread affinity");
147 RTE_TEST_ASSERT(memcmp(&cpuset0, &cpuset1, sizeof(rte_cpuset_t)) == 0,
148 "Affinity should be stable");
149
150 size_t i;
151 for (i = 1; i < CPU_SETSIZE; i++)
152 if (CPU_ISSET(i, &cpuset0)) {
153 CPU_ZERO(&cpuset0);
154 CPU_SET(i, &cpuset0);
155
156 break;
157 }
158 RTE_TEST_ASSERT(rte_thread_set_affinity_by_id(thread_id, &cpuset0) == 0,
159 "Failed to set thread affinity");
160 RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset1) == 0,
161 "Failed to get thread affinity");
162 RTE_TEST_ASSERT(memcmp(&cpuset0, &cpuset1, sizeof(rte_cpuset_t)) == 0,
163 "Affinity should be stable");
164
165 return 0;
166}
167
168static int
169test_thread_attributes_affinity(void)

Callers

nothing calls this directly

Calls 3

rte_thread_createFunction · 0.50

Tested by

no test coverage detected