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
0
votes
0 answers

Delay in php sleep functions their selves?

I have a PHP program that should sleep for some time to make it tick 100 times per 1 second in it's process while loop. But when I want to calculate the time lapsed for a 100 tick cycle I get more than 1 second. Is this a problem from my code or…
Danihex
  • 16
  • 2
0
votes
0 answers

usleep() in while loop causing issues - whole process freezes

I am using php, Laravel, Redis, and SQL on an Ubuntu localhost server. I have made a bunch of methods that return results from API searches after some processing. I am calling 5 of these methods which will be very slow if done synchronously, so I've…
0
votes
0 answers

Google App Script, UrlFetchApp Sleep After Page Loads But Before the Fetch?

Please bear with me, I'm self taught and not great at writing code. I'm trying to scrape some data from a webpage in Google Sheets but the page "lazy loads" so not all of the data is there immediately upon page load. The delay is a few seconds. My…
0
votes
0 answers

Using random numbers with usleep()

I notice each time that I run my program the random number, represented by percentage, is always climbing. As in, the previous random number is always smaller than the next random number. What can I do to keep this from happening? #include…
Descode
  • 1
  • 3
0
votes
1 answer

usleep() on localhost VS Repl.it

I'm currently learning PHP so I'm doing some training, and I've come to a problem that I don't understand. I wrote a few lines of code on Repl.it : $msg = "Once upon a time..."; for ($i=0; $i < strlen($msg); $i++) { echo…
0
votes
0 answers

usleep issue with unistd.h

I want to use miliseconds for my program in c, but there was an error. Basicly im trying to do a halfsecond sleep between between the command. My code : #include #include #include int msleep(unsigned int tms) { …
0
votes
2 answers

float number and usleep problem

Im wrinting app which has that piece of code, where t->tick is float: usleep(1000); t->tick = t->tick + 0.001; printf("tick is %f, firing time is %f\n", t->tick, t->firing_time); i found that there is error in usleep?: tick is 0.313000, firing time…
JosiP
  • 2,619
  • 5
  • 29
  • 33
0
votes
1 answer

While cycle and usleep

Here is a cut from my daemon code: package somepackage; use Proc::Daemon; use Time::HiRes qw/usleep/; use constant{ LOGFILE => '/var/log/.../work.log' }; our $LOG; unless($pid) { open($LOG,'>>'.LOGFILE); my $tm; } while ($pid == 0) …
Starmaster
  • 842
  • 1
  • 6
  • 9
0
votes
1 answer

SLEEP: (Sleep or usleep) is not suspending everything in my thread in Linux but it does in Windows? why?

In Windows: for (int i = 0; i < 100; i++) { Sleep(100); // Sleep 100 ms in Windows printf(".[%d] ", i); } The result is a bracketed number comes out every 100ms in Windows. In Linux: for (int i = 0; i < 100; i++) …
jdl
  • 6,151
  • 19
  • 83
  • 132
0
votes
2 answers

Stop execution till the beginning of the next hour

I successfully find (i think) how many microseconds have to pass till the beginning of the next hour but usleep() function shows warning Number of microseconds must be greater than or equal to 0 $min = (integer)date('i'); $sec =…
Professor Chaos
  • 447
  • 5
  • 11
0
votes
1 answer

How to exit GUI program by clicking the mouse in Python?

from graphics import * def main(): win = GraphWin("Shapes") center = Point(100, 100) circ = Circle(center, 30) circ.setFill("red") circ.draw(win) time.sleep(6) main() So, I have installed (barely somehow) graphics.py by…
user6179055
0
votes
2 answers

C after timer_start() sleep is not working

I am using eclipse IDE on ubuntu to compile my c project. I have a timer. After starting the timer, sleep or usleep functions are not working. Here is the code; EDIT /* ============================================================================ …
Furkan KESKIN
  • 168
  • 3
  • 16
0
votes
0 answers

Run a loop for X seconds, settng usleep in while()

I have a variable ($i) starts from 0 to 9. It keeps increasing ($i++) in a loop until it reaches 9, when it reaches 9 it sets back $i to 0. I want to run this loop for 2 seconds only and then get the final number where it stopped after 2 seconds. So…
Themer
  • 185
  • 1
  • 12
0
votes
1 answer

perl on windows stuck on calling for usleep from another module

I'm using the following perl code on windows environment: use Time::HiRes qw(usleep); #(some code here) $self->{GLOBAL_OBJ}->xsleep($delay) if($delay); sub xsleep { my $seconds = shift; #print "will sleep:$seconds seconds\n"; …
Omer Levy
  • 51
  • 2
0
votes
2 answers

usleep doesn't work in iOS

I have a problem in iOS. The green ViewController should turn after a few seconds to red and I have this code: override func viewDidLoad() { super.viewDidLoad() let ZeitZahl = arc4random_uniform(1499) + 6000 usleep(ZeitZahl) …
Blub
  • 121
  • 1
  • 1
  • 6