| 276 | ****************************************************************************/ |
| 277 | |
| 278 | int work_usrstart(void) |
| 279 | { |
| 280 | int ret; |
| 281 | #ifndef CONFIG_BUILD_PROTECTED |
| 282 | pthread_t usrwork; |
| 283 | pthread_attr_t attr; |
| 284 | struct sched_param param; |
| 285 | #endif |
| 286 | |
| 287 | /* Initialize the work queue */ |
| 288 | |
| 289 | list_initialize(&g_usrwork.q); |
| 290 | |
| 291 | #ifdef CONFIG_BUILD_PROTECTED |
| 292 | |
| 293 | /* Start a user-mode worker thread for use by applications. */ |
| 294 | |
| 295 | ret = task_create("uwork", |
| 296 | CONFIG_LIBC_USRWORKPRIORITY, |
| 297 | CONFIG_LIBC_USRWORKSTACKSIZE, |
| 298 | work_usrthread, NULL); |
| 299 | if (ret < 0) |
| 300 | { |
| 301 | int errcode = get_errno(); |
| 302 | DEBUGASSERT(errcode > 0); |
| 303 | return -errcode; |
| 304 | } |
| 305 | |
| 306 | return ret; |
| 307 | #else |
| 308 | /* Start a user-mode worker thread for use by applications. */ |
| 309 | |
| 310 | pthread_attr_init(&attr); |
| 311 | pthread_attr_setstacksize(&attr, CONFIG_LIBC_USRWORKSTACKSIZE); |
| 312 | |
| 313 | pthread_attr_getschedparam(&attr, ¶m); |
| 314 | param.sched_priority = CONFIG_LIBC_USRWORKPRIORITY; |
| 315 | pthread_attr_setschedparam(&attr, ¶m); |
| 316 | |
| 317 | ret = pthread_create(&usrwork, &attr, work_usrthread, NULL); |
| 318 | if (ret != 0) |
| 319 | { |
| 320 | return -ret; |
| 321 | } |
| 322 | |
| 323 | /* Detach because the return value and completion status will not be |
| 324 | * requested. |
| 325 | */ |
| 326 | |
| 327 | pthread_detach(usrwork); |
| 328 | |
| 329 | return (pid_t)usrwork; |
| 330 | #endif |
| 331 | } |
| 332 | |
| 333 | #endif /* CONFIG_LIBC_USRWORK && !__KERNEL__*/ |
nothing calls this directly
no test coverage detected