8

I wonder which was the first operating system that had context switch and what are famous examples of OS that didn't have context switch?

Chenmunka
  • 8,141
  • 3
  • 39
  • 65
Niklas Rosencrantz
  • 1,111
  • 8
  • 22
  • 9
    Define context switch. Any system that supports interrupts does context switching, and on a conceptual level, using WordStar for an hour and another hour Multiplan on a CP/M machine is a context switch as well. Even a pocket calculator that has "M+" and "RM" keys supports context switching on a conceptual level. As it is now, there cannot be a definitive answer to this question. – tofro Aug 01 '17 at 11:48
  • 2
    Even a device as simple as an Abacus supports the concept of context switching. – tofro Aug 01 '17 at 11:56
  • @tofro Saving the stack of the current thread and changing it? – Niklas Rosencrantz Aug 01 '17 at 12:27
  • 1
    An Abacus was able to do that, as mentioned above – tofro Aug 01 '17 at 20:21
  • @DjDac Err... and what about stackless machines? – Raffzahn Sep 04 '17 at 07:42
  • 1
    @tofro How do you do context switching with an abacus? Take a photo of it? – JeremyP Sep 04 '17 at 08:46
  • 2
    @JeremyP For example. Or just use another set of rows, leaving the ones you just have worked with alone for a while. – tofro Sep 04 '17 at 08:54
  • I could do it on a TRS-80 Model 4 or 4P, provided it had 128 KB RAM. It would give you 2 environments you could run separate programs in, and a third one to run console commands. – Jan80TRS Sep 04 '17 at 00:04

1 Answers1

17

The first operating system to implement context switches as we understand them today was the Atlas supervisor. Quoting T. Kilburn, R. B. Payne and D. J. Howarth’s 1961 paper on The Atlas Supervisor (printed in AFIPS Computer Conference 20 and in Per Brinch Hansen’s Classic Operating Systems):

While one program is halted, awaiting completion of a magnetic tape transfer for instance, the co-ordinator routine switches control to the next program in the object program list which is free to proceed. In order to maintain full protection, it is necessary to preserve and recover the contents of working registers common to all programs such as the B-lines, accumulator, and control registers, and to protect blocks in use in core store.

The idea itself was first described by Christopher Strachey in his 1959 paper, Time sharing in large, fast computers; the main purpose was to allow computers to switch tasks when one task was blocked waiting on I/O. Interactive task-switching followed shortly; the first demonstration of that was CTSS in 1962 (this is what ended up being known as time-sharing; Strachey’s concept is referred to as multi-programming). In fact John McCarthy floated the idea of time-sharing in an unpublished memo dated January 1, 1959, so both concepts were contemporaneous.

Strictly speaking any operating system which supports hardware interrupts has to support some form of context switching, even if it is strictly single-tasking (like MS-DOS). So the only operating systems which didn’t have any form of context switching were the few batch processing operating systems in the late ’50s such as BKS on the Philco-2000.

Context switching arguably pre-dates operating systems, or rather, there were computers without operating systems designed as such which nevertheless supported context switches: the X—1, built at the Mathematical Centre in Amsterdam, supported interrupt-driven I/O, and it was demonstrated with a small coordination program used to switch between two running programs, one CPU-limited, the other I/O-limited.

Another outcome of the interruption facility is that it is quite easy to run two programs at the same time. This was rather a strange sight when we tried it the first time, and we were very astonished to find that the system worked.

Stephen Kitt
  • 121,835
  • 17
  • 505
  • 462