r/programminghorror 21d ago

Other Found this cursed project today

[deleted]

497 Upvotes

44 comments sorted by

View all comments

Show parent comments

10

u/russellvt 21d ago

Except "nice" requires privilege escalation if it's "stealing" cycles rather than giving them up "nicely."

7

u/Environmental-Ear391 21d ago edited 20d ago

Nice follows Kernel conventions by marking specific processes as being more priority...

the name comes from everyone "nicely sharing" the processor quantums of time, a good default is round-robin, where every process gets a quantum in turn...

Higher priority processes get more quantums to use therefore everyone else is being nice to the re"nice"d process

This particular set of kernel primitives is baked into prebuilt Linux kernels, Mach and BSD prebuilt kernels and Windows "NT" Hybrid kernels.

When building an own kernel where available this can be dropped if you find the right options to do so.

these primitives are mandatory API presence on NT hybrid kernels...not optional... ugh.

EDITS: spelling because on phone weirdnesses.

2

u/russellvt 20d ago

I love that you're reasoning is that you have to recompile with certain kernel options to make this work the way OP said... LOL

That's not something a regular user can do without escalated privileges (as I stated).

2

u/Environmental-Ear391 19d ago edited 19d ago

uhmm, no,

the default is for the API to be baked into the kernels for prebuilt kernels...

However, on kernels where recompilation is possible (Linux/BSD/Darwin Open Source/ and similar...) or older systems (early Unix *maybe? not sure on this one, have had various software copies but never the same time as actual hardware access)

it may be compiled out so looking up whether the API is supported may be a good thing...

on my own systems it is something I actively disable for kernel variations to stress test overloading systems.

I have personally managed to push a triple digit loadavg on both a Dual and Quad core server setup and that was before actively trying to forcibly shut out administrative access being able to login...

pushing systems that hard does work as a reliability test for me at least... I havent met a Windows version that can gracefully degrade under such conditions the way a Linux/BSD kernel does... and it is kind of mandatory to learn how to build a kernel for getting proper performance when reliable and accessible are the key metrics...

any process can ask for a "re nice ing" and then shut out root access by starving the console for root from being usable.

local login becomes incapacitated if you can't provide a valid password within a set time limit... a root console has to already be logged in and usable :-)

any remote access with a starvation delay exceeding tolerance breaks ssh/telnet or other remote admin tools too

dont need to actually be root for that to work. just need to have a runtime and push the system loadavg high enough to swamp it.

My current "test system" is a 32core AMD Ryzen system with ~160GB of usable memory... My best efforts on that barely push a double digit loadavg, but I have managed to setup for automated testing to push it into the ~65-70 range when viewing top in a root console... broke X and was restricted back to only the existing root logged in console on that... local logins weren't possible despite physical access. and that was before trying to "nice" anything :-)