What does the SysRq key do?

Solution 1:

SysRq was introduced on IBM PC keyboards as a way to have a cross-platform way to initiate a low-level event. When typing the keys, they get put into a buffer and flushed periodically. If your machine locks up, the keyboard does not work.

The SysRq key was basically to force a command to be sent to the computer, bypassing the buffer, to trigger a low level call; usually a RESET event.

However, each OS ignores this key now, and uses a preferred combination keystroke to initiate some sort of 'Task Manager' like interface enabling the OS to remain running, rather than a reset the computer.

Its much more common to run applications from the host OS, rather than from the BIOS. It wasn't like that in the 1980's :-)

Solution 2:

The SysRq key was invented in the early days of personal computers, when low-level Terminate and Stay Resident (TSR) programs could directly access and modify the keyboard buffer. This key bypassed the buffer and gave direct access to the MSDOS operating system.

Today this key is ignored by the BIOS and by Windows. It has been relegated to the Prt Scn key and is activated by Alt+Prt Scn. Some manufactures, for example Lenovo, no longer mark it on the keyboard, although it can still be accessed as above.

Some older debuggers used this key as the break-execution key, but this no longer exists.

Under Linux the key is still present, requiring that the CONFIG_MAGIC_SYSRQ kernel option was specified when the kernel was built. This can be checked by entering the command:

$ cat /proc/sys/kernel/sysrq
176

The command will most often return the value of 176, where each bit stands for one function:

0 - disable sysrq completely
1 - enable all functions of sysrq
2 - enable control of console logging level
4 - enable control of keyboard (SAK, unraw)
8 - enable debugging dumps of processes etc.
16 - enable sync command
32 - enable remount read-only
64 - enable signaling of processes (term, kill, oom-kill)
128 - allow reboot/poweroff
256 - allow nicing of all RT tasks

A value of 0 disables all SysRq functions and a value of 1 enables all of them. The running value can be changed for example by the command:

echo "1" > /proc/sys/kernel/sysrq

Of all command key sequences, REISUB is the most famous, when holding the Alt+Prt Scn keys and pressing the following keys in sequence:

  • r : switches the keyboard from raw to XLATE mode
  • e : sends a SIGTERM signal to all processes, to close gracefully if possible
  • i : sends a SIGKILL signal to terminate processes which didn't respond
  • s : sync all mounted filesystems and flush all cached disk changes
  • u : remount all filesystems in read-only
  • b : system reboot.

References:

  • Wikipedia System request
  • How to enable all SysRq functions on Linux
  • What to do when Ubuntu Freezes/Crashes?
  • Alt + sysrq + REISUB doesn't reboot my laptop

Solution 3:

It is a programmable key which can be made to do a variety of things, depends.

I remember it having some uses on old ibm terminals, and some DOS programs used it for a form of soft resetting.

Solution 4:

On linux it still serves a very useful function:

https://en.wikipedia.org/wiki/Magic_SysRq_key