What is the status (per 2015) of the "maturity" of how well OSes can control/limit the usage of CPU?

leeteq

Distinguished
May 28, 2009
18
0
18,510
mastodon.technology
Hi all, I am generally not so into the really technical parts of hardware, and want to update my insight into one particular aspect: With the continuous increase in amount in general, but also of "aggressive"/"bullyish" JavaScripts that are running in our browsers, I see that both on Windows and Linux systems, it seems that we cannot ensure a simple thing such as guaranteeing that screen updates, mouse control and keyboard control _never_ gets hit when a Javascript or browser tab or flash issue "goes through the roof".

Is it really still the situation that we need to accept the risk of computers freezing up to the point that we have to physically shut them down to restart?

What is the technical reasons why even in 2015 we still cannot get rid of just that one part where we loose control over the last 2(?) per cent of the CPU, and reserve it for operating the input devices, so we at least for example can choose to kill whatever process(es) have frozen.
 
I don't think this question is right for this forums.

This is like asking if we can land on the moon why don't we have more efficient vehicles?

To this day, computers still run into troubles that require a hard reboot. Why? It can literally be caused by millions and millions of bits that the processor has to compute. Sometimes it can receive a 1 instead of a 0 due to manufacture process, environmental variables and such, which can cause it to freeze.
 

leeteq

Distinguished
May 28, 2009
18
0
18,510
mastodon.technology
Yes, I am unsure as of which forum is the right one to ask about this.
My curiosity is to get someone with more hardware vs. OS knowledge than myself, to give a technical reasoning, and to confirm if it is simply impossible for the OS to control and reserve some specific portion of the CPU just to guarantee that one does not loose control of the input devices and output devices. Since it is 2015 now, I suspect that it just might be possible to program an OS to behave like that, or are there technical limitations in CPUs and/or BIOS that simply prevents such control?
 

leeteq

Distinguished
May 28, 2009
18
0
18,510
mastodon.technology
Not sure I understand that. I am only asking if it is technically possible to enforce the system to reserve say 2% of the CPU, or even easier, a whole (1) of the cores, let whatever good or bad software use the other cores, but not at all the reserved one. Then - in my reasoning - I would expect that if something freezes, I would be able to operate the keyboard and mouse anyway, and open for example the system monitor and kill the process that is experiencing problems.

My question is this: can we program such control into the OS (Linux for example), so that one part of the system "always responds"? Is that technically possible with the hardware we have at our disposal now per october 2015? We have been waiting for decades for this, so now I think I finally would like to know what is the problem, technically speaking. I am not prepared to be given the same answers as I got in the 1990s when asking about this, or should I? And if so; why is that exactly, technically speaking?
 

leeteq

Distinguished
May 28, 2009
18
0
18,510
mastodon.technology
I am not saying a whole core. I am just trying to find out what is technically possible, and what is technically impossible, and where inbetween those, the limit goes, and why. So if you say that it is easier and actually technically possible to reserve a whole core, then the next question would be if it is completely IMpossible to reserve just 2% of that core, or if it for some technical reason is just more viable to reserve the whole. I would hope (expect) that by 2015, we have solutions that make it possible to reserve a given percentage of the CPU.

I think this should be documented in for example Wikipedia, including reasons and perspectives for the future. I personally think it is high time we can get rid of total computer freezes.

I understand that if something happens in the GPU, then possible the screen freezes and it becomes almost irrelevant if the mouse and keyboard continues to work (not totally), but if GPUs also can get a percentage reserved to guarantee that for example in Linux, one can get out of the desktop and into a terminal to launch some commands, etc., then that is something I would like to know why is not implemented already.
 
Maybe I don't get out much or something but I haven't had hard freeze's in years. Not like the days of running win98 with memory leaks and poor memory management and all. I generally use chrome for a browser and it somewhat sandboxes each tab so if you have an unresponsive tab it gives you so long before asking whether to wait it out or kill the page. It doesn't affect the rest of the pc or the rest of the tabs though. Every once in awhile flash acts up and reports a crash and it's as simple as reloading the page. Maybe that's not the case with other browsers, I don't really use too many others. Quit using firefox due to all its issues some time ago and have tried vivaldi a few times with no issue.

It just hasn't been an issue, not on my current i5 or my previous core2duo e8400 which was only a dual core cpu. Definitely not to the point of the keyboard or mouse becoming unresponsive. Maybe not enough ram? Really old/slow cpu? Really old version of windows? (I'm still running win7 which isn't exactly new by any means so it's not a perk from running win 8/8.1/10).
 

USAFRet

Titan
Moderator
What you seem to be looking for is a whole system sandbox. Thereby cutting off some of the system for actual use.

I can't remember the last time I had a system freeze like that. Certainly not this decade.
Probably not this century.

Don't run bad code.
 

leeteq

Distinguished
May 28, 2009
18
0
18,510
mastodon.technology
I have seen several cases (also recently) where seemingly JavaScript on tabs in Google Chrome freezes the whole computer, both on Windows and Linux.

I am not asking this because I have a problem to solve. I am looking for someone who can explain the technical limitations that OSes are facing per 2015 (edit: related to hardware/performance). I would like to understand the actual limitations of hardware as of now. Whether or not some bad code is to blame for a freeze is beside the point. I ask out of curiosity; I want to really understand if it is possible at all for an OS to control a portion of the CPU to protect input devices.

Say that a problem that is NOT related to the display driver or GPU makes something freeze. Is it possible to have a situation where we can actually get to at least switch to the terminal to issue some commands?

Can that part of the system be ensured to be running while "98% of the CPU/GPU is "frozen" (or gone wild: maxing out, thus causing a freeze)?
 

USAFRet

Titan
Moderator
I do not believe this is possible (today) in a regular PC. The CPU and other hardware simply does what the software tells it to.

The issue is.. the hardware you want to isolate still runs through the OS. Keyboard, mouse, screen. Once the OS chokes, for whatever reason....that's all she wrote.
Otherwise, the individual peripheral software/drivers would have to be baked into the CPU and motherboard firmware. Obviously, that would not work.
 

leeteq

Distinguished
May 28, 2009
18
0
18,510
mastodon.technology
Well, the BIOS works with both mouse, keyboard and display even before there is any OS installed, so that is not entirely the case. I suspect that parts of the reality here is that BIOS are not sufficiently flexible or advanced. That might be from security reasons, of course, or other such concerns.

However, what I want to know, is; in (freeze) situations where the cause of the problem lies in the operation of/within just one program, for example the browser, is it not then possible to at least prevent "all running instances of all browsers" to use more than x% of the CPU, and have the OS reserve for example 1 or 2 percent of the CPU for "crisis handling", so that as long as it is not an actual "driver crash", then we can get to stop the problematic process through at least the terminal?

It is my impression that many or most of these freezes is due to processes running loose, looping, or whatever might cause the CPU to max out, run at 100% and "never" come back down - and then during that process the input devices are also frozen. The impression is that of "poor multitasking" handling, from a non-technical perspective. Whenever it is not indeed technically a mouse problem, for instance, then the mouse should be not only "working" but also "smoothly" no matter which other process is maxing out on the CPU or GPU usage.

My point is if it is possible to have some buffer left to ensure smooth input (edit: and output/display) device operation.
 
Where I've seen a program (say an entire browser instance with multiple tabs open or multiple windows) lock up and become unresponsive, it usually doesn't take the rest of the system down with it. Typically you can enter a command like ctrl+alt+del from the keyboard (within windows) to bring up the task manager and even when windows explorer is jammed up from a halted program it gives priority to the task manager. From there you can end a task, even end windows explorer then go to file -> new task and search through the windows file folders and manually restart explorer.exe.

It may not be sandboxed but by using various priorities the pc can typically recover. I'm not sure exactly how to go about that in linux but haven't encountered that issue in linux either (not yet anyway). I believe some things are by default given realtime priority and while you can change priority for various open applications in task manager (normal, high, very high etc) it won't allow you to set most things to realtime. My assumption and I could be wrong, is that realtime is reserved for such things so the os can prioritize and still gain access to task manager when the rest of the desktop seems frozen.
 

leeteq

Distinguished
May 28, 2009
18
0
18,510
mastodon.technology
Yes, that is the assumption we are all making, but when thing really freeze up it is very clear that also input devices are affected or even totally frozen. My main point is that if that even happens once, even just slightly noticing some lag in the mouse, then that is the proof that the OS is not (at that moment) actually (able to, or configured to?) reserving enough resources to not affect the input devices. Since we also have (far fewer, acknowlingly, but still) total freezes, where it is totally clear that "something happened in the browser", we know that this mechanism is not solid. And I am curious to find out very exactly why it is so that we in 2015 cannot make (or configure) (os) systems that maintain full control on input (/output).

Now that GPUs also are multi-core, even the screen freezing should be history. Cannot the OS detect a frozen driver and then perhaps shift to a secondary driver temporarily? Cannot the OS know when the display is not respoding normally, at the same instant as our eye catches the problem? I really want to get to the bottom of this, and see if we can at least make a clear, insightul documentation, with some perspectives.

I am starting a series of posts on my blog related to define logical/"non-tech" user-contributed wishlist-specs for the design of "next generation" laptops (such things as using the space given to CD/DVD for secondary HDD/SSD, etc.,) and I want to know if there are any hardware specs for CPU/GPU/BIOS that can indicate for vendors (and enlighten users generally) on what might help eliminate freezes alltogether.

I think it is high time now in 2015 IF it is technically possible at all.

My impression of why this is such a difficult topic, however, is that this very question contains indirectly some embarassment and "reasons for less pride", which demotivates highly insightful individuals from contributing clear answers to such debate. This has been the case for decades, literally, an just that fact makes the embarassment increase with time. Why did this not become possible "already" in the 1990s, for example? And now 20 years later, less problems, but still have not removed the technical possibility, which is my point here.

I understand it is painful for people who love tech to "admit" (or even parttake in a discussion about it) that we cannot do this which from a non-tech perspective seems like a "trivial thing", but I still want to find the real answer(s).

Now, expanding on that a tad, with recent developments:

We are now seeing the rise of "Open-Source Hardware", and will undoubtedly see more and more custom-design options where laptops partially get more modular.

In these post-Snowden times, who is to say that we will not "soon" encounter more evidence that some of the prevailing CPU/GPU design specs include deliberate possibilities for total freezes, just to keep the possibility open to take down/take control of a computer?

We know these kind of vulnerabilities are already possible to exploit, but we have not yet (I think?) seen examples on computers where this possibility is by design/man-made. We have, however, seen several examples on other hardware/firmware/driver products that even after/through repeated fixes, are deliberately designed to make such attacks/back doors possible, in particular in routers the last couple of years. The fixes to revealed vulnerabilities have introduced new back doors or just pretended to close the loopholes. By design.

So, for several reasons, I would like to know if the main question I have rised in this issue (see the title) is technically possible or not.

Where can we get in touch with people who can answer this very precisely?
Anyone of them frequenting these forums?
The real experts? The CPU manufacturer's designers?
 

waxitman

Honorable
Mar 17, 2012
19
0
10,520
I have also pondered this situation recently. Freezes may be less common but a freeze is a freeze and until they are totally eliminated then leeteq's point is a very valid one.

I believe it is possible to isolate the linux kernel to one CPU core which would be reserved specifically for the OS. Probably not too difficult either. I don't know enough to say that it would prevent the system freezing. Maybe in some instances. It is a huge blow to performance to do it this way though. You woud lose 25% processing power from a four core CPU. Perhaps in a server where they are already providing hard disk redundancy and able to hotplug cpus this may be acceptable.

The OS is able to read CPU state and throttle it for power saving, likewise the GPU. How about writing a tiny loop code to run on the GPU which checks CPU cycles. If these stop the GPU immediately load sheds and runs the OS until a safe reboot can be made. At the same time the CPU counts FPS and if these cease will override and bypass the GPU and VRAM to directly output graphics through the connected HDMI/VGA/DVI. Similar loops can be run on all PCI and integrated hardware, most would not be critical if isolated when suspecting an error.

I have been thinking of a system like this for overclocking which will often cause a hard system freeze. The system only needs to respond long enough to reset the CPU defaults and then initialise it again. This would eliminate the need for rebooting at these 'regular' events. Just overclock either CPU or GPU and the other would do the babysitting. Once everything was stable then both overclocks could be applied. This need not be a huge blow to performance, possibly <0.1% of total processing power. Not a bad compromise to never lose unsaved work again.

I am not a programmer. I have been reading a lot about overclocking and this presented itself as a possibility. Maybe someone with more knowledge on the matter could lend their opinion.
 


I'll answer this as best as I can, disregarding HW problems and outright coding errors. I'll talk from a Windows perspective, since I'm more familiar with the Windows scheduler in particular.

What it comes down to, is the OS scheduler is going to use some method to service all the threads in the system that need to run. At any point in time, there's a couple hundred of those. And the OS is juggling these threads several hundred times a second.

*Most* of these threads don't do significant work or are sleeping, but they still take up CPU time, and interrupt whatever thread was currently running on that CPU core. This can easily result in a thread being bumped to another CPU core (the OS really doesn't care what threads run on what CPU core), which degrades performance if the CPU cache doesn't immediately have the data it needs. In addition, threads automatically get bumped if they are waiting for resources to be assigned (HDD reads, memory assignments, and the like), and if you have multiple threads all requesting memory or HDD access, you can end up blocking one for potentially a significant amount of time.

Here's an example of thread management nonsense: You have an application doing some significant work, with a little box with a cancel button that stops that work. Simple enough; you hit the cancel button, and you expect the application to stop. However, even if you have a thread to handle the message-box input, there's really no guarantee when the OS will actually get around to executing that thread, and process the button command to stop working. The way Windows in particular is designed, is that threads that are running in the foreground (the current application) get preferential treatment, in order to maximize performance (the idea being most people run one heavy application at a time, such as games, which you don't want to get bumped by some background task). So that thread that tells the application to stop? It might take a couple of seconds for it to run, execute, finish executing (it can be bumped before finishing, just like any other thread), and finally give you control of the PC again.

Now, under the hood, the display thread that manages the screen is just another thread, and just like any other thread, there's really no guarantee it will ever get executed in a timely manner. Granted, it's got super high priority, being a system thread, and can bump *almost* any other thread in the system (Audio and UI typically have higher priority in Windows), but do enough work, and have enough other threads, and yeah, it's quite possible it gets delayed a second or two.

Note the Desktop typically seems to lock up more on Windows system not because the actual update thread is being prevented from running, but because DWM.exe, the Desktop Windows Manager process, is a user-space process, and thus has the same priority as a normal user-space program, which is much more likely to get blocked then a kernel thread.

If you want to guarantee some thread runs within some specified timespan, you're basically talking about a Real Time OS, where TIME is the most important condition to meet. Overall performance is lower compared to multitasking OS's, but I can guarantee a timespan where every thread will be executed. So yes, it's quite possible to get rid of the types of delays you are talking about, but you'd need to use an OS that's about 50% slower overall then what you're using now. Like all things in life, there's a tradeoff involved.