在一般的计算机概念中,覆盖(Overlay)表示将一块指令数据替换为另一块的行为。覆盖是一种编程技术,允许程序在主存空间不足时仍能运行。在嵌入式系统中,由于缺乏虚拟内存机制,覆盖技术也被广泛应用以克服物理内存的限制。

用法

构建一个覆盖程序需要程序员将程序手动分割为独立的目标代码。覆盖管理器由操作系统或程序本身提供,用于从外存读取所需数据并交换到主存中。通常情况下,链接器都会提供对覆盖的支持。

例子

以下是一个示例,展示了用于使OS/360链接编辑器链接覆盖程序的控制语句。

 INCLUDE SYSLIB(MOD1)
 INCLUDE SYSLIB(MOD2)
 OVERLAY A
   INCLUDE SYSLIB(MOD3)
     OVERLAY AA
       INCLUDE SYSLIB(MOD4)
       INCLUDE SYSLIB(MOD5)
     OVERLAY AB
        INCLUDE SYSLIB(MOD6)
 OVERLAY B
    INCLUDE SYSLIB(MOD7)
                       +--------------+
                       | Root Segment |
                       | MOD1, MOD2   |
                       +--------------+ 
                               |
                    +----------+----------+
                    |                     |
             +-------------+       +-------------+
             |  Overlay A  |       |  Overlay B  |
             |  MOD3       |       |  MOD7       |
             +-------------+       +-------------+
                    |
           +--------+--------+
           |                 |
    +-------------+   +-------------+
    | Overlay AA  |   | Overlay AB  |
    | MOD4, MOD5  |   | MOD6        |
    +-------------+   +-------------+

Wikiwand in your browser!

Seamless Wikipedia browsing. On steroids.

Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.

Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.