501 points · by RyanRies · 11y ago · 169 comments
kill -STOP 1234
kill -CONT 1234
killall -STOP -c "Pandora"
killall -CONT -c "Pandora"
A more nuanced control is to throttle down the CPU, via cputhrottle[1].If I'm running a CPU-intensive calculation and don't want to bog down the rest of my system I will use it to give me enough cycles for Sublime Text to work smoothly.
It's easy to call:
sudo cputhrottle PID cpuUsage%
ex. sudo cputhrottle 12345 400
1. http://www.willnolan.com/cputhrottle/cputhrottle.htmlEvery once in a while I am reminded how wonderful, and perhaps unlikely, it is that I have a nice, slick, mass market consumer device (apple computer running OS X) that is honest to god UNIX underneath.
And then sad, knowing that this is a brief golden age that will probably pass.
tl;dr a more powerful operating system with worse UI, which is the obvious trade. A less powerful system with a fantastic UI.
We have also seen an incremental approach in the gradual replacement of open APIs/components with closed ones.
> How can operating systems research be relevant when the resulting operating systems are all indistinguishable?
> There was a claim in the late 1970s and early 1980s that Unix had killed operating systems research because no one would try anything else. At the time, I didn’t believe it. Today, I grudgingly accept that the claim may be true (Microsoft notwithstanding).
> A victim of its own success: portability led to ubiquity. That meant architecture didn’t matter, so now there’s only one. Linux is the hot new thing... but it’s just another Unix.
#!/bin/bash
currentProcess=$(xprop -id $(xprop -root | grep -F '_NET_ACTIVE_WINDOW(WINDOW)' | awk '{print $5}') | grep -F '_NET_WM_PID(CARDINAL)' | awk '{print $3}')
state=$(grep 'State:' /proc/$currentProcess/status | awk '{print $2}')
if [[ "$state" == "T" ]]
then
kill -CONT $currentProcess
else
kill -STOP $currentProcess
fiWhere it gets more interesting is using elaborate checkpoint/restore [1] mechanisms for processes to serialize their state (open fds, watches, IPC, etc.) into an image that can then be overlayed, remotely executed, debugged and so forth.
I mean, of course, we have these apps that splay themselves all over global system resources in complex ways, and so we need to track down how they've done that, record it, and then replay it later to restore them. It's necessary.
But imagine a well-behaved classical X11 app, running in something like a VM or Docker container. You execute its launcher, the VM spins up in the background, the app launches in the VM, and the app's X11 client connects to the X11 server you're staring at and displays things.
If we truly want to sandbox apps, wouldn't it make more sense to move more toward a model like that—one where you have a discrete "application backend process" running in a sandbox, and you can just chuck around the sandbox itself willy-nilly (freezing it, thawing it, copying it, etc.) because it has well-defined connection-points to the host?
C/R enables complete persistence by duplicating a process from its image, which can cut initialization and startup times by orders of magnitude, and resume service from an exact position with zero downtime, and not just basic mechanisms like socket superservers.
It lets you back up process state at any arbitrary moment, send it over the network, recalculate and reexec immediately and then thaw again for debugging it from that particular point.
It just helps enable live migrations and zero downtime recoordinations with far less complicated redundancy schemes. This includes containers. On top of it being a universal save/pause button.
Depending on the robustness of the image format, it can be made space efficient through deduplication.
C/R is quite invaluable for any scenario that involves fault tolerance, high response times, tracking down difficult bugs, low startup overhead and so on. I'm surprised why it's still such an obscure technique.
Besides, I don't think the primary use case here is even graphical apps (not that they don't work just fine). What you really want is a local indexed copy of all the execution environment details, like pipes, sockets, timers, ttys, timers, sigmasks, *fds, etc. for infrastructure.
calc
$a = Get-Process calc
$a.ProcessorAffinity = 1
$a.PriorityClass = "Idle"
$b = [Diagnostics.Process]::Start("PowerShell", "-c while (1) {}")
$b.ProcessorAffinity = 1
Ta-da!The bizarre part, when it comes to Flash, is that I've yet to see an actual difference in the application behavior when I throttle down it's CPU usage. I would think that if it normally maxes out 7 of my 8 logical cores, being limited to 40% of one core would make introduce slowness. But I guess that's just an indication of how poorly written the OS X flash client it.
I use cpulimit to force a CPU bound program to slow down. I also use it for programs that always max out the CPU for no good reason, and work fine with less CPU.
Nice won't help with either of those.
These days of MMOs and other coordinated time-sinks make me miss the simplicity of pausable single-player and turn-based multiplayer sometimes.
Hell, even the single player games are getting to be unpausable. How many cut scenes are there in GTAV? And if other duties are at hand, the only option is to skip the story line so you can pause.
These days I can at least hit the Home button on a Wii U game and expect it to work. Emulators are still hogging save-states all to themselves, though.
Now, I only need a similar tool that kills the process with the highest CPU and MEMORY load with a short cut. Reasons: Sometimes a process leaks memory and fills up 16GB RAM and opening a new process like taskmgr is impossible to severe paging-IO. Sometimes a full screen application crash and spawns a modal crash dialog behind the full screen window so only taskmgr and keyboard usage works (as the mouse is hidden by the crashed full screen app).
Edit: Not working as expected :(
Run python script that allocated a couple of gigabytes of RAM effectively causing my machine to freeze. And OOM killer figured out the best thing it can do is this:
[2889118.406439] Out of memory: Kill process 11878 (SpotifyHelper) score 302 or sacrifice child
[2889118.406442] Killed process 11878 (SpotifyHelper)Did you try it on Wine yet?
The Witcher 3 pauses cutscenes when the window is not in focus. So the example is probably not the greatest.
I will always have a soft spot for small, lean single function applications. I guess it takes me back to my UNIX days. Some of my favourite more modern programs are SumatraPDF, uTorrent (the older 2.x versions) and Notepad2, lovely single exe programs that are self-contained. No installers and messy configs all over the place or in the registry.
Or run `perfmon /res`.
delay = currentFrameTime - lastFrameTime
playerPosition += direction * delay
I know that some games (such as Diablo III) may automaticallt ban you if you happen to run a program that may be used to cheat (they detect that via a background process check).Some time ago I had an application crash on a development machine while I was playing a game. On my dev machine crashes go straight to ollydbg. Next thing I know I'm kicked from the game, and it tells me to stop 'using cheat programs'. Go figure :p
https://tuts4you.com/download.php?list.3 https://tuts4you.com/download.php?view.2425
Although they did, there were some item duplication bugs. And even that was irrelevant, since there were quickly popping up small armies of item / gold farmers; every once in a while they'd get banned, but by then they would've earned enough money to buy another fifty copies of the game and continue.
Then give back the time later (if you need the clock to match the real clock) when it's waiting for input.
e.g http://pcgamingwiki.com/wiki/Remember_Me#Skip_intro_videos
if (ForegroundWindow)
{
...
}
else
{
MessageBox(NULL, L"Unable to detect foreground window!", L"UniversalPauseButton Error", MB_OK | MB_ICONERROR);
}
becomes if (!ForegroundWindow)
{
MessageBox(NULL, L"Unable to detect foreground window!", L"UniversalPauseButton Error", MB_OK | MB_ICONERROR);
break;
}
...I've added this to the scoop-extras bucket for Scoop[0]. So users with the extras bucket can install it using:
scoop install universalpausebutton
EDIT: Do you have a licence?[0]: http://scoop.sh
If you want to actually pause the linux kernel you'll have to use something like the magic SysRq: https://en.wikipedia.org/wiki/Magic_SysRq_key
Alternatively you can run the operating system in an emulator like qemu.
An interesting startup idea would be a bluetooth thingy (kinda vague, maybe a necklace?) that when pushed becomes a TRUE universal pause button. Pauses my DVR, my car audio, my linux mythtv box, everything, silences my phone ringer, mutes the TV, shuts off the alarm clock, temp-mutes the smoke alarm if its currently going off, silence the oven timer, car alarm off if its currently sounding, you name it.
Sounds technologically possible although a huge PITA, which sounds like a great startup idea.
You might need to ram thru a whole new bluetooth LE broadcast protocol, maybe. Or just a blind beacon of "anything" thats sniffable (edited: whoops that wouldn't work so well with silenced burglar alarm systems).
I suspect this would sell pretty well once it gets universal...
The security implications and UX involved in managing settings in a non-infuriating fashion rapidly sunk it though, and I daresay it would never have been practically deployable unless business/landowners/whatever could enforce its use as a condition of entry.
Also, you forgot the hollow tooth + airbag components + RF magic => remote operated ball-gag :P
https://chrome.google.com/webstore/detail/media-keys-by-sway...
In that case, after unpausing, the animation would just skip ahead.
As a remedy, the pause button could also stop the system clock as seen by the process.
That is a lot of work, but I wonder if there are no debugging or reverse-engineering tools that work in that way.
Looks like the real solution would be to pause your SO ;)
My solution was the DS/3DS line of consoles... snap 'em shut, bam, paused. I've called them the consoles of choice for the discriminating father.
(If you've never had kids and find yourself wondering what horrible father would be playing video games while taking care of his children, well, you see, it turns out that sometimes your child wants to sleep on somebody, and will not sleep any other way... and there's only so many things you can do with a baby that cries if you move sleeping on you. Both of my kids went through that phase for different reasons.)
I'm a fan of this as well - works for PSP and Vita too, just quickly press power and it's in sleep mode. However, I have run into one game that didn't properly pause itself when closed. I think it was Kingdom Hearts 358/2 Days. Its cutscenes didn't pause when I closed my DS. Otherwise, yeah, this is the greatest.
uh and you'd need to find that pause key the dimension above...