Position-independent Code - History

History

In early computers, code was position-dependent: each program was built to be loaded into, and run from, a particular address. In order to run multiple jobs using separate programs at the same time, an operator had to carefully schedule the jobs so that no two simultaneous jobs would run programs that required the same load addresses. For example, if both the payroll program and the accounts receivable program were built to run at address 32K, the operator could not run both at the same time. Sometimes, an operator would keep multiple versions of a program around, each built for a different load address, to expand his options.

To make things more flexible, position-independent code was invented. Position-independent code could run from any address at which the operator chose to load it.

The invention of dynamic address translation (the function provided by an MMU) almost made position-independent code obsolete because every process could have its own separate 32-bit (or even more) address space. Because position-independent code is less efficient than position-dependent code, this was a better solution to the problem.

The next problem to be attacked was the memory waste that happens when the same code is loaded multiple times to be used by multiple simultaneous jobs. If two jobs run entirely identical programs, dynamic address translation provides a solution by allowing the system simply to map two different jobs' address 32K to the same bytes of real memory, containing the single copy of the program.

But more often, the programs are different and merely share a lot of common code. For example, the payroll program and the accounts receivable program probably both contain an identical sort subroutine. So designers invented shared modules (a shared library is a form of shared module). While the main payroll and accounts receivable programs get loaded into separate memory, the shared module gets loaded once and simply mapped into the two address spaces.

Position-independent code has been used not only to coordinate the work of user-level applications, but within operating systems as well. The earliest paging systems did not use virtual memory address spaces; instead, the operating system would explicitly load individual modules of itself as needed, overwriting less needed ones (the memory available for the operating system was much smaller than the operating system). A module had to be capable of running in whatever memory was free at the time it was needed, so individual operating system modules were made of position-independent code.

The invention of virtual memory made that method obsolete, because the operating system could have a virtual address space so big that every module of the operating system could have its own permanent virtual address.

Read more about this topic:  Position-independent Code

Famous quotes containing the word history:

    You treat world history as a mathematician does mathematics, in which nothing but laws and formulas exist, no reality, no good and evil, no time, no yesterday, no tomorrow, nothing but an eternal, shallow, mathematical present.
    Hermann Hesse (1877–1962)

    I saw the Arab map.
    It resembled a mare shuffling on,
    dragging its history like saddlebags,
    nearing its tomb and the pitch of hell.
    Adonis [Ali Ahmed Said] (b. 1930)

    All objects, all phases of culture are alive. They have voices. They speak of their history and interrelatedness. And they are all talking at once!
    Camille Paglia (b. 1947)