Click here to Skip to main content
15,914,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Does anything affect Sleep () Pin
toxcct11-May-04 4:59
toxcct11-May-04 4:59 
GeneralRe: Does anything affect Sleep () Pin
Jens Doose11-May-04 5:09
Jens Doose11-May-04 5:09 
GeneralRe: Does anything affect Sleep () Pin
toxcct11-May-04 5:17
toxcct11-May-04 5:17 
GeneralRe: Does anything affect Sleep () Pin
Jens Doose11-May-04 5:23
Jens Doose11-May-04 5:23 
GeneralRe: Does anything affect Sleep () Pin
toxcct11-May-04 5:29
toxcct11-May-04 5:29 
GeneralRe: Does anything affect Sleep () Pin
Jens Doose11-May-04 5:41
Jens Doose11-May-04 5:41 
GeneralRe: Does anything affect Sleep () Pin
toxcct11-May-04 5:51
toxcct11-May-04 5:51 
GeneralRe: Does anything affect Sleep () Pin
Toby Opferman11-May-04 12:48
Toby Opferman11-May-04 12:48 
The system will only deadlock if a message is sent to a window that is on a thread using "Sleep" in a non-alertable state. If you use "SleepEx", the second parameter allows the thread to wait in an "alertable" state.

A "SendMessage" queues an APC on the window's thread and will be processed if the thread is in an "alertable" state. So, if you use SleepEx() and maintain an alertable thread state you will be able to become signaled.

Sleep() is also a system call. It's not implemented in user-mode, so it doesn't do a while(x < 10). It's not a spinlock either. The thread should be delayed in the scheduler until the sleep has expired.

I'm not sure what the original question was, but it was something about going into a hibernate state. Perhaps this should answer the question (Link Below)

If this is true, I would think that the thread sleep would continue to sleep once the machine resumed, since it technically hasn't slept the full period. The only way it wouldn't is unless the scheduler bases the sleep off of time (Which would have changed) and it processes this information upon restart. Of course, even if it is based off of time, generally the OS is probably notified of a hibernation and it could make special arrangements to honor the full sleep independent of the hibernation, ie, resume after the system restarted.

I can't be sure of that without a test. You could write a thread to sleep and after the sleep write a debug message or something. Perform the test and verify the results. Though, generally speaking, the results could vary by implementation (hardware, OS, etc.) but most likely the implementations should match what you find.

http://www.veritest.com/benchmarks/battmark/bb3power_man/b3sleep.asp

Hibernation

Hibernation is one of several terms describing a state of reduced power consumption that a power-managed computer may support.

According to the conventional definition of hibernation, a notebook copies all memory contents and hardware state information to non-volatile storage (typically the hard disk, which requires no power to retain information), and the notebook is completely powered down.

Leaving hibernation and returning the system to full operation requires booting the computer as usual and then waiting while the system restores the memory contents and hardware state. The process is finished when the computer is at exactly the point it was when the hibernate process started.

Hibernation trades time for power: maintaining the system state requires no power (because the state has been saved to disk), so the computer can remain in hibernation indefinitely. However the user must wait when entering and returning from hibernation—sometimes several minutes or more if the system has a lot of memory.
GeneralRe: Does anything affect Sleep () Pin
Toby Opferman11-May-04 12:53
Toby Opferman11-May-04 12:53 
GeneralRe: Does anything affect Sleep () Pin
Rafael Fernández López11-May-04 4:50
Rafael Fernández López11-May-04 4:50 
GeneralRe: Does anything affect Sleep () Pin
cheesepirate11-May-04 4:53
cheesepirate11-May-04 4:53 
GeneralCopyFile help! Pin
Ryan McDermott11-May-04 4:34
Ryan McDermott11-May-04 4:34 
GeneralRe: CopyFile help! Pin
Rafael Fernández López11-May-04 4:54
Rafael Fernández López11-May-04 4:54 
GeneralRe: CopyFile help! Pin
Diddy11-May-04 5:51
Diddy11-May-04 5:51 
GeneralRe: CopyFile help! Pin
ThatsAlok3-May-05 22:12
ThatsAlok3-May-05 22:12 
GeneralNeed help on subclassing windows Pin
cnurse11-May-04 3:19
cnurse11-May-04 3:19 
GeneralRe: Need help on subclassing windows Pin
Hesham Amin11-May-04 4:12
Hesham Amin11-May-04 4:12 
GeneralRe: Need help on subclassing windows Pin
cnurse11-May-04 13:53
cnurse11-May-04 13:53 
GeneralList control events Pin
jhorstkamp11-May-04 2:54
jhorstkamp11-May-04 2:54 
GeneralRe: List control events Pin
Monty211-May-04 3:02
Monty211-May-04 3:02 
GeneralRe: List control events Pin
Diddy11-May-04 3:11
Diddy11-May-04 3:11 
GeneralRe: List control events Pin
jhorstkamp11-May-04 8:13
jhorstkamp11-May-04 8:13 
GeneralRe: List control events Pin
Diddy26-May-04 2:46
Diddy26-May-04 2:46 
QuestionHow to make code block works faster? Pin
Kolich11-May-04 2:41
Kolich11-May-04 2:41 
AnswerRe: How to make code block works faster? Pin
Nitron11-May-04 2:56
Nitron11-May-04 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.