Add thread name to Win32Thread.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2541 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
911cbb5793
commit
ac9c373d7f
|
@ -39,6 +39,18 @@ typedef struct
|
|||
DWORD ThreadID;
|
||||
}win_thread_t;
|
||||
|
||||
const DWORD MS_VC_EXCEPTION=0x406D1388;
|
||||
|
||||
#pragma pack(push,8)
|
||||
typedef struct tagTHREADNAME_INFO
|
||||
{
|
||||
DWORD dwType; // Must be 0x1000.
|
||||
LPCSTR szName; // Pointer to name (in user addr space).
|
||||
DWORD dwThreadID; // Thread ID (-1=caller thread).
|
||||
DWORD dwFlags; // Reserved for future use, must be zero.
|
||||
} THREADNAME_INFO;
|
||||
#pragma pack(pop)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* LOCAL DEFINES
|
||||
|
@ -97,6 +109,23 @@ rt_uint32_t SysTickInterruptHandle(void);
|
|||
static DWORD WINAPI ThreadforSysTickTimer(LPVOID lpParam);
|
||||
static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam);
|
||||
|
||||
static void SetThreadName(DWORD dwThreadID, char* threadName)
|
||||
{
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = threadName;
|
||||
info.dwThreadID = dwThreadID;
|
||||
info.dwFlags = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* rt_hw_stack_init()
|
||||
|
@ -110,10 +139,13 @@ static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam);
|
|||
|
||||
static DWORD WINAPI thread_run( LPVOID lpThreadParameter )
|
||||
{
|
||||
rt_thread_t tid = rt_thread_self();
|
||||
win_thread_t *pWinThread = (win_thread_t *)lpThreadParameter;
|
||||
|
||||
SetThreadName(GetCurrentThreadId(), tid->name);
|
||||
|
||||
pWinThread->Entry(pWinThread->Param);
|
||||
|
||||
printf("thread %x exit\n", pWinThread->ThreadID);
|
||||
pWinThread->Exit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -154,9 +186,6 @@ rt_uint8_t* rt_hw_stack_init(void *pEntry,void *pParam,rt_uint8_t *pStackAddr,vo
|
|||
return (rt_uint8_t*)pWinThread;
|
||||
} /*** rt_hw_stack_init ***/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* rt_hw_interrupt_disable()
|
||||
|
@ -222,7 +251,7 @@ void rt_hw_context_switch_interrupt(rt_uint32_t from,
|
|||
|
||||
rt_interrupt_to_thread = *((rt_uint32_t *)(to));
|
||||
|
||||
//trigger YIELD exception(cause contex switch)
|
||||
//trigger YIELD exception(cause context switch)
|
||||
TriggerSimulateInterrupt(CPU_INTERRUPT_YIELD);
|
||||
} /*** rt_hw_context_switch_interrupt ***/
|
||||
|
||||
|
|
Loading…
Reference in New Issue