Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

23. Timers and Sleeping > Setting Timeouts on Blocking Operations

Setting Timeouts on Blocking Operations

One use of real-time timers is to place an upper limit on the time for which a blocking system call can remain blocked. For example, we may wish to cancel a read() from a terminal if the user has not entered a line of input within a certain time. We can do this as follows:

  1. Call sigaction() to establish a handler for SIGALRM, omitting the SA_RESTART flag, so that system calls are not restarted (refer to Interruption and Restarting of System Calls).

  2. Call alarm() or setitimer() to establish a timer specifying the upper limit of time for which we wish the system call to block.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint