| 75 | ****************************************************************************/ |
| 76 | |
| 77 | int nxthread_create(FAR const char *name, uint8_t ttype, int priority, |
| 78 | FAR void *stack_addr, int stack_size, main_t entry, |
| 79 | FAR char * const argv[], FAR char * const envp[]) |
| 80 | { |
| 81 | FAR struct tcb_s *tcb; |
| 82 | pid_t pid; |
| 83 | int ret; |
| 84 | |
| 85 | /* Allocate a TCB for the new task. */ |
| 86 | |
| 87 | tcb = kmm_zalloc(sizeof(struct tcb_s)); |
| 88 | if (!tcb) |
| 89 | { |
| 90 | serr("ERROR: Failed to allocate TCB\n"); |
| 91 | return -ENOMEM; |
| 92 | } |
| 93 | |
| 94 | /* Setup the task type */ |
| 95 | |
| 96 | tcb->flags = ttype | TCB_FLAG_FREE_TCB; |
| 97 | |
| 98 | /* Initialize the task */ |
| 99 | |
| 100 | ret = nxtask_init(tcb, name, priority, |
| 101 | stack_addr, stack_size, entry, argv, envp, NULL); |
| 102 | if (ret < OK) |
| 103 | { |
| 104 | kmm_free(tcb); |
| 105 | return ret; |
| 106 | } |
| 107 | |
| 108 | /* Get the assigned pid before we start the task */ |
| 109 | |
| 110 | pid = tcb->pid; |
| 111 | |
| 112 | /* Activate the task */ |
| 113 | |
| 114 | nxtask_activate(tcb); |
| 115 | |
| 116 | return pid; |
| 117 | } |
| 118 | |
| 119 | /**************************************************************************** |
| 120 | * Name: nxtask_create |
no test coverage detected