Mapping memory regio into the address space of every process

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
hhh83
Posts: 3
Joined: Wed Oct 03, 2012 10:48 am

Mapping memory regio into the address space of every process

Post by hhh83 »

Dear all,

I am new in this forum, I am looking for answers to my issues.

Actually, I am working in thesis on implementation shared memory programming model under real-time constraints.
My platform consists from multiple cores connects through network on-chip and access to memory off-chip. The memory model divides to private local memory for each core and shared region for all. Each core has own OS and access to memory by using lookup table (LUT), also each core has L1 and L2 caches and didn't has cache coherency between cores. This is description briefly for my platform, and I aim to porting programming model for this system, has real time shared features.

However, There is big issue in this system. It is memory addressing, when core allocated object in shared memory space, should make sort translation to address and send the offset to consumer core. The consumer core also do the same procedure to get the correct address space, since the virtual address is not valid for other cores. So, the access on it can not be accomplished with simply passing the proper pointer.

Therefore, I am looking to ideas or solution to manage this issue.
My questions:
1. I have idea, but I didn't have enough to prepare. If we could mapping the shared memory region as the same virtual address for every processor, we could implement the pointer access approach to shared memory. So, how could implementing this idea? Namely shared virtual mapping and force other cores to remapping this region based on the information memory mapping of one core.

2. Is possible to mapping the stack of processor in shared memory?

I am looking to hearing you.

Thanks in Advance
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Mapping memory regio into the address space of every pro

Post by Combuster »

Sounds like an homework question ripped from it's original context. I can't reproduce enough of the actual problem to give hints without making the answer obvious, if there even is one.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
hhh83
Posts: 3
Joined: Wed Oct 03, 2012 10:48 am

Re: Mapping memory regio into the address space of every pro

Post by hhh83 »

This is not homework, just, I tried to explain the problem. I will appreciate any help.
Thanks
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Mapping memory regio into the address space of every pro

Post by gerryg400 »

However, There is big issue in this system. It is memory addressing, when core allocated object in shared memory space, should make sort translation to address and send the offset to consumer core. The consumer core also do the same procedure to get the correct address space, since the virtual address is not valid for other cores. So, the access on it can not be accomplished with simply passing the proper pointer.
The normal method is to create a kernel-managed 'named' object and return whatever pointer or handle is appropriate to the processes. Copying/sharing etc. can be done using the global 'name'. The kernel takes care of the details.
1. I have idea, but I didn't have enough to prepare. If we could mapping the shared memory region as the same virtual address for every processor, we could implement the pointer access approach to shared memory. So, how could implementing this idea? Namely shared virtual mapping and force other cores to remapping this region based on the information memory mapping of one core.
That's generally a poor and rather restrictive solution. I would advise against it.
2. Is possible to mapping the stack of processor in shared memory?
Yes, but again I would advise against it. Stacks are not supposed to be managed by processes. They are under control of the compiler/language environment.
If a trainstation is where trains stop, what is a workstation ?
hhh83
Posts: 3
Joined: Wed Oct 03, 2012 10:48 am

Re: Mapping memory regio into the address space of every pro

Post by hhh83 »

Thanks for response.

The normal method is to create a kernel-managed 'named' object and return whatever pointer or handle is appropriate to the processes. Copying/sharing etc. can be done using the global 'name'. The kernel takes care of the details.

This is looking like a nice idea, How could I do it ? Could you give me more details to implement it?

Yes, but again I would advise against it. Stacks are not supposed to be managed by processes. They are under control of the compiler/language environment

I know this option under control of the compiler. Namely, one core as the master mapping his stack in shared array. Consequently, all local and global variables of master are shareable and by implementing the idea of fixed virtual address, every core could access this variables.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Mapping memory regio into the address space of every pro

Post by gerryg400 »

I know this option under control of the compiler. Namely, one core as the master mapping his stack in shared array. Consequently, all local and global variables of master are shareable and by implementing the idea of fixed virtual address, every core could access this variables.
No, you can't do that. Global variables are not on the stack. Furtheremore, while compilers generally use the stack for local variables, many local variables are register based or are optimised away. There is no way to portably and consistently predict where a local variable (on another core) might be at a particular time.
If a trainstation is where trains stop, what is a workstation ?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Mapping memory regio into the address space of every pro

Post by bluemoon »

hhh83 wrote:Could you give me more details to implement it?
It can be done by abstracting the global object and provide functions to work on that:

Code: Select all

typedef struct {
   uint32_t handle;
   uint32_t attr;
   uintptr_t phy_addr; // physical address
   size_t size;
   uint32_t ref; // reference count (or a more complex user/process list for bookkeeping)
   ...
} GLOBAL_OBJECT;

uint32_t global_allocate(size_t size) {
   GLOBAL_OBJECT* obj = ....; // allocate a new slot
   obj->phy_addr = allocate_physical_memory(size);
   ...
   return obj->handle;
}

void* global_retain(uint32_t handle, void* addr, size_t size) {
   GLOBAL_OBJECT* obj = lock_object(handle);
   mmap(addr, obj->phy_addr, size, flags);
   ...
   unlock_object(handle);
}
The owner process allocate the global object, and all shared process retain that object and map it into local address space.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Mapping memory regio into the address space of every pro

Post by dozniak »

Make SAS OS, lose mapping problems at once.
Learn to read.
Post Reply