问题描述
我已经创建了一个这样的定时器,它可以工作,但是当我想创建两个定时器一起工作时,只有一个定时器的回调函数可以工作,请帮忙,谢谢:
EFI_STATUS TimerInit()
{
EFI_STATUS Status;
EFI_HANDLE TimerOne = NULL;
//BOOLEAN ExitMark = FALSE;
static const UINTN SecondsToNanoSeconds = 1000000;
Status = gBS->CreateEvent(
EVT_NOTIFY_SIGNAL | EVT_TIMER,TPL_CALLBACK,TimeoutSelf,NULL,&TimerOne
);
if ( EFI_ERROR( Status ) )
{
Print( L"Create Event Error! \r\n" );
return(1);
}
Status = gBS->SetTimer(
TimerOne,TimerPeriodic,MultU64x32( SecondsToNanoSeconds,1)
);
if ( EFI_ERROR( Status ) )
{
Print( L"Set Timer Error! \r\n" );
return(2);
}
while (1 )
{
// do something
}
// cancel timer
gBS->SetTimer( TimerOne,TimerCancel,0 );
gBS->CloseEvent( TimerOne );
return EFI_SUCCESS;
}
如果我创建两个计时器,我将创建另一个 TimeoutSelf 函数。
解决方法
//this is timer:
EFI_STATUS SystemTimeIntervalInit()
{
EFI_STATUS Status;
EFI_HANDLE TimerOne = NULL;
static const UINTN SecondsToNanoSeconds = 1000000;
Status = gBS->CreateEvent(
EVT_NOTIFY_SIGNAL | EVT_TIMER,TPL_CALLBACK,TimeSlice,NULL,&TimerOne
);
Status = gBS->SetTimer(
TimerOne,TimerPeriodic,MultU64x32( SecondsToNanoSeconds,1)
);
while (1)
{
}
gBS->SetTimer( TimerOne,TimerCancel,0 );
gBS->CloseEvent( TimerOne );
return EFI_SUCCESS;
}
//this is signal event
VOID EFIAPI TimeSlice(IN EFI_EVENT Event,IN VOID *Context)
{
DEBUG ((EFI_D_INFO,"System time slice Loop ...\n"));
gBS->SignalEvent (MultiTaskTriggerEvent);
return;
}
//this is three events:
EFI_STATUS MultiProcessInit ()
{
UINT8 i;
EFI_GUID gMultiProcessGuid = { 0x0579257E,0x1843,0x45FB,{ 0x83,0x9D,0x6B,0x79,0x09,0x38,0x29,0xA9 } };
EFI_EVENT_NOTIFY TaskProcesses[] = {DisplaySystemDateTime,HandleKeyboardEvent,HandleMouseEvent};
for (i = 0; i < sizeof(TaskProcesses) /sizeof(EFI_EVENT_NOTIFY); i++)
{
gBS->CreateEventEx(
EVT_NOTIFY_SIGNAL,TPL_NOTIFY,TaskProcesses[i],&gMultiProcessGuid,&MultiTaskTriggerEvent
);
}
return EFI_SUCCESS;
}
@MiSimon,I have use one timer and three events to realize it at finally.
thanks a lot.