fix:linux:fix the semaphore pend bugs, deal the timeout
@@ -157,6 +157,23 @@ static bool_t __semp_pend(osal_semp_t semp,int timeout)
{
struct timespec ts;
+ if(timeout == cn_osal_timeout_forever)
+ {
+ ///< wait until we get the semaphore
+ while(1)
+ {
+ clock_gettime(CLOCK_REALTIME, &ts);
+
+ ts.tv_sec += 10;
+ ts.tv_nsec += 0;
+ if(0 == sem_timedwait((sem_t *)semp, &ts))
+ {
+ return true;
+ }
+ }
+ }
+ else if(timeout >= 0)
+ {
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += (timeout / 1000);
@@ -170,6 +187,12 @@ static bool_t __semp_pend(osal_semp_t semp,int timeout)
return true;
}
}
+ else
+ {
+ ///< this is a overflow time, i think
+ return false;
+ }
+}
static bool_t __semp_post(osal_semp_t semp)
{
