Question: Try running the program in Listing 23-3 (t_nanosleep.c) in the background with a 60-second sleep interval, while using the following command to send as many

Try running the program in Listing 23-3 (t_nanosleep.c) in the background with a 60-second sleep interval, while using the following command to send as many SIGINT signals as possible to the background process:

$ while true; do kill -INT pid; done

You should observe that the program sleeps rather longer than expected. Replace the use of nanosleep() with the use of clock_gettime() (use a CLOCK_REALTIME clock) and clock_nanosleep() with the TIMER_ABSTIME flag. (This exercise requires Linux 2.6.) Repeat the test with the modified program and explain the difference.

$ while true; do kill -INT pid; done

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The given exercise involves modifying the program in Listing 233 tnanosleepc by replacing the usage of nanosleep with clockgettime and clocknanosleep ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!