7

How did UNIX multitasking work without virtual memory? Wouldn't applications still need their own memory space? Or did applications have to know that now all visible memory spaced is theirs?

(Note to avoid confusion: By "virtual memory" I mean virtualised memory, NOT the swap file.)

9
  • "how did"? or perhaps "how does", or "how can"? Commented Aug 10, 2011 at 19:23
  • Are there current Unix systems that don't use virtual memory? Does the C runtime even support that? Commented Aug 10, 2011 at 20:04
  • 1
    @sawdust That link actually explains how uClinux runs several processes without VM! Excellent. Commented Aug 11, 2011 at 8:44
  • 1
    Why the down vote? And how is it "difficult to tell what is being asked here"? There are two answers and I accepted one. People understood the question and I got the answer I needed. Commented Aug 12, 2011 at 18:35
  • 1
    There is also this: 'In segmented systems such as Multics (1964), code is inherently position-independent, since addresses in a program are relative to the current segment rather than absolute.'
    – Utku
    Commented Jul 25, 2016 at 21:09

2 Answers 2

2

Multitasking and multiprocessing can be accomplished on computers that do not have a memory management unit (MMU) to provide virtual memory. There are many operating systems that support multitasking and/or multiprocessing for processors that do not have an MMU. I don't know when Unix utilized virtual memory.

There are other hardware requirements besides virtual memory that Unix needs to implement its multiprocessing features. Key is the protected or supervisor modes of the CPU, i.e. kernel mode versus user mode.

Are there current Unix systems that don't use virtual memory?

I assume that all modern versions of Unix utilize a MMU.

uClinux is a version of Linux that does not require a MMU and does not use virtual memory. But don't expect the same level of security between processes as with real Linux. It is an OS for embedded devices to run trusted application programs.

Does the C runtime even support that?

The C programming language is not tied to Unix or Linux. Nor does it require virtual memory. C can be used to program 8-bit microcontrollers. A runtime library is specific to a version of an operating system and a compiler. There are versions of the C runtime library for uClinix for processors that do not have a MMU.

2
  • To be clear, having the MMU in hardware is a relatively recent innovation (on the unix time-scale). There is nothing stopping you from having the OS do the address translation (albeit it will be much slower than a hardware solution). Although you are correct that this would still require the cpu to support execution modes.
    – crasic
    Commented Aug 11, 2011 at 2:56
  • When I said "the C runtime" I meant the one(s) used by Unix (and clones). Commented Aug 11, 2011 at 8:42
5

Older versions of Unix multitasked by swapping. When a task reached a blocking point (waiting for a read, eg) it would be swapped out to disk and another task swapped in.

Basically one task at a time could be in memory, and all were mapped to the same set of memory locations.

"Fork" (start new sub-task) was accomplished by simply swapping out the current task, then assigning a new task ID to the task image still in memory and letting it continue running (as the "forked" subtask).

This approach (the original Bell Unix) was simple and worked pretty well on primitive hardware, but Berkley Unix took advantage of memory-mapping hardware in newer processors to enable multiple tasks to be in memory simultaneously, slowly morphing into a full virtual memory scheme.

(I don't know what scheme Linux uses.)

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