MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / thread_start

Function thread_start

TactilityKernel/source/concurrent/thread.cpp:174–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174error_t thread_start(Thread* thread) {
175 thread->lock();
176 check(thread->mainFunction != nullptr);
177 check(thread->state == THREAD_STATE_STOPPED);
178 check(thread->stackSize);
179 thread->unlock();
180
181 thread_set_state_internal(thread, THREAD_STATE_STARTING);
182
183 thread->lock();
184 uint32_t stack_depth = thread->stackSize / sizeof(StackType_t);
185 enum ThreadPriority priority = thread->priority;
186 portBASE_TYPE affinity = thread->affinity;
187 thread->unlock();
188
189 BaseType_t result;
190 if (affinity != -1) {
191#ifdef ESP_PLATFORM
192 result = xTaskCreatePinnedToCore(
193 thread_main_body,
194 thread->name.c_str(),
195 stack_depth,
196 thread,
197 (UBaseType_t)priority,
198 &thread->taskHandle,
199 affinity
200 );
201#else
202 result = xTaskCreate(
203 thread_main_body,
204 thread->name.c_str(),
205 stack_depth,
206 thread,
207 (UBaseType_t)priority,
208 &thread->taskHandle
209 );
210#endif
211 } else {
212 result = xTaskCreate(
213 thread_main_body,
214 thread->name.c_str(),
215 stack_depth,
216 thread,
217 (UBaseType_t)priority,
218 &thread->taskHandle
219 );
220 }
221
222 if (result != pdPASS) {
223 thread_set_state_internal(thread, THREAD_STATE_STOPPED);
224 thread->lock();
225 thread->taskHandle = nullptr;
226 thread->unlock();
227 return ERROR_UNDEFINED;
228 }
229
230 return ERROR_NONE;
231}

Callers 1

ThreadTest.cppFile · 0.85

Calls 4

checkFunction · 0.50
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected