#define PTHREAD_CREATE(thread, attr,start_routine, arg) pthread_create(thread, attr,start_routine, arg)
#define PTHREAD_SETNAME_NP(thread, name) pthread_setname_np(thread, name)
#define PTHREAD_JOIN(thread, retval) pthread_join(thread, retval)
#define PTHREAD_EXIT(retval) pthread_exit(retval)
typedef pthread_t PTHREAD_T;
static PTHREAD_T P_RearSensorDetectThread = 0;
static BOOL P_RearSensorDetectExit;
void* P_RearSensor_Detection_Func(void *argv)
{
while (!P_SensorDetectExit)
{
//usleep(200*1000*1);
//sleep(1);
usleep(300000);
}
printf("[SM] P_RearSensor_Detection_Func: pthread_exit\n");
PTHREAD_EXIT(NULL);//task_exit:
return NULL;
}
void P_RearSensor_StartThread(void)
{
int ret = 0;
P_RearSensorDetectExit = FALSE;
if (0 != P_RearSensorDetectThread){
printf("P_RearSensorDetectThread alread start\n");
return;
}
ret = PTHREAD_CREATE(&P_RearSensorDetectThread, NULL, P_RearSensor_Detection_Func, NULL);
if (0 == ret)
PTHREAD_SETNAME_NP(P_RearSensorDetectThread, "Rearsensor_task");
else
printf("P_RearSensor_StartThread pthread_create failed\n");
return;
}
void P_RearSensor_StopThread(void)
{
P_RearSensorDetectExit = TRUE;
if (0 != P_RearSensorDetectThread)
{
PTHREAD_JOIN(P_RearSensorDetectThread, NULL);
P_RearSensorDetectThread = 0;
}
return;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.