| 400 | ****************************************************************************/ |
| 401 | |
| 402 | static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, int priority, |
| 403 | start_t start, CODE void *entry, |
| 404 | uint8_t ttype) |
| 405 | { |
| 406 | FAR struct tcb_s *rtcb = this_task(); |
| 407 | irqstate_t flags; |
| 408 | int ret; |
| 409 | |
| 410 | /* Assign a unique task ID to the task. */ |
| 411 | |
| 412 | ret = nxtask_assign_pid(tcb); |
| 413 | if (ret == OK) |
| 414 | { |
| 415 | /* Save task priority and entry point in the TCB */ |
| 416 | |
| 417 | tcb->sched_priority = (uint8_t)priority; |
| 418 | tcb->init_priority = (uint8_t)priority; |
| 419 | #ifdef CONFIG_PRIORITY_INHERITANCE |
| 420 | tcb->base_priority = (uint8_t)priority; |
| 421 | #endif |
| 422 | tcb->start = start; |
| 423 | tcb->entry.main = (main_t)entry; |
| 424 | |
| 425 | /* Save the thread type. This setting will be needed in |
| 426 | * up_initial_state() is called. |
| 427 | */ |
| 428 | |
| 429 | ttype &= TCB_FLAG_TTYPE_MASK; |
| 430 | tcb->flags &= ~TCB_FLAG_TTYPE_MASK; |
| 431 | tcb->flags |= ttype; |
| 432 | |
| 433 | /* Set the appropriate scheduling policy in the TCB */ |
| 434 | |
| 435 | tcb->flags &= ~TCB_FLAG_POLICY_MASK; |
| 436 | #if CONFIG_RR_INTERVAL > 0 |
| 437 | tcb->flags |= TCB_FLAG_SCHED_RR; |
| 438 | tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); |
| 439 | #else |
| 440 | tcb->flags |= TCB_FLAG_SCHED_FIFO; |
| 441 | #endif |
| 442 | |
| 443 | /* Save the task ID of the parent task in the TCB and allocate |
| 444 | * a child status structure. |
| 445 | */ |
| 446 | |
| 447 | nxtask_save_parent(tcb, ttype); |
| 448 | |
| 449 | #ifdef CONFIG_SMP |
| 450 | /* exec(), task_create(), and vfork() all inherit the affinity mask |
| 451 | * from the parent thread. This is the default for pthread_create() |
| 452 | * as well but the affinity mask can be specified in the pthread |
| 453 | * attributes as well. pthread_create() will have to fix up the |
| 454 | * affinity mask in this case. |
| 455 | */ |
| 456 | |
| 457 | nxtask_inherit_affinity(tcb); |
| 458 | #endif |
| 459 |
no test coverage detected