1

On Windows 10’s cmd.exe, I typed a format D: /P:3 command to format my 1TB external disk. The process began running, and I left my computer after it said 1% complete in 10 minutes or so.

At 30 minutes, my computer decided I wasn't doing anything and put itself to sleep, disrupting the format process.

I was displeased.

I have since applied the usual methods to caffeinate and otherwise force the computer to stay awake as I run this process again. But, it raised a question in my mind that has proved very difficult to search for online:

Why does Windows (or any OS for that matter) not recognize a running process in a shell in an open Command Prompt App as a valid reason to stay awake?

Watching a video keeps things awake, moving the mouse/typing on the keyboard keeps things awake… Why not a user-typed command in a user-opened Command Prompt App?

Is there some excellent logic backing up the reason to exclude this or just another foolish design choice perpetuated over the years through inheritance?

5
  • 1
    This question is pointing to a design decision and asking why. As such, only opinions and speculations can be offered. These sorts of questions are out of scope here.
    – kreemoweet
    Commented Jul 20, 2022 at 4:56
  • Fair enough. Unless someone in the small group of people who contributed to the design is still lurking around here 50 years later or someone has access to the original spec, then all I’m going to get is a mixture of informed/uninformed speculation
    – szofar
    Commented Jul 20, 2022 at 6:34
  • It is not all opinion. For the most part Windows suspends all processes and Apps when it suspends. There are only a few exceptions, but these are quite obvious and prominent.
    – anon
    Commented Jul 20, 2022 at 11:49
  • @john the question could be rewritten to ask how to keep a computer from sleeping. There's a good question hidden in here, it's just not the question that is currently written, I don't think. Commented Jul 21, 2022 at 4:22
  • Thank you - I have edited my post to cover both eventualities.
    – anon
    Commented Jul 21, 2022 at 10:28

3 Answers 3

0

In general, if something wasn't done, assume that it's not a deliberate design decision but lack thereof. It could sometimes be that such a feature was explicitly left out of a design, but more commonly it never reached the 'design' in the first place – it could be way down in the priority list, it could have been only discussed in a hallway and discarded, or it could have been never brought up at all.

In this case, though, the feature "as designed" works differently than what your post assumes in the first place – the OS doesn't try to recognize specific things as video playback, it relies on explicit sources of information (either direct user input, or a program telling it to stay awake).

That is, programs usually have to tell the OS to hold the system awake while some specific operation is happening. For example, in Windows the program can call SetThreadExecutionState(), on Linux the program takes a "suspend inhibitor", on Android it uses a "wake lock".

For apps that weren't programmed to use the OS facilities correctly, Linux comes with CLI "wrapper" tools that do it before running the main app. For example, instead of wget you would run gnome-session-inhibit wget and the system would not suspend as long as that program was running. (Sort of like 'caffeinate' but used in-line instead of being an external on/off toggle.)

Why not a user-typed command in a user-opened Command Prompt App?

As for why wake-locks were left out of cmd.exe and powershell – all we can do is guess and speculate, but the most likely reason is that it would be somewhat difficult to externally distinguish commands that want to finish a specific operation (e.g. format, download) from commands that do not (e.g. if you left an opened git log running and it's just sitting there).

The same goes for graphical apps – there is no externally visible difference between a game that must remain awake and an email app that could be suspended without problems, despite both using the network at the same rate; or between a video player that must remain awake and a picture viewer that could be suspended, despite both being full-screen.

I suspect that more often than not, it would lead to false positives that result in the system staying awake when it should have suspended, and your complaint would just be replaced by someone else's complaint about Windows increasing their power bill.

(This is already a problem with Windows 10, as one of its internal Windows Update services occassionally takes a wake lock and forgets to release it, resulting in the system never going to sleep even though no operation is actually being performed.

But also consider the maintenance costs of features: such a problem is still easier to solve with an explicit wake lock, as the fix only affects the specific program that's broken – whereas if the OS had some heuristics to guess or detect idle/active programs, any changes to fix the detection of some programs would likely break the detection of some others.)

1

Because at any one time dozens or even hundreds of processes are running (though they could be idle). Often, it would not be (reliably) distinguishable which processes are supposed to keep the PC awake. For a human using the PC, that’s often easy though – because they have one more piece of information the PC does not: Intent. They know why they did what they did.

So instead of the operating system, programs themselves are responsible for inhibiting sleep. Videos, VoIP calls, PowerPoint slideshows, whatever. Basic system tools (like format) may not have kept up with this change.

0

(A) The first question was: After an idle period, the computer went to sleep.

This is not at all unusual.

Excel, Word or whatever can be running, ALL processes are running for sure. All that happens is that Windows going into Suspend, suspends (stops) the running App or process. (Zoom, You Tube, Video excepted)

I see this all the time with Windows Apps and with VMware (which suspends running Machines) when I suspend Windows.

I have had this happen both when not using the computer (or at the Suspend timer interval) and also when battery gets low.

Windows suspends everything (with a few notable Video / Audio exceptions).

This situation is normal.

(B) Another question here appears to be how you can keep a computer awake.

This is done with power management.

If your battery is healthy, set the idle time to go to sleep for 1 or 2 hours.

If plugged into AC, set the idle time to Never.

I use threshold battery management, keep my computer plugged in, set Suspend to Never and it is always ON.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .