| 117 | #endif |
| 118 | |
| 119 | int |
| 120 | rte_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 | } |