| 354 | } |
| 355 | |
| 356 | void OSCancelThread(OSThread* thread) |
| 357 | { |
| 358 | BOOL enabled; |
| 359 | |
| 360 | enabled = OSDisableInterrupts(); |
| 361 | |
| 362 | switch (thread->state) |
| 363 | { |
| 364 | case OS_THREAD_STATE_READY: |
| 365 | if (!(0 < thread->suspend)) |
| 366 | { |
| 367 | UnsetRun(thread); |
| 368 | } |
| 369 | break; |
| 370 | case OS_THREAD_STATE_RUNNING: |
| 371 | RunQueueHint = TRUE; |
| 372 | break; |
| 373 | case OS_THREAD_STATE_WAITING: |
| 374 | RemoveItem(thread->queue, thread, link); |
| 375 | thread->queue = NULL; |
| 376 | if (!(0 < thread->suspend) && thread->mutex) |
| 377 | { |
| 378 | UpdatePriority(thread->mutex->thread); |
| 379 | } |
| 380 | break; |
| 381 | default: |
| 382 | OSRestoreInterrupts(enabled); |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | OSClearContext(&thread->context); |
| 387 | if (thread->attr & OS_THREAD_ATTR_DETACH) |
| 388 | { |
| 389 | RemoveItem(&__OSActiveThreadQueue, thread, linkActive); |
| 390 | thread->state = 0; |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | thread->state = OS_THREAD_STATE_MORIBUND; |
| 395 | } |
| 396 | |
| 397 | __OSUnlockAllMutex(thread); |
| 398 | |
| 399 | OSWakeupThread(&thread->queueJoin); |
| 400 | |
| 401 | __OSReschedule(); |
| 402 | OSRestoreInterrupts(enabled); |
| 403 | |
| 404 | return; |
| 405 | } |
| 406 | |
| 407 | s32 OSResumeThread(OSThread* thread) |
| 408 | { |
no test coverage detected