views:

41

answers:

2

hi,

This is re submission , because am not getting any response from superuser.com Also sorry for the mis understanding.

First of all I need to know , difference between physical addressing and virtual addressing concept in an embedded systems?

then why virtual addressing concept is implemented in an embedded systems ?

then what is the advantages of the same over a system with physical addressing concept in an embedded systems?

then How the mapping between virtual addressing to physical addressing is done in an embedded systems?

Explain the above concept with some simple examples in some simple architecture.

+1  A: 

Physical addressing means that your program actually knows the real layout of RAM. When you access a variable at address 0x8746b3, that's where it's really stored in the physical RAM chips.

With virtual addressing, all application memory accesses go to a page table, which then maps from the virtual to the physical address. So every application has its own "private" address space, and no program can read or write to another program's memory. This is called segmentation.

Virtual adddressing has many benefits. It protects programs from crashing eachother through poor pointer manipulation, etc. Because each program has its own distinct virtual memory set, no program can read another's data - this is both a safety and a security plus. Virtual memory also enables paging, where a program's physical RAM may be stored on a disk (or, now, slower flash) when not in use, then called back when an application attempts to access the page. Also, since only one program may be resident at a particular physical page, in a physical paging system, either a) all programs must be compiled to load at different memory addresses or b) every program must use Position-Independent Code, or c) some sets of programs cannot run simultaneously.

The physical-virtual mapping may be done in software (with hardware support for memory traps) or in pure hardware. Sometimes even the page tables themselves are on a special set of hardware memory. I don't know off the top of my head which embedded system does what, but every desktop has a hardware TLB (Translation Lookaside Buffer, basically a cache for the virtual-physical mappings) and some now have advanced Memory Mapping Units that help with virtual machines and the like.

The only downsides of virtual memory are added complexity in the hardware implementation and slower performance.

Borealid
"every application has its own "private" address space, and no program can read or write to another program's memory"But the MMU maps each virtual address to corresponding physical address right?If the programs use the virtual address then it implicitly accessing the same physical memory area right?/renjith_g
Renjith G
@Renjith G: in general, a particular physical page only maps to one application's virtual space, so there is no way for the programs to interfere with eachother. If you explicitly allocate shared memory, then two different applications' virtual pages will map to the same page. But, in the general case, the applications' physical page sets are disjoint. The mapping from virtual to physical is **per application** and the TLB is flushed when you make a context switch.
Borealid
But, If the two applications accesse directly the DMA/UART/Any h/w control control registers (suppose it is having virtual addressing enabled)?The the programs got interfered right?Also where can i see the mapping b/w virtual and physical memory addressing? (i mean MMU page table?)
Renjith G
@Renjith G: I/O device special addressing is a whole different matter, and is done by the kernel, which uses physical memory (only userland is virtual-mapped). Applications make use of hardware devices only through the indirection of system calls, which know to translation addresses from V->P and manage contention. If this keeps going, I'm going to be explaining a whole introductory operating systems course; I recommend you get a decent intro-level systems textbook and read up. There's a lot to learn.
Borealid
But what is the case of above comment "an embedded system without OS ?"
Renjith G
@Renjith G: If the embedded system has no OS, it also has very, very, **very** limited functionality. Application-specific hardware and cooperatively-multithreaded systems do not usually make use of virtual memory. Just for perspective here, the 1st-generation iPod has an OS. Refrigerators often have operating systems.
Borealid
+1 for very nice explained and informative answer ... keep up
A: 

The VAX (Virtual Address eXtented by Digital Equipment Corp which became Compaq, which became HP) is a very good example of an virtual embeded hardware system. It was a 32 bit mini computer that had an OS called VMS or Virtual Memory Systems. Dave Cutler was one of the principle architets of the systems and he much later wrote the Kernal for Windows NT. He is a very good read for this and other stuff. The Vax had special hardware for control of the virtual space and control of opcode access for security through hardware... very secure. This system was or is the grandfather of the modfern day PC at the Kernal Level. The first BSOD I saw on WNT 3.51 I was able to read because it came from the crash dump used in VMS to stop the system when unstable. By te way Look at the name VMS and WNT and you will find the next letters in the alhabet from VMS makes the term WNT. This was not an accident. maybe a jab at DEC for letting him go.

MarkC