In Linux is it possible to start a process (e.g. with execve) and make it use a particular memory region as stack space?
Background:
I have a C++ program and a fast allocator that gives me “fast memory”. I can use it for objects that make use of the heap and create them in fast memory. Fine. But I also have a lot of variable living on the stack. How can I make them use the fast memory as well?
Idea: Implement a “program wrapper” that allocates fast memory and then starts the actual main program, passing a pointer to the fast memory and the program uses it as stack. Is that possible?
[Update]
The pthread setup seems to work.
With pthreads, you could use a secondary thread for your program logic, and set its stack address using
pthread_attr_setstack():What I don’t follow is how you’re expecting to get any performance improvements out of doing something like this (I assume the purpose of your “fast” memory is better performance).