Trouble with setitimer and getitimer.

Trouble with setitimer and getitimer.

Post by John Aleg » Sun, 10 Jan 1993 06:50:18



I am trying to time a tight SCSI read loop on a
NeXT machine.

I am having trouble with the UNIX functions
setitimer and getitimer.

My code (or one variation of it) looks like this:

struct itimerval        after;

setitimer(ITIMER_REAL, &after, 0L);
        puts("Starting");
        for(i=1;i<=num;i++)    
                [self performSCSIRequest];
        puts("Done");
getitimer(ITIMER_REAL, &after);

I have not been able to get any kind of succesful
data out of setitimer or getitimer.  If I do not
assvalues to the various componets of after,
I get back 0 or all fields.  If I do assaign
initial values, I either get back the same values
or garbage.

All comments welcome
---
John N. Alegre
Andante Systems
VideoLabs Inc.

#############################################################
# NeXTMail preferred.             |




#############################################################

 
 
 

1. SIGALARM setitimer getitimer

Hey Guys
I have written some code which acts perfectly fine in a program to use
SIGALRM. I am able to raise an alarm after every 10 seconds. But when
I add this functionality to my socket code, no alarm is generated. Can
anyone possibly tell me a cure for my problem. Thanks
Here is the code :
int cmd_exec(char *string)
{
 char bufsize[BUFSIZ];
 FILE *ptr;

 if ((ptr=popen(string,"r")) != NULL) {
                while(fgets(bufsize,BUFSIZ,ptr)!= NULL)
                        printf("%s",bufsize);

        }

   memset(bufsize,0,BUFSIZ);
int main () {

 struct sigaction sigs;

  sigemptyset(&sigs.sa_mask);
  sigaction(SIGUSR1, &sigs,(struct sigaction* )NULL);
  signal (SIGALRM,ALARMhandler);
 signal (SIGINT,intHANDLER);
  signal(SIGUSR1,UserSignal);
  alarm(20);    
  cmd_exec("ls /usr/local/scripts *.c");
  while(1);
        //while (1) {
                //   sleep(10);
                 //  write(fileno(stdout), "\n",2);
                //   printf("Just Executed \\n");
        //}
    return 0;
void intHANDLER(int sig)
{
        char c;
        signal(SIGALRM,SIG_IGN);
        signal(SIGINT, SIG_IGN);
        printf ("OUCH, you just hit a CTRL-C\n");
        printf ("Would you like to terminate the program[y/n]\n");
        c=getchar();
        if (c=='y' || c=='n')
        {
                exit(0);
        }
        signal(SIGINT,intHANDLER);
        signal(SIGALRM,ALARMhandler);
return;
void ALARMhandler(int sig)
{
        printf("\n20 Seconds are up\n");
        alarm(20);
        raise(SIGUSR1);
        cmd_exec("ls");
  return;
void UserSignal(int sig)
{
        printf("USER SIGNAL 1 RECEIVED\n");
        return;

2. konqueror can't use ssl

3. setitimer() and getitimer() timing measurments

4. webmail interface idiot question

5. getitimer() setitimer() gettimeofday()

6. packets in a frame

7. Porting: How to simulate setitimer(2)/getitimer(2) ?

8. csh set "a b"=c core dump

9. Matrox Mystique ands X.

10. Resolution of getitimer?

11. getitimer()

12. Usage of getitimer()

13. More@!!.. Panasonic/SB-CD troubles, trouble, trouble...