-1

I have to use Multi core shared Memory (MSMC) in one multi core DSP. I know the starting address of that memory and its size. Now I want to allocate some arrays ( I have declared them as pointers so that the memory can be freed later ) starting with particular address and utilizing the memory as per their size. How Can I do this in C ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    This is difficult to answer without more information about the environment. What OS? What architecture? Paging, Segmentation? Are you writing with Linux API, POSIX, or standard C? – James T. Smith Apr 09 '15 at 05:13
  • You have declared arrays as pointers? So you have declared pointers?! Thats different from declaring arrays. Also I don't know a way allocating arrays is technically even possible. – dhein Apr 09 '15 at 05:51

1 Answers1

0

If it is static memory without needing to allocate or free, just point to it and use it.

void * myArray = STATIC_MEMORY_ADDRESS;

If you do need allocate and free though.. you really need a malloc routine that knows that that is the pool. Here is a stack overflow question for implementing malloc. I have seen a few malloc implmentations and most of them will let you tell it what pool of memory to use.

If you are going to be using multiple threads/cores though.. make sure your malloc routine has mutex's.

Community
  • 1
  • 1
Hashtag
  • 75
  • 4