I am facing some problems with the usage of setitimer functionality.
When I execute the code I couldn't see expected result. The signal handles printf( ) works when I comment the while(1) part in main function (which is my busy executing code). In my understanding both (main( ) and signal_handler()) should run in time sliced fashion or in parallel depending on Linux scheduler.
Can anyone help me out in debugging or correcting my understanding?
Here is the code:
void timer_handler (int signum) {
    printf("...\n"); 
    printf ("Timer expired %d times\n", ++count);
} 
void Tmr_Init(void) {
    struct sigaction sa;
    struct itimerval timer; 
    memset (&sa, 0, sizeof (sa));
    sa.sa_handler = &timer_handler; 
    sigaction (SIGPROF, &sa, NULL);timer.it_value.tv_sec = 2;
    timer.it_value.tv_usec = 0;
    timer.it_interval.tv_sec = 1;
    timer.it_interval.tv_usec = 0;
    setitimer (ITIMER_PROF, &timer, NULL);
} 
int main () {
    Tmr_Init(); 
    /* Do busy work. */
    while (1) {
        printf("In main!!\n"); 
        sleep(2);
    }
    return 0;
} 
 
    