[GHC] #1933: Zero times in profiling with GHC-6.8.1

GHC trac at galois.com
Mon Apr 28 18:43:18 EDT 2008


#1933: Zero times in profiling with GHC-6.8.1
-------------------------------+--------------------------------------------
 Reporter:  daniel.is.fischer  |          Owner:  simonmar
     Type:  bug                |         Status:  new     
 Priority:  normal             |      Milestone:  6.8.3   
Component:  Profiling          |        Version:  6.8.1   
 Severity:  normal             |     Resolution:          
 Keywords:                     |     Difficulty:  Unknown 
 Testcase:                     |   Architecture:  x86     
       Os:  Linux              |  
-------------------------------+--------------------------------------------
Changes (by simonmar):

 * cc: daniel.is.fischer at web.de (added)

Comment:

 Daniel: could you try this modified version of your test program and let
 me know the results?

 {{{
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <signal.h>
 #include <unistd.h>
 static volatile int tock = 0;
 static void handler(int i)
 {
    tock = 1;
 }

 int main(int argc, char *argv[])
 {

     struct sigevent ev;
     timer_t timer;
     struct itimerspec it;
     struct sigaction action;
     int m,n,count = 0;

     ev.sigev_notify = SIGEV_SIGNAL;
     ev.sigev_signo  = SIGVTALRM;

     action.sa_handler = handler;
     action.sa_flags = 0;
     sigemptyset(&action.sa_mask);
     if (sigaction(SIGVTALRM, &action, NULL) == -1) {
         printf("SIGVTALRM problem\n");
         exit(3);
     }

     if (timer_create(CLOCK_PROCESS_CPUTIME_ID, &ev, &timer) != 0) {
         printf("No CLOCK_PROCESS_CPUTIME_ID timer\n");
        exit(1);
     }

     it.it_value.tv_sec = 0;
     it.it_value.tv_nsec = 1;
     it.it_interval = it.it_value;
     if (timer_settime(timer, 0, &it, NULL) != 0) {
         printf("settime problem\n");
         exit(4);
     }

     tock = 0;

     for(n = 3; n < 20000; n++){
         for(m = 2; m <= n/2; m++){
             if (!(n%m)) count++;
             if (tock) goto out;
         }
     }
 out:

     if (!tock) {
         printf("no CLOCK_REALTIME signal\n");
         exit(5);
     }

     timer_delete(timer);

     if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
         printf("No CLOCK_REALTIME timer\n");
         exit(2);
     }

     it.it_value.tv_sec = 0;
     it.it_value.tv_nsec = 1;
     it.it_interval = it.it_value;
     if (timer_settime(timer, 0, &it, NULL) != 0) {
         printf("settime problem\n");
         exit(4);
     }

     tock = 0;

     usleep(100);

     if (!tock) {
         printf("no CLOCK_REALTIME signal\n");
         exit(5);
     }

     timer_delete(timer);

     exit(0);
 }
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1933#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list