Sleep functions

These functions are used to suspend a calling thread for a given length of time, until a signal is received (question: does delay() cares about signals?)
include
sleep(unsigned int seconds);
usleep(useconds_t useconds);
delay(unsigned int mseconds);
Include
nanosleep(const struct timespec* rqtp, struct timespec* rmtp); // rqtp: requested time; rmtp: remaining time, can be NULL.
Note: the suspension time may be greater than the requested amount, due to the nature of time measurement, or the thread scheduling. Below is an example of usleep(500): 500us sleep turns to be 1ms 920us, or 1ms 853us.

if(delay_needed) {

int sleep_us = 500;

trace_logf( _NTO_TRACE_USERFIRST + 801, “delay %d us”, sleep_us);

usleep(sleep_us);

delay_needed = 0;

}

trace_logf( _NTO_TRACE_USERFIRST + 800, “set up a new transfer”);

Screen shot 2015-05-07 at 4.54.22 PM Screen shot 2015-05-07 at 4.52.31 PM
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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