All about programming in GNU/LINUX

Illustration of sleep system systm call in GNU/LINUX using a simple program

//download link for the file:
/* Hackintosh Rao , Codes for GNU/LINUX \m/ */
/*system calls used :sleep(int sec)         */
/*Sleep system call pauses the execution of instructions for specified no.of.seconds*/
int main()
    int i;
      printf(“\n\t\tWithout time delay”);
    printf(“\nWait and watch how the execution halts for 2 seconds each time when SLEEP is called”);
         printf(“\n# “);
         sleep(2) ;/*the argument for sleep system call is an integer duration in sec for which
                      you want the exection of the instructions to be put to pause */



2 responses

  1. What happens If I give negative number to the sleep command ?

    January 5, 2012 at 12:20 am

  2. There will no error or a warning ….. the program just sleeps and never wakes up 🙂

    January 5, 2012 at 2:53 am

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s