sleep is a system call that suspends a process or thread for a specified amount of time
Questions tagged [sleep]
3187 questions
1
vote
1 answer
Temporarly Prevent Forced Sleep on Mac OS X through Python/Terminal
How can one disable forced sleep (sleep caused by the user - often by closing lid/pressing Sleep under the apple menu) through Terminal, preferably with a Python script, on OS X? I would like to be able to run the following or similiar...
import…

The Novice
- 124
- 9
1
vote
3 answers
C sleep method obstructs output to console
I have a C program, where I just wanted to test if I could reproduce a console spinner used in npm install while it installs a module. This particular spinner simply spins in this order:
|
/
-
\
on the same space, so I use the following…

Patrick Roberts
- 49,224
- 10
- 102
- 153
1
vote
1 answer
regarding sleep command in c++
I am trying to delay the program using sleep command. But when I print the results, I don't see the delay. Am I missing something .
#include
#include
#include
#include
#include // for time…

user2532296
- 828
- 1
- 10
- 27
1
vote
2 answers
Is it possible to sleep in granularity of microseconds in linux kernel?
Is it possible to sleep in granularity of microseconds in linux kernel ?
From what i know, there is msleep() which can sleep in milliseconds
and there is udelay() which busy waits for time in microsecond
granularity.
But I need to sleep ( not busy…

Chinna
- 3,930
- 4
- 25
- 55
1
vote
2 answers
Execute code after some time without using sleep in Python?
I am writing code for an LCD screen using Python and I want it to display a flashing 'Press SELECT' message until a button on the LCD is pressed.
The problem is that while the program is in sleep, it does not register the user pressing the button,…

quelqu_un
- 13
- 2
1
vote
3 answers
Waiting for invokeLater() to be called
Is there a more elegant way to do what I'm doing below? That is, is there a more elegant way than polling and sleeping, polling and sleeping, and so on to know when a Runnable.run() method has been called via invokeLater()?
private int myMethod()…

Paul Reiners
- 8,576
- 33
- 117
- 202
1
vote
1 answer
Is there a race condition when manually put process into sleep
When I read ldd3 chapter 6, I was confused by the codes which is shown below:
while (spacefree(dev) == 0) { /* full */ DEFINE_WAIT(wait);
up(&dev->sem);
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
PDEBUG("\"%s\" writing:…

Douglas Su
- 3,214
- 7
- 29
- 58
1
vote
1 answer
How do you "sleep" in an AnyEvent callback without pausing the whole script?
I'm specificaly using AnyEvent::Inotify::Simple (using EV as backend) to monitor file events. So I have a handler callback that in a particular case, I need to "pause" before continuing. sleep obviously halts everything (so other events don't get…

FunkyShu
- 138
- 5
1
vote
4 answers
Delay routine in Swing on button click which should not stall the application
I am trying to do the following: click a button, button disappears for 2 seconds, text appears for 2 seconds and after those 2 seconds the visibility is reversed. So far I have done this:
btnScan.addActionListener(new ActionListener(){
…

deadpixels
- 769
- 1
- 12
- 21
1
vote
2 answers
sleep in for loop for total iteration time of 2 minutes
I have a for loop inside a while (1) and I want the loop to average approx 2 minutes through each entire for loop cycle. This requires sleeping between each iteration for a different time based on execution time of the iteration and time remaining…

sjohnson
- 69
- 2
- 13
1
vote
2 answers
Is there a blocking version of "Sleep"? (ahk)
I have a hotkey that I press repeatedly quite fast and I included a Sleep in the routine to throttle it a bit. But when I go at faster speeds the output starts to mess up. The culprit is definitely the sleep because when I take it out and let it…

Jpaji Rajnish
- 1,491
- 4
- 17
- 35
1
vote
1 answer
sleep vs SIG_ALARM usage and CPU performance
When should I use sleep() and a reconfiguration of SIG_ALRM?
For example, I'm thinking of scheduling some task at some specific time. I could spawn a thread with an sleep() call inside and when sleep() returns, do some task, or I could specify a…

vicaba
- 2,836
- 1
- 27
- 45
1
vote
1 answer
PHP Sleep function With While Loop
I am using Ubuntu Server 14.04 I have some issue in my script ...script give me response very well if i use die instead of sleep after echo in else condition but when i use sleep(3600) after echo in else condition it is not giving me any response…

Hafiz Atta Ur Rahman
- 33
- 1
- 2
- 9
1
vote
1 answer
Inconsistent sleep behavior when using AudioClip in Java
I am writing Ukelele Simulator, and I want to play a note on each string with a short delay in between. Currently, I have a method that returns an AudioClip containing the sound of the currently pressed note on each string, and I am attempting to…

GoatFood
- 25
- 1
- 4
1
vote
1 answer
Sending data periodically from client to server in C
I am creating a multithreaded socket program that needs to send 2 sets of data to the server periodically. The client needs to send GPS information every 3 seconds and polarity information every 4 seconds. My idea on implementing this was to simply…

marcusc
- 21
- 4