Lines Matching refs:thread
113 static void OSi_CancelThreadAlarmForSleep(OSThread *thread);
114 static void OSi_InsertThreadToList(OSThread *thread);
115 static void OSi_RemoveThreadFromList(OSThread *thread);
120 static void OSi_ExitThread_ArgSpecified(OSThread *thread, void *arg);
157 static void OSi_InsertLinkToQueue(OSThreadQueue *queue, OSThread *thread) in OSi_InsertLinkToQueue() argument
161 while (next && next->priority <= thread->priority) in OSi_InsertLinkToQueue()
163 if (next == thread) in OSi_InsertLinkToQueue()
176 queue->head = thread; in OSi_InsertLinkToQueue()
180 prev->link.next = thread; in OSi_InsertLinkToQueue()
183 thread->link.prev = prev; in OSi_InsertLinkToQueue()
184 thread->link.next = NULL; in OSi_InsertLinkToQueue()
185 queue->tail = thread; in OSi_InsertLinkToQueue()
193 queue->head = thread; in OSi_InsertLinkToQueue()
197 prev->link.next = thread; in OSi_InsertLinkToQueue()
200 thread->link.prev = prev; in OSi_InsertLinkToQueue()
201 thread->link.next = next; in OSi_InsertLinkToQueue()
202 next->link.prev = thread; in OSi_InsertLinkToQueue()
248 static OSThread *OSi_RemoveSpecifiedLinkFromQueue(OSThreadQueue *queue, OSThread *thread) in OSi_RemoveSpecifiedLinkFromQueue() argument
258 if (t == thread) in OSi_RemoveSpecifiedLinkFromQueue()
372 static void OSi_InsertThreadToList(OSThread *thread) in OSi_InsertThreadToList() argument
377 while (t && t->priority < thread->priority) in OSi_InsertThreadToList()
385 thread->next = OSi_ThreadInfo.list; in OSi_InsertThreadToList()
386 OSi_ThreadInfo.list = thread; in OSi_InsertThreadToList()
390 thread->next = pre->next; in OSi_InsertThreadToList()
391 pre->next = thread; in OSi_InsertThreadToList()
404 static void OSi_RemoveThreadFromList(OSThread *thread) in OSi_RemoveThreadFromList() argument
409 while (t && t != thread) in OSi_RemoveThreadFromList()
419 OSi_ThreadInfo.list = thread->next; in OSi_RemoveThreadFromList()
423 pre->next = thread->next; in OSi_RemoveThreadFromList()
618 void OS_CreateThread(OSThread *thread, in OS_CreateThread() argument
647 thread->priority = prio; in OS_CreateThread()
648 thread->id = (u32)index; in OS_CreateThread()
649 thread->state = OS_THREAD_STATE_WAITING; in OS_CreateThread()
652 thread->profiler = NULL; in OS_CreateThread()
656 OSi_ThreadInfo.entry[index] = thread; in OS_CreateThread()
658 OSi_InsertThreadToList(thread); in OS_CreateThread()
661 thread->stackBottom = (u32)stack; in OS_CreateThread()
662 thread->stackTop = (u32)stack - stackSize; in OS_CreateThread()
663 thread->stackWarningOffset = 0; in OS_CreateThread()
666 …*(u32 *)(thread->stackBottom - sizeof(u32)*2) = OSi_STACK_CHECKNUM_BOTTOM; // minus for stack Chec… in OS_CreateThread()
667 *(u32 *)thread->stackTop = OSi_STACK_CHECKNUM_TOP; in OS_CreateThread()
670 OS_InitThreadQueue(&thread->joinQueue); in OS_CreateThread()
673 …OS_InitContext(&thread->context, (u32)func, (u32)stack - sizeof(u32)*2); // minus for stack CheckN… in OS_CreateThread()
675 thread->context.r[0] = (u32)arg; // argument for func in OS_CreateThread()
676 thread->context.lr = (u32)OS_ExitThread; in OS_CreateThread()
682 thread->mutex = NULL; in OS_CreateThread()
684 thread->mutexQueueHead = NULL; in OS_CreateThread()
685 thread->mutexQueueTail = NULL; in OS_CreateThread()
687 thread->mutexQueue.head = NULL; in OS_CreateThread()
688 thread->mutexQueue.tail = NULL; in OS_CreateThread()
693 OS_SetThreadDestructor(thread, NULL); in OS_CreateThread()
698 thread->queue = NULL; in OS_CreateThread()
699 thread->link.prev = thread->link.next = NULL; in OS_CreateThread()
702 MI_CpuClear32(&thread->specific[0], sizeof(void *) * OS_THREAD_SPECIFIC_MAX); in OS_CreateThread()
706 thread->alarmForSleep = NULL; in OS_CreateThread()
737 static void OSi_ExitThread_ArgSpecified(OSThread *thread, void *arg) in OSi_ExitThread_ArgSpecified() argument
741 OS_InitContext(&thread->context, (u32)OSi_ExitThread, (u32)OSi_StackForDestructor); in OSi_ExitThread_ArgSpecified()
742 thread->context.r[0] = (u32)arg; in OSi_ExitThread_ArgSpecified()
743 thread->context.cpsr |= HW_PSR_IRQ_DISABLE; in OSi_ExitThread_ArgSpecified()
744 thread->state = OS_THREAD_STATE_READY; in OSi_ExitThread_ArgSpecified()
745 OS_LoadContext(&thread->context); in OSi_ExitThread_ArgSpecified()
846 OSThread thread; in UTEST_OS_ExitThread() local
852 OS_CreateThread(&thread, in UTEST_OS_ExitThread()
856 OS_WakeupThreadDirect(&thread); in UTEST_OS_ExitThread()
857 OS_JoinThread(&thread); in UTEST_OS_ExitThread()
871 void OS_DestroyThread(OSThread *thread) in OS_DestroyThread() argument
875 SDK_ASSERT(thread); in OS_DestroyThread()
878 if (OS_GetCurrentThread() == thread) in OS_DestroyThread()
889 OSi_UnlockAllMutex(thread); in OS_DestroyThread()
892 OSi_CancelThreadAlarmForSleep(thread); in OS_DestroyThread()
895 if (thread->queue) in OS_DestroyThread()
897 (void)OSi_RemoveSpecifiedLinkFromQueue(thread->queue, thread); in OS_DestroyThread()
901 OSi_RemoveThreadFromList(thread); in OS_DestroyThread()
905 OSi_ThreadInfo.entry[thread->id] = NULL; in OS_DestroyThread()
907 thread->state = OS_THREAD_STATE_TERMINATED; in OS_DestroyThread()
910 OS_WakeupThread(&thread->joinQueue); in OS_DestroyThread()
932 static inline void OSi_KillThreadWithPriority(OSThread *thread, void *arg, u32 prio);
933 static inline void OSi_KillThreadWithPriority(OSThread *thread, void *arg, u32 prio) in OSi_KillThreadWithPriority() argument
935 SDK_ASSERT(thread); in OSi_KillThreadWithPriority()
938 …u32 stack = (OSi_StackForDestructor) ? (u32)OSi_StackForDestructor : thread->stackBottom - siz… in OSi_KillThreadWithPriority()
940 OS_InitContext(&thread->context, (u32)OSi_ExitThread, stack); in OSi_KillThreadWithPriority()
942 thread->context.r[0] = (u32)arg; in OSi_KillThreadWithPriority()
943 thread->context.cpsr |= HW_PSR_IRQ_DISABLE; // prohibit IRQ interrupts within the destructor in OSi_KillThreadWithPriority()
945 thread->state = OS_THREAD_STATE_READY; in OSi_KillThreadWithPriority()
948 (void)OS_SetThreadPriority(thread, prio); in OSi_KillThreadWithPriority()
953 void OS_KillThread(OSThread *thread, void *arg) in OS_KillThread() argument
955 OS_KillThreadWithPriority(thread, arg, OS_GetThreadPriority(thread)); in OS_KillThread()
958 void OS_KillThreadWithPriority(OSThread *thread, void *arg, u32 prio) in OS_KillThreadWithPriority() argument
962 if (thread == OS_GetCurrentThread()) in OS_KillThreadWithPriority()
964 OSi_ExitThread_ArgSpecified(thread, arg); in OS_KillThreadWithPriority()
969 OSi_CancelThreadAlarmForSleep(thread); in OS_KillThreadWithPriority()
971 OSi_KillThreadWithPriority(thread, arg, prio); in OS_KillThreadWithPriority()
983 OSThread thread; in UTEST_OS_KillThread_1() local
984 OSThread *t = &thread; in UTEST_OS_KillThread_1()
1031 OSThread thread; in UTEST_OS_KillThread_2() local
1037 OS_CreateThread(&thread, in UTEST_OS_KillThread_2()
1043 OS_WakeupThreadDirect(&thread); in UTEST_OS_KillThread_2()
1045 UT_AssertEq(thread.destructor, killThreadDtor); in UTEST_OS_KillThread_2()
1047 OS_WakeupThreadDirect(&thread); in UTEST_OS_KillThread_2()
1050 OS_KillThread(&thread, 0); in UTEST_OS_KillThread_2()
1051 OS_JoinThread(&thread); in UTEST_OS_KillThread_2()
1067 static void OSi_CancelThreadAlarmForSleep(OSThread *thread) in OSi_CancelThreadAlarmForSleep() argument
1069 OSAlarm *alarm = thread->alarmForSleep; in OSi_CancelThreadAlarmForSleep()
1086 void OS_JoinThread(OSThread *thread) in OS_JoinThread() argument
1090 SDK_ASSERT(thread); in OS_JoinThread()
1093 while(thread->state != OS_THREAD_STATE_TERMINATED) in OS_JoinThread()
1095 OS_SleepThread(&thread->joinQueue); in OS_JoinThread()
1110 BOOL OS_IsThreadTerminated(const OSThread *thread) in OS_IsThreadTerminated() argument
1112 SDK_ASSERT(thread); in OS_IsThreadTerminated()
1113 return (thread->state == OS_THREAD_STATE_TERMINATED) ? TRUE : FALSE; in OS_IsThreadTerminated()
1125 OSThreadState OS_GetThreadStatus(const OSThread *thread) in OS_GetThreadStatus() argument
1127 SDK_ASSERT(thread); in OS_GetThreadStatus()
1128 return thread->state; in OS_GetThreadStatus()
1141 void OS_SleepThreadDirect(OSThread *thread, OSThreadQueue *queue) in OS_SleepThreadDirect() argument
1143 SDK_ASSERT(thread); in OS_SleepThreadDirect()
1144 SDK_ASSERT(thread->state != OS_THREAD_STATE_TERMINATED); in OS_SleepThreadDirect()
1149 if ( thread->state == OS_THREAD_STATE_READY ) in OS_SleepThreadDirect()
1154 *queue |= (OSThreadQueue)(1UL << thread->id); in OS_SleepThreadDirect()
1156 thread->queue = queue; in OS_SleepThreadDirect()
1157 OSi_InsertLinkToQueue(queue, thread); in OS_SleepThreadDirect()
1160 thread->state = OS_THREAD_STATE_WAITING; in OS_SleepThreadDirect()
1257 OSThread *thread = OSi_RemoveLinkFromQueue(queue); in OS_WakeupThread() local
1259 thread->state = OS_THREAD_STATE_READY; in OS_WakeupThread()
1260 thread->queue = NULL; in OS_WakeupThread()
1261 thread->link.prev = thread->link.next = NULL; in OS_WakeupThread()
1282 void OS_WakeupThreadDirect(OSThread *thread) in OS_WakeupThreadDirect() argument
1286 SDK_ASSERT(thread); in OS_WakeupThreadDirect()
1287 SDK_ASSERT(thread->state != OS_THREAD_STATE_TERMINATED); in OS_WakeupThreadDirect()
1290 thread->state = OS_THREAD_STATE_READY; in OS_WakeupThreadDirect()
1427 OSThread *thread = OSi_ThreadInfo.entry[i]; in OS_DumpThreadList() local
1428 OS_Printf("%02d: %08x %5d %08x\n", i, thread, (thread) ? thread->priority : 0, in OS_DumpThreadList()
1429 (thread) ? thread->next : 0); in OS_DumpThreadList()
1435 OSThread *thread = OSi_ThreadInfo.list; in OS_DumpThreadList() local
1436 while (thread) in OS_DumpThreadList()
1439 OS_Printf("%02d: %08x %5d %08x %d %8x %8x %8x %8x\n", thread->id, thread, in OS_DumpThreadList()
1440 thread->priority, thread->next, thread->state, in OS_DumpThreadList()
1441 (thread->queue) ? thread->queue->head : (OSThread *)1, in OS_DumpThreadList()
1442 (thread->queue) ? thread->queue->tail : (OSThread *)1, thread->link.prev, in OS_DumpThreadList()
1443 thread->link.next); in OS_DumpThreadList()
1444 thread = thread->next; in OS_DumpThreadList()
1477 OSThread *thread = OSi_ThreadInfo.list; in OS_GetNumberOfThread() local
1478 while (thread) in OS_GetNumberOfThread()
1481 thread = thread->next; in OS_GetNumberOfThread()
1502 OSStackStatus OS_GetStackStatus(const OSThread *thread) in OS_GetStackStatus() argument
1505 if (*(u32 *)(thread->stackTop) != OSi_STACK_CHECKNUM_TOP) in OS_GetStackStatus()
1510 else if (thread->stackWarningOffset in OS_GetStackStatus()
1511 && *(u32 *)(thread->stackTop + thread->stackWarningOffset) != OSi_STACK_CHECKNUM_WARN) in OS_GetStackStatus()
1516 else if (*(u32 *)(thread->stackBottom - sizeof(u32)*2) != OSi_STACK_CHECKNUM_BOTTOM) in OS_GetStackStatus()
1546 void OSi_CheckStack(const char *file, int line, const OSThread *thread) in OSi_CheckStack() argument
1550 if ((st = OS_GetStackStatus(thread)) == OS_STACK_NO_ERROR) in OSi_CheckStack()
1556 thread, in OSi_CheckStack()
1557 thread->id, in OSi_CheckStack()
1559 thread->stackTop, thread->stackBottom, thread->stackWarningOffset); in OSi_CheckStack()
1611 void OS_SetThreadStackWarningOffset(OSThread *thread, u32 offset) in OS_SetThreadStackWarningOffset() argument
1614 SDK_ASSERTMSG(OS_GetThreadContext(thread)->sp > thread->stackTop + offset, in OS_SetThreadStackWarningOffset()
1618 thread->stackWarningOffset = offset; in OS_SetThreadStackWarningOffset()
1623 *(u32 *)(thread->stackTop + offset) = OSi_STACK_CHECKNUM_WARN; in OS_SetThreadStackWarningOffset()
1637 BOOL OS_SetThreadPriority(OSThread *thread, u32 prio) in OS_SetThreadPriority() argument
1645 SDK_ASSERTMSG(thread != &OSi_IdleThread, "cannot change idle thread priority."); in OS_SetThreadPriority()
1649 while (t && t != thread) in OS_SetThreadPriority()
1667 OSi_ThreadInfo.list = thread->next; in OS_SetThreadPriority()
1671 pre->next = thread->next; in OS_SetThreadPriority()
1675 thread->priority = prio; in OS_SetThreadPriority()
1676 OSi_InsertThreadToList(thread); in OS_SetThreadPriority()
1696 u32 OS_GetThreadPriority(const OSThread *thread) in OS_GetThreadPriority() argument
1698 SDK_ASSERTMSG(thread, "OS_GetThreadPriority: bad thread"); in OS_GetThreadPriority()
1700 return thread->priority; in OS_GetThreadPriority()
1903 void OS_SetThreadDestructor(OSThread *thread, OSThreadDestructor dtor) in OS_SetThreadDestructor() argument
1905 SDK_ASSERT(thread); in OS_SetThreadDestructor()
1906 thread->destructor = dtor; in OS_SetThreadDestructor()
1918 OSThreadDestructor OS_GetThreadDestructor(const OSThread *thread) in OS_GetThreadDestructor() argument
1920 SDK_ASSERT(thread); in OS_GetThreadDestructor()
1921 return thread->destructor; in OS_GetThreadDestructor()
1934 void OS_SetThreadParameter(OSThread *thread, void *parameter) in OS_SetThreadParameter() argument
1936 SDK_ASSERT(thread); in OS_SetThreadParameter()
1937 thread->userParameter = parameter; in OS_SetThreadParameter()
1949 void *OS_GetThreadParameter(const OSThread *thread) in OS_GetThreadParameter() argument
1951 SDK_ASSERT(thread); in OS_GetThreadParameter()
1952 return thread->userParameter; in OS_GetThreadParameter()
1967 void OSi_SetSystemErrno(OSThread *thread, int errno) in OSi_SetSystemErrno() argument
1969 SDK_ASSERT(thread); in OSi_SetSystemErrno()
1970 thread->systemErrno = errno; in OSi_SetSystemErrno()
1982 int OSi_GetSystemErrno(const OSThread *thread) in OSi_GetSystemErrno() argument
1984 SDK_ASSERT(thread); in OSi_GetSystemErrno()
1985 return thread->systemErrno; in OSi_GetSystemErrno()
1999 OSThread *thread = OSi_GetCurrentThread(); in OS_GetErrno() local
2000 return OSi_GetSystemErrno(thread); in OS_GetErrno()
2013 BOOL OS_IsThreadInList(const OSThread *thread) in OS_IsThreadInList() argument
2021 if (t == thread) in OS_IsThreadInList()