Questions tagged [usleep]

usleep is a function provided by various languages and run times that delays a script or program by an amount of time specified in micro-seconds (µ - micro).

Details of how to use usleep vary by implementation.

94 questions
1
vote
2 answers

Is there some sort of a command for creating a delay in a program

Many people told me there is a better way to create a delay for X amount of milliseconds. People told me about sleep command and usleep(), but I failed to make that work. Currently I'm using this: void delay(unsigned int mseconds) { clock_t…
user10149464
1
vote
1 answer

simplest truest timing in C

I'm making a microcontroller programmer and for now, I've been using usleep() to try to introduce appropriate delays. It seems that sometimes the program works and sometimes it doesn't. I tried the -O2 flag when compiling my code but I begin to…
Mike -- No longer here
  • 2,064
  • 1
  • 15
  • 37
1
vote
1 answer

macos nanosleep() sleeping for (far) too long

Conceptually I run following Swift pseudo code to regulate UDP sent data bitrate let sendQueue = DispatchQueue(label: "_send_queue", qos: .userInitiated) sendQueue.async { for data in datas { socket.send(data) if let timespec =…
simpleone
  • 360
  • 3
  • 10
1
vote
1 answer

usleep with clock_gettime() issue

I was doing a microbenchmark. My code appears something like this while(some condition){ struct timespec tps, tpe; clock_gettime(CLOCK_REALTIME, &tps); encrypt_data(some_data) clock_gettime(CLOCK_REALTIME, &tpe); long time_diff…
mbbce
  • 2,245
  • 1
  • 19
  • 31
1
vote
2 answers

Implementing Timer in PHP and Sleep function

I am creating an PHP application in which i want to set a timer of 15 minutes for a particular section of test. If the student doesn't complete the section in 15 minutes the scores are saved and the student is navigated to the next section. So i…
1
vote
0 answers

Move an ascii object based on spaces per second

I am trying to move a picture based on its vertical and horizontal speed. I understand that if, say, the word "Picture" were to be moving across the terminal screen at a rate of .25 spaces per second, I would write something like: #include…
Josh Simani
  • 107
  • 10
1
vote
0 answers

Adobe Air SQLite synchronous busy timeout / SQLite concurrent access / avoid busy loop

this is my first post here. I'm asking because I ran out of clues and I was unable to find anything about this specific issue. My question is: In Adobe AIR, is there a way to do a synchronous usleep() equivalent (delay execution of 200ms),…
Tino
  • 9,583
  • 5
  • 55
  • 60
1
vote
1 answer

time attack on bash program with usleep() inside

I have a little hackme where I have to get the password with brute force. In the program is the function usleep(); when I have the right length and it is changing when one letter is right. It would not be a problem, but the sleep time is about one…
user2675468
  • 150
  • 3
  • 16
1
vote
2 answers

Simple PERL script to loop very quickly

I'm trying to get a perl script to loop very quickly (in Solaris). I have something like this: #! /bin/perl while ('true') { use strict; use warnings; use Time::HiRes; system("sh", "shell script.sh"); Time::HiRes::usleep(10); } I want the…
Huskie69
  • 795
  • 3
  • 11
  • 31
1
vote
1 answer

curl_multi pause after a few executions

My problem is I want to access json data from an API webpage, and there are only 10 calls per second allowed. After 10 calls added to the handler I exec them and then every result gets decoded, the data processed and the curl session will be removed…
pfu
  • 69
  • 1
  • 7
1
vote
0 answers

In which cases put a process itself in an sleep ?

I really would like to know about some cases that a process put itself in a sleep. What would happen for example in following cases? Would the process put itself in a sleep? and why ? Multiply of big number of values Waiting for user…
1
vote
3 answers

Is there another difference between sleep and usleep?

Is the only difference between sleep function and usleep one Is that the parameter of first one is in seconds and the other one in micro seconds ?? Is there any difference else ?? Anther thing please, I'll use this functions with loops, Is there any…
Nedal Eldeen
  • 159
  • 1
  • 7
1
vote
2 answers

php mail() functions executed in wrong order

I have 2 mail functions, like this: mail( $from, '', 'mail1', $headers ); mail( $from, '', 'mail2', $headers ); If I test it with my own email address in the $from, sometimes I receive mail1 first and sometimes I receive mail2 first. I want to…
user617123
  • 463
  • 2
  • 9
  • 26
0
votes
1 answer

Segmentation fault in multithreaded application

I have a Segmentation fault in my multithreaded application that is becoming a headache. It looks like the problem is being generated in a usleep call. I tried to replace it with nanosleep but it persists. It also appears near to a sem_timedwait…
funkadelic
  • 311
  • 1
  • 2
  • 10
0
votes
4 answers

PHP usleep to prevent script timeout

I have a script that loads a massive directory listing and just (in it's nature) takes forever to load. I'm now in some cases experiencing the script timing out and was curious if I could use something like usleep to keep the script from timing out…
Fluidbyte
  • 5,162
  • 9
  • 47
  • 76