int main()
{
	int64_t timeStart,timeEnd;
	timeStart = getSystemTimeMs();
	pthread_t p1,p2,p3,p4;
	pthread_create(&p1,NULL,addNum,NULL);
	pthread_create(&p2,NULL,addNum,NULL);
	pthread_create(&p3,NULL,addNum,NULL);
	pthread_create(&p4,NULL,addNum,NULL);

	pthread_join(p1,NULL);
	pthread_join(p2,NULL);
	pthread_join(p3,NULL);
	pthread_join(p4,NULL);

	timeEnd = getSystemTimeMs();
	printf("thread lock->count:%lld, time use=%lldms\n",count, (timeEnd-timeStart));
	timeStart = getSystemTimeMs();
	pthread_create(&p1,NULL,addNum2,NULL);
	pthread_create(&p2,NULL,addNum2,NULL);
	pthread_create(&p3,NULL,addNum2,NULL);
	pthread_create(&p4,NULL,addNum2,NULL);

	pthread_join(p1,NULL);
	pthread_join(p2,NULL);
	pthread_join(p3,NULL);
	pthread_join(p4,NULL);
	timeEnd = getSystemTimeMs();
	printf("cas lock free->count2:%lld, time use=%lldms\n",count2, (timeEnd-timeStart));

	return 0;
}
示例#2
0
/*
 * if return 0, power off already
 * if 1, is doing this or not start
 * */
static int PowerOffHighVoltageStep(void)
{
	static UINT32 LastTimeMs = 0;
	UINT32 tNow = getSystemTimeMs();
	int systemState = getSystemState();
	UINT32 th = 0;
	int vcuCmd = BMS_GetVcuCmd();
	
	/*VCU操作时 只可能处于放电模式下*/
	if( systemState == SYSTEM_MODE_DISCHARGE)
	{
		if( vcuCmd == CMD_POWER_OFF )  /*vcu 关闭继电器*/
		{   
			PowerOffHV();
		}
	}
	
	/*如果出现一级异常, 发命令给VCU要求关闭,但VCU没有响应*/
	if( BMS_NeedPowerOff() == 1 ) 
	{
		th = TIME_TRHESHOLD_CAL(LastTimeMs, tNow);
		if( th> MAX_ALLOWED_REFLECT_TIME)
		{
			PowerOffHV();
		}
	}
	else
	{
		LastTimeMs = tNow;
	}
	return gPowerOffCmd;
}
示例#3
0
static int relayErrMonitor(void)
{
	UINT8 i = 0;
	UINT32 timeNow = getSystemTimeMs();
	for (i = 0; i < 4; i++)
	{
		if (isHighVolRelayOpOk(hightVolRelays[i].IoStatus.ioBits.Control,hightVolRelays[i].IoStatus.ioBits.Feedback))
		{
			if (hightVolRelays[i].relayTimers.errStart == 1)
			{
				if (hightVolRelays[i].errs.relayErrstatus == 0)
				{
					if (TIME_TRHESHOLD_CAL(
							hightVolRelays[i].relayTimers.errStartTimeMs,
							timeNow) > timeThresholdRealyOpTime)
					{
						if (hightVolRelays[i].IoStatus.ioBits.Control == 0)
						{
							hightVolRelays[i].errs.relayErrstatus =
									ERR_RELAY_SHUTDOWN;
						}
						else
						{
							hightVolRelays[i].errs.relayErrstatus =
									ERR_RELAY_OPEN;
						}
					}
				}
			}
			else
			{
				hightVolRelays[i].relayTimers.errStart = 1;
				hightVolRelays[i].relayTimers.errStartTimeMs =
						getSystemTimeMs();
			}
		}
		else
		{
			hightVolRelays[i].relayTimers.errStart = 0;
			hightVolRelays[i].errs.relayErrstatus = ERR_RELAY_NONE;
		}
	}
}
示例#4
0
文件: intc.c 项目: mildrock/batteryMs
static void INTC_CP_C(void)
{
	CP_flag++;
	if (CP_flag == 1)
	{
		CP_time1 = getSystemTimeMs();
	}
	else if (CP_flag == 2)
	{
		CP_time2 = getSystemTimeMs();
		if(SIU .GPDO[IO_STATUS_CP_C].R == 0)
		CP_high = TIME_TRHESHOLD_CAL(CP_time2, CP_time1);
	}
	else if(CP_flag == 3)
	{
	if(SIU .GPDO[IO_STATUS_CP_C].R == 0)
	CP_high = TIME_TRHESHOLD_CAL(CP_time3, CP_time2);
	CP_time3 = getSystemTimeMs();
	CP_time = TIME_TRHESHOLD_CAL(CP_time3, CP_time1);
	CP_flag = 0;
	Sys_flag = 0;
	}
	SIU .EISR.B.EIF11 = 1;
}
示例#5
0
文件: timer.c 项目: mildrock/Master
int test_timer_RTI(void)
{
	static UINT8 Sys_Flag = 0;
//  while (1)
	{
		if (getSystemTimeMs() % 500 == 0)
		{
			Sys_Flag = 1-Sys_Flag;
		}

		if (Sys_Flag)
		{
			gpio_set(LED_PORT, GPIO_HIGH);        	//在相应的管脚输出高电平
		}
		else
		{
			gpio_set(LED_PORT, GPIO_LOW);        	//在相应的管脚输出高电平
		}
	}
	return 0;
}
示例#6
0
int Check_VEH_CHARGER_UpperLimmitCurrent(void)
{
	static UINT32 CheckPWM_LastTimeMs = 0;
	static UINT32 LAST_VALUE = 0;
	UINT16 NOW_VALUE;
	UINT32 tNow = getSystemTimeMs();
	UINT32 th = 0;
	th = TIME_TRHESHOLD_CAL(CheckPWM_LastTimeMs, tNow);
	if( th> MAX_ALLOWED_CHECKPWM_TIME)
	{
		NOW_VALUE = GetPowerSupplyCurrentByPWM();
		if(NOW_VALUE!=LAST_VALUE)
		{
			VEH_CHARGER_UpperLimmitCurrent_Update();
			LAST_VALUE = NOW_VALUE;
		}
    }
	else
	{
		CheckPWM_LastTimeMs = tNow;
	}

}
示例#7
0
文件: timer.c 项目: mildrock/Master
void delay_ms(UINT32 ms)
{
	UINT32 lms = getSystemTimeMs();
	while (TIME_TRHESHOLD_CAL(g_time_ms, lms) < ms)
		;
}