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

Function test_thread_attributes_affinity

dpdk/app/test/test_threads.c:168–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168static int
169test_thread_attributes_affinity(void)
170{
171 rte_thread_t thread_id;
172 rte_thread_attr_t attr;
173 rte_cpuset_t cpuset0;
174 rte_cpuset_t cpuset1;
175
176 RTE_TEST_ASSERT(rte_thread_attr_init(&attr) == 0,
177 "Failed to initialize thread attributes");
178
179 CPU_ZERO(&cpuset0);
180 RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset0) == 0,
181 "Failed to get thread affinity");
182 RTE_TEST_ASSERT(rte_thread_attr_set_affinity(&attr, &cpuset0) == 0,
183 "Failed to set thread attributes affinity");
184 RTE_TEST_ASSERT(rte_thread_attr_get_affinity(&attr, &cpuset1) == 0,
185 "Failed to get thread attributes affinity");
186 RTE_TEST_ASSERT(memcmp(&cpuset0, &cpuset1, sizeof(rte_cpuset_t)) == 0,
187 "Affinity should be stable");
188
189 thread_id_ready = 0;
190 RTE_TEST_ASSERT(rte_thread_create(&thread_id, &attr, thread_main, NULL) == 0,
191 "Failed to create attributes affinity thread.");
192
193 while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
194 ;
195
196 RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset1) == 0,
197 "Failed to get attributes thread affinity");
198 RTE_TEST_ASSERT(memcmp(&cpuset0, &cpuset1, sizeof(rte_cpuset_t)) == 0,
199 "Failed to apply affinity attributes");
200
201 __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE);
202
203 return 0;
204}
205
206static int
207test_thread_attributes_priority(void)

Callers

nothing calls this directly

Calls 6

rte_thread_attr_initFunction · 0.85
rte_thread_selfFunction · 0.50
rte_thread_createFunction · 0.50

Tested by

no test coverage detected