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

Function rte_thread_create

dpdk/lib/eal/unix/rte_thread.c:119–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117#endif
118
119int
120rte_thread_create(rte_thread_t *thread_id,
121 const rte_thread_attr_t *thread_attr,
122 rte_thread_func thread_func, void *args)
123{
124 int ret = 0;
125 pthread_attr_t attr;
126 pthread_attr_t *attrp = NULL;
127 struct sched_param param = {
128 .sched_priority = 0,
129 };
130 int policy = SCHED_OTHER;
131#ifndef RTE_EAL_PTHREAD_ATTR_SETAFFINITY_NP
132 struct thread_start_context ctx = {
133 .thread_func = thread_func,
134 .thread_args = args,
135 .thread_attr = thread_attr,
136 .wrapper_done = false,
137 .wrapper_mutex = PTHREAD_MUTEX_INITIALIZER,
138 .wrapper_cond = PTHREAD_COND_INITIALIZER,
139 };
140#endif
141
142 if (thread_attr != NULL) {
143 ret = pthread_attr_init(&attr);
144 if (ret != 0) {
145 RTE_LOG(DEBUG, EAL, "pthread_attr_init failed\n");
146 goto cleanup;
147 }
148
149 attrp = &attr;
150
151#ifdef RTE_EAL_PTHREAD_ATTR_SETAFFINITY_NP
152 if (CPU_COUNT(&thread_attr->cpuset) > 0) {
153 ret = pthread_attr_setaffinity_np(attrp, sizeof(thread_attr->cpuset),
154 &thread_attr->cpuset);
155 if (ret != 0) {
156 RTE_LOG(DEBUG, EAL, "pthread_attr_setaffinity_np failed\n");
157 goto cleanup;
158 }
159 }
160#endif
161 /*
162 * Set the inherit scheduler parameter to explicit,
163 * otherwise the priority attribute is ignored.
164 */
165 ret = pthread_attr_setinheritsched(attrp,
166 PTHREAD_EXPLICIT_SCHED);
167 if (ret != 0) {
168 RTE_LOG(DEBUG, EAL, "pthread_attr_setinheritsched failed\n");
169 goto cleanup;
170 }
171
172 if (thread_attr->priority ==
173 RTE_THREAD_PRIORITY_REALTIME_CRITICAL) {
174 ret = ENOTSUP;
175 goto cleanup;
176 }

Callers 14

rte_eal_initFunction · 0.50
dlb2_get_pp_allocationFunction · 0.50
test_non_eal_lcoresFunction · 0.50
test_thread_create_joinFunction · 0.50
test_thread_priorityFunction · 0.50
test_thread_affinityFunction · 0.50

Calls 5

pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85
rte_thread_joinFunction · 0.70
pthread_createFunction · 0.50

Tested by 9

test_non_eal_lcoresFunction · 0.40
test_thread_create_joinFunction · 0.40
test_thread_priorityFunction · 0.40
test_thread_affinityFunction · 0.40
process_dupFunction · 0.40