Illustration of time,diffitme and sleep system call in GNU/LINUX

//download link for the file:
   simple illustration of time and difftime system call in GNU/LINUX
   system calls used: 1)time_t time(time *) ;go to /usr/include and use “grep time_t *”
                      2)double difftime(time2,time1);go to /usr/include and use “grep -l difftime *”
                      3)void sleep(int sec);


int main()
    time_t time_1970,time2_1970;//time_t is a built in data type and is used to store very large numbers
    int i;
    double timedifference;

        time_1970=time((time_t *)0);
        /*time system call takes in a NULL argument and returns no.of.seconds eclapsed since 1970*/

        printf(“\nThe no.of.seconds passed from 1970 is:%ld “,time_1970);
        /*sleep system call halts or pauses the execution for no.of.seconds mentioned as arguments to the call*/
        time2_1970=time((time_t *)0);
        /*difftime is a system call which returns back the time difference in seconds as a double b/w its 1st and 2nd argument of type time_t*/
        printf(“\n\nHey !! The program was paused for %f seconds”,timedifference);


2 thoughts on “Illustration of time,diffitme and sleep system call in GNU/LINUX

    1. ya , unistd is not required in this case , all the system calls in this program comes under time.h and stdlib is for exit(0) , but i feel with the range function calls unistd provides in system programming in linux its better to have it …and the program stilll works fine with just stdlib.h , i am not able to figure out the reason ??? can u ???

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s