3

The book "Modern Operating systems", says

The Operating System is an Extended Machine.

So I wonder if an OS is a model of computaion, and whether it makes sense to say if an OS is Turing complete? Thanks.

2
  • As far as I can tell the quotation is not meant to refer to Turing Machines in any way, and is merely saying that the OS "extends" the hardware with a bunch of useful higher-level features. Still an interesting question though. – Ixrec Jan 15 '15 at 7:56
  • 3
    Turing-complete is like saying it can potentially do anything a modern computer can do, time permitting (disregarding the theoretical infinite memory and such). That doesn't make much sense being applied to a program being run on the "turing-complete" machine unless the operating system were simulating a machine in of itself (which as operating systems go, they generally don't). – Neil Jan 15 '15 at 8:36
8

Probably not.

Operating systems expose an API that provides services. Despite the apparent complexity, the vast majority of service calls in a OS API are just that: service calls, and nothing more. Operating systems do not typically provide looping services, or any of the other mechanics of a Turing-Complete machine; programming languages provide such mechanisms (i.e. the programming languages that call the OS API).

If an OS call does provide a looping service (e.g. traversing all the files in a folder) or some other operation that characterizes a Turing-complete mechanism, it does so at the behest of code written by some programmer in a Turing-complete programming language.

3

I would generally say "no" with a caveat.

The main difficulty is that the phrase "operating system" is very broad -- an "OS" could be a standalone microkernel without any attached services, or an OS could be a multi-user graphical environment with a hundred subsystems, or anywhere in between.

When you decompose a modern operating system, you may find that it includes components or services which are Turing complete. For example, the "Debian" OS includes "bash" as a central part of the system -- without bash (or some workalike), you wouldn't recognize it as the same operating system. Bash, of course, provides a Turing complete programming language.

You might say that Debian is indirectly Turing-complete - because it has a Turing-complete component. But that's misattribution. If you wanted to have a discussion about the computational soundness of Unix-style UX, you would talk to the authors of bash -- not the authors of Debian.

1

This depends on how the operating system is implemented, and on how you answer the question of what is part of the operating system and what isn't.

As other answers have already commented, an operating system may provide a scripting language as part of its shell. Whether this can be said to make the system itself turing complete is a question of semantics: is the shell viewed as being the operating system. Many would answer "no" - a shell is just user interface, the operating system itself is lower level than that.

In most cases, an operating system is implemented as an abstraction layer on top of hardware. The hardware provides processing, and both user software and the OS are implemented using it. In this case, it's quite clear that the operating system itself is not turing complete - the underlying hardware provides that property.

But there a handful of cases that are different, primarily in academic research systems:

  • In some systems the hardware and operating system are inextricably linked in such a fashion that from an end-user perspective it does not really make sense to distinguish one from the other. An example would be CAP or the Flex machine.

  • In some systems the operating system provides a programming language that all user applications must be written in, or a virtual machine that they must use. Examples include the LISP Machine OS aka Genera and Microsoft's Singularity.

In either of these cases, the answer is probably yes.

1

Operating Systems Are Languages. And Operating Systems Are Machines. So, yes, it does in fact make sense to talk about all the same things that we talk about for Languages and Machines: Computational Power, Expressivity, Orthogonality, Compositionality, Modularity, etc.

The fact that Operating Systems Are Languages seems to be so obvious that there isn't even any discussion about it that one could link to. The dual (Languages Are Operating Systems) seems to be discussed more vividly, and there is a quote on that page saying:

The converse, that operating systems are languages is widely known. Where does an OS designer get inspiration from if not from various languages? This is especially true in the case of functional languages. (Damn those bastards, always twenty years ahead of the rest of us.)

(Emphasis mine.)

1

A Turing machine is one of a particular set of mathematical constructs that take a string as input and either return "true", return "false", or never return.

To say a Turing machine U is a universal Turing machine is to say there is a way to take any Turing machine M and any input string I and represent (M, I) as exactly one string S such that if M returns a result for I, then U returns the same result for S.

To say a programming language is Turing complete is to say the interpreter is a universal Turing machine. (The combination of a compiler and the computer on which the compiled code runs could be called an "interpreter".) The program is the input string to the interpreter, and the output value is whatever we choose to observe about the interpreter's output when the program is run -- a certain character printed to the console could mean "true", a zero status code could mean "true", etc.

The difficulty of saying whether an OS is Turing complete lies in the difficulty of defining what its input and output are. It is trivially Turing complete if you define its input as the combination of its file system (where an executable file can be stored) and its shell (where a command can be entered to run an executable file). If you can use the shell directly to write to a file (e.g. echo "this is my program" > program.txt), run a compiler on that file, and then run the compiler's output, then the shell itself is trivially a Turing machine. In some OSes, the shell is nontrivially a universal Turing machine, even without touching the file system, thanks to a shell scripting language.

For any given general purpose operating system, there are probably many more creative ways to define its "input" and "output" such that it is a universal Turing machine. This could actually be a bad thing, because that would mean there is a creative way to cause the OS to go into an infinite loop and become nonresponsive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.