Domanda

In 8086 more than one logical addresses (segment:offset) can have the same physical address (001F:000F and 000F:010F are the same addresses, like 001F:000F = 01F0+000F = 01FF in the same way as 000F:010F = 01FF).

In physical memory, any programs see the logical memory address. So more than one program can have data (byte) at the same physical address (though the logical addresses are different) position. Why don't they collide with each other? Why don't we lose data???

È stato utile?

Soluzione

The 8086 can address 1MB of memory, requiring 20 bits to specify the address of any particular byte. Since the 8086's registers only hold 16 bits, the segment model was developed which gives each of those 1M addresses many different names. Just as the number 4 can be named as 0+4, 1+3, 2+2, etc., the address 12345 can be expressed as 1234:0005, 1233:0015, 1230:0045, and so on.

In other words, each physical address has 64k different logical addresses. This means that if one program is accessing 1234:0005 and another program is accessing 1233:0015, those two programs will be accessing the exact same memory address.

So how do we prevent different programs from "colliding" with each other? First of all, recognize that modern computers do not use 8086es anymore. If you have multiple programs running on an actual 8086, they are probably cooperating with each other, sharing the address space knowingly.

Modern CPUs do not run in the 1MB segmented mode (called "real mode") anymore. If you run an OS like Windows or Linux, the CPU uses something called virtual memory, where each program has its own mapping of logical addresses to physical addresses. In this mode, the programs typically use logical addresses that are 32 or 64 bits, and the programs have no knowledge of how a given logical address maps to a physical address. Any number of programs can use the same set of logical addresses and there will be no overlap of physical addresses unless the programs specifically arrange to do so.

Altri suggerimenti

In DOS programs can't run simultaneously, so there's no problem of collision.

In multitasking OSes each process runs on its own address space specified by the OS. Their logical address maps to different physical addresses (except for shared memory locations) so there won't be any collision either.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top