36

As I remember, the SysRq key generated a special, unique interrupt (not an ordinary keyboard interrupt). It was supposed to let the user interrupt any process in a multitasking situation and return control to a special handler in the system. But, as far as I know, no one ever used it.

It seems like it would have been a great interrupt to hook if you wanted to interrupt a hung program. Early DOS days had no Windows Task Manager. It could also be intercepted by a long process to report the status of the process. I used something similar on a mainframe that processed a huge number of records and ran for hours.

It could be used to swap execution contexts, like in the GEM operating system. But I don't believe anyone ever used it for anything.

Is that true? It seems like an incredible waste.

7
  • 3
    I have a vague recollection that IBM TopView used the SysReq key. But I can't find any evidence of that after a couple of minutes of looking. Commented Feb 11 at 23:25
  • 1
    @GregHewgill IIRC in TopView one had always go thru the switch menu item, accessed after pressing control.
    – Raffzahn
    Commented Feb 12 at 0:57
  • 1
    <fd.lod.bz/rbil/interrup/bios/1585.html>? Commented Feb 12 at 10:26
  • 3
    Possibly of interest: Linux can use it and I recall using it on some systems c. 20 years ago. It couldn't recover a hung system, but it could get that hung system to do certain things, such as crash (with a crashdump), sync all mounted filesystems, unmount them, then reboot. So slightly better than a hard reset, especially before ext3 and journals came along.
    – Jack B
    Commented Feb 12 at 18:04
  • 1
    It's been a while (25 years give or take a few) but I dimly remember that it had a function in either QEMM or DesqView - pieces of early, DOS-based multitasking systems. But as it's been a while, I don't recall any details and I could be flat-out wrong.
    – Tom
    Commented Feb 12 at 19:36

4 Answers 4

33

TL;DR: One of the great Ideas that never Materialized

Contrary to what is often assumed, the key was not added to support some 3270-style emulation1, but to enable a basic multi-application/OS environment where DOS would be only one of several applications. Support for that was added with the AT, but it never came to be.


As I remember, the SysRq key generated a special, unique interrupt (not an ordinary keyboard interrupt).

Kind of. When pressed, the keyboard will issue a hardware IRQ 1 just like any other key. IRQ 1 is routed to INT 09h, which handles all keyboard input. With an AT BIOS (or later), the BIOS handler will call INT 15h2 function 85h if SysRq is pressed or released.

  • Sub-function 0 is called when SysRq is pressed.
  • Sub-function 1 is called when SysRq is released.

It was supposed to let the user interrupt any process in a multitasking situation and return control to a special handler in the system.

Yes, SysRq was intended as part of a set of functions to enable creation of a bare metal hypervisor, intended to run multiple OSes at once and in parallel.

But, as far as I know, no one ever used it.

Yes and no. The development version of OS/2 used SysRq to bring up a very primitive3 task manager. The first customer release changed the name to OS/2 1.0 and its keystroke to Ctrl+Esc4.

I used something similar on a mainframe that processed a huge number of records and ran for hours.

That was exactly the idea behind addition of these services.

It seems like an incredible waste

It was originally intended to be used with OS/2, but that changed from being a simple multi-tasking system to a more ambiguous one.

DOS 4.0 in turn used a complete different structure5.


1 The 3270 knew more than one single-key message, so adding only one key wouldn't help much. Even less is there a need to add a special interrupt service for only one, since the application gets interrupts for all keys anyway.

Both the 3270 PC and the 3270 AT used their own large keyboard with more than a dozen additional keys. To handle this, an additional ISA card was used, to which the keyboard was connected via a special cable. It handled the additional keys as well as a loop thru mode that would allow the keyboard to be used for regular PCs.

2 Int 15h originally handled cassette I/O (function 0-3h). The new AT functions, called "Extended AT Services", were added with function numbers starting at 80h. Those included basic functionality for extended memory support (access of memory above 1 MiB for real-mode programs), but also basic services needed for a hypervisor to manage multiple OSes in parallel. SysRq handling was one of those services, intended to be used to switch to the hypervisor's user interface.

The main idea of those functions was to offer a very basic set of communication interfaces to share resources (devices, memory, and processing time) between otherwise independent OS instances. One of them handled the sharing - much like back in the 1960s with CP/CMS on /360 mainframes. It consisted of the Hypervisor CP-40 and the CMS OS running as one of its guest OSes.

3 It was just a list of running applications. Only the names; no other information. All it could do was switch.

4 It is interesting that one of the names, before IBM and MS settled for OS/2, was CP/DOS, quite an obvious reference to CP/CMS.

5 DOS 4 is what Microsoft developed as a multitasking followup to DOS 3, continuing a soft switchover to Xenix. When Microsoft joined IBM with their OS/2 approach, all of that got dumped.

6
  • 2
    Too bad Windows didn't use it for Secure Attention Key. Linux eventually used it for unstick console commands.
    – Joshua
    Commented Feb 13 at 22:28
  • 1
    @Joshua Windows 1&2 was intended to run also on 8088 computers (PC, PC-XT), which keyboards didn't have that key.
    – Raffzahn
    Commented Feb 13 at 22:38
  • 1
    Secure Attention Key is from the NT branch though.
    – Joshua
    Commented Feb 13 at 22:41
  • 1
    I just now noticed that my keyboard doesn't have a SysReq labeled key. The key is just labeled "Print Screen."
    – trlkly
    Commented Feb 14 at 4:09
  • Oddly, the SysRq scancode is treated specially in the 3270 PC -- if ALT is pressed, it toggles the top bit of port 0189h, one of the registers in the video controller. After that, the scancode is processed like any other.
    – john_e
    Commented Feb 14 at 10:30
20

The SysRq key is a perfectly normal key on the keyboard.

It does not generate a special or unique interrupt by itself.

The standard keyboard interrupt of BIOS just does what it does for all keys and reacts accordingly, and for the SysRq key, it simply calls INT 15h with AH=85h.

So not any different from Print Screen key where BIOS calls INT 5h or Ctrl-Break sequence where BIOS calls INT 1Bh.

So if a DOS program is hung, it is hung. The system cannot return to DOS from a game or program that has already gone haywire and the only thing left to try is to reboot with Ctrl-Alt-Del, if it even works any more.

The intention for SysRq key was originally supposed to be used on 286 PCs which had protected mode that allows isolation of say Unix kernel from programs and thus bring up a console to kill the hung program.

Apparently some debuggers used it as triggering a TSR and Linux can be configured to use it.

4
  • 4
    I thought the original use of SysRq was to provide a keyboard like IBM 360/370-ish terminals had, for 3270-ish emulation.
    – davidbak
    Commented Feb 12 at 0:18
  • 3
    Correct. Back in my Mainframe days when 3270s ruled the world, SysRq was the key you hit when CMS got stuck in CPWAIT and you needed to talk to the VM/SP command processor. The key naturally migrated to PC keyboards, but lost its function as the PC had no lower-level executive than DOS. Commented Feb 12 at 9:18
  • 1
    @Eight-BitGuru Well, it got added to the AT not for some emulation - the exactly for adding a CP like system. The key is part of the extend AT function intended to provided a CP like system below DOS.
    – Raffzahn
    Commented Feb 12 at 12:09
  • 1
    @davidbak The 3270 emulation needs way more keys than this SysRq. Its Keyboard was a special 122 key one - including an ISA card with its own keyboard controller.
    – Raffzahn
    Commented Feb 12 at 12:11
3

The DOS version of the SoftICE debugger allowed the use of the SysRq key to pop up the debugger UI.

The VM/386 system allowed up to 99 virtual DOS machines to run simultaneously using a single copy of MS-DOS, and the SysRq key brought up a hypervisor-style menu.

-1

It's not implemented like you might think. It's like an arrow key or page up/down. These keys have an os-wide defined use which can be overridden in a command line app. You can also define SysRq as a well-known command in your app or some sort of Easter egg. So there is no telling if it was used in DOS apps at all.

Many Unix/Linux kernels support the SysRq magic keys and you can use the SysRq key the same way you might use any other key on the keyboard. The Google Pixel 7 shipped with these features enabled, as a recent commercial example.

However it's use extends into modern day Linux. By enabling certain flags in the kernel build, you can use it to hard reboot by using a magic key sequence+b(alt+sysrq+b), kill all processes except init with magic+I, or cause a kernel panic with magic+c. These are useful for debugging and empirical security feature testing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .