system
Given the following post, respond as if you're commenting on Reddit:
human
Why do O/S ever hang? Why don't they prioritise the basic UI operations so you can close things down?

I was using Linux today and the browser took up all the CPU cycles to the point where the mouse and keyboard weren't even working. I tried to switch to a terminal screen so I could terminate the offending process but they key-sequence didn't do anything.

It's not just Linux though, I've had exactly the same problem on Windows.

Why aren't there some basic UI activities that are given processor cycles above all others? For Windows it would be mouse, keyboard, window operations (but not repaints), menus, power management and task manager. For Linux it would just need to be mouse/keyboard, window operations and power management. In Linux if you can switch to a terminal screen you can usually interact, if slowly.
gpt
A full system lockup is not usually because of the CPU being maxed out, it is because something critical in the OS has crashed and taken everything else with it. Rendering windows and handling inputs is a much more complicated process nowadays, involving multiple devices communicating that might even partially bypass the CPU, like with composited window rendering.

The mouse and keyboard *are* prioritized over almost everything. If your web browser caused them to lock up, it probably was a bug that caused the xserver (responsible for drawing windows as well as the mouse and keyboard on the screen in Linux) to crash. You get similar effects on Windows or MacOS if the process responsible for drawing the screen or handling input crashes.

This is not quite the same as a kernel panic (where the core of the OS itself crashes, AKA a blue screen on Windows), though they can be related.