Skip to content

Instantly share code, notes, and snippets.

@xixitalk
Created July 9, 2016 02:15
Show Gist options
  • Save xixitalk/5c176a78a8743465061ef15ab5f9a248 to your computer and use it in GitHub Desktop.
Save xixitalk/5c176a78a8743465061ef15ab5f9a248 to your computer and use it in GitHub Desktop.
UINT32引起的死循环
SINT32 txsem_count_init(Semaphore *ptxSem)
{
UINT32 i = 0;
UINT32 semCount = 0;
UINT32 Count = 0;
semCount = GetSemaphoreCount(ptxSem);
Count = SEM_INIT_NUM - semCount;
if (Count > 0)
{
for( i=0;i<Count;i++)
{
PutSemaphore(ptxSem);
}
}
else if (Count < 0)
{
Count = 0 - Count;
for(i = 0;i<Count;i++)
{
GetSemaphore(ptxSem);
}
}
return SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment