usleep () do obliczania czasu, który upłynął, zachowuje się dziwnie

Obliczam czas, który upłynął w milisekundach dla każdego kolejnego wywołania funkcji obsługi za pomocą poniższego kodu. Gdy używam usleep (1000), tj. Różnica czasu 1 ms między każdym wywołaniem wynosi 10 ms, a gdy używam usleep (1000000), tj. 1 sekunda, zaskakująco odstęp czasu między każdym wywołaniem spada do mniej niż 1 ms. Oto fragment kodu:

    #include<stdio.h>
    #include<stdlib.h>
    #include<sys/time.h>
    #include<unistd.h>

    struct timeval start_time;
    void handler(int);

    int main()
    {
            struct timeval current_time;
            int i=0;
            gettimeofday(&start_time,0);
            gettimeofday(&current_time,0);
            printf("%012.3fms: emulationbegins\n",((current_time.tv_usec-start_time.tv_usec)/1000.0));

            while(i++<5)
            {
                    usleep(1000); // compare with usleep(1000000)
                    handler(i);
            }

            return 0;
    }

    void handler(int i)
    {
            printf("In Handler %d\n",i);
            struct timeval current_time;
            gettimeofday(&current_time,0);
            printf("%012.3fms: Handler Called\n",((current_time.tv_usec-start_time.tv_usec)/1000.0));
            return;
    }

questionAnswers(2)

yourAnswerToTheQuestion