The Artima Developer Community
Sponsored Link

C# Answers Forum
Solaris Timer Implementation

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ulisses

Posts: 2
Nickname: ulisses
Registered: Apr, 2004

Solaris Timer Implementation Posted: Apr 6, 2004 9:33 AM
Reply to this message Reply
Advertisement
I've a problem with a Solaris program implementation: My code uses a
timer procedure and when i try to execute date -a XXXX or rdate, my
aplication stops. I can't use ntp and need to set the machine time.
Here is my procedure. If you know how you can help me, please, do it.
static void handlerDelay() {
siglongjmp( env, 1 );
}

int XoPortUtilDelay( unsigned int milissec ) {

int houveTemporizacao = 0;
int segundos;
int microSeg;
struct itimerval tempoSleep;
void (*handlerAnterior)();

segundos = milissec / 1000;
microSeg = ( milissec % 1000 ) * 1000;

//!!!
if( microSeg < 50000 ){
microSeg = 50000;
}
//!!!

tempoSleep.it_value.tv_sec = segundos;
tempoSleep.it_value.tv_usec = microSeg;
tempoSleep.it_interval.tv_sec = 0;
tempoSleep.it_interval.tv_usec = 0;

handlerAnterior = signal( SIGALRM, handlerDelay );

if( handlerAnterior == SIG_ERR ){
return FALHA;
}

/* The first call to sigsetjmp show the point where the next
siglongjmp will return. Return always 0 at first time. When siglongjmp
is called (no signal handler), execution return to the call point to
sigsetjmp and the returned value are the specified as second argument
in siglongjmp. */

houveTemporizacao = sigsetjmp( env, 1 );

if( !houveTemporizacao ){
if( setitimer( ITIMER_REAL, &tempoSleep, NULL ) == -1 ){
return FALHA;
}
pause();
}

signal( SIGALRM, handlerAnterior );

return SUCESSO;
}//fim XoPorUtilDelay

Topic: Alternatives to set the system date Previous Topic   Next Topic Topic: Why it does not work with unicode and Win98 ??

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use