• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Misery

Access to one program from another

15 posts in this topic

Hi,

I wonder if it is possible that two or more applications can have access to the same part of memory.
Lets say I have one program that allocates and fills part of memory with some objects.
And I would like another program to be able to read, modify and write this part of memory.

Is there any name for such technology, some libs, tutorials?

Regards,
Misery
0

Share this post


Link to post
Share on other sites
[quote name='Misery' timestamp='1313850744' post='4851603']
Is there any name for such technology,
[/quote]
I think you are searching "Shared memory". The functionality is typically provided by the operation system api.
0

Share this post


Link to post
Share on other sites
Now do you really want to directly share the memory or do you just want access to the date there? There is a HUGE difference in the two.
0

Share this post


Link to post
Share on other sites
[quote name='Misery' timestamp='1313850744' post='4851603']
I wonder if it is possible that two or more applications can have access to the same part of memory.
Lets say I have one program that allocates and fills part of memory with some objects.
And I would like another program to be able to read, modify and write this part of memory.[/quote]

Memory is not localized. Entire memory is accessible at any time.

The mere concept of "application" or more accurately, process, is something that is arbitrarily defined by each operating system or runtime system. No such limitation exists when it comes to memory itself.

So a question needs more detail - which OS, which language and what kind of sharing?
0

Share this post


Link to post
Share on other sites
[quote name='Misery' timestamp='1313850744' post='4851603']
Hi,

I wonder if it is possible that two or more applications can have access to the same part of memory.
Lets say I have one program that allocates and fills part of memory with some objects.
And I would like another program to be able to read, modify and write this part of memory.

Is there any name for such technology, some libs, tutorials?

Regards,
Misery
[/quote]

As a suggestion, look at the following: [url="http://www.boost.org/doc/libs/1_47_0/doc/html/interprocess.html"]http://www.boost.org/doc/libs/1_47_0/doc/html/interprocess.html[/url] I'm not a huge fan of boost but for this particular item and a couple others I have no interest in writing such things myself and this is a very reasonable solution so long as you don't have to debug it yourself. I've used this for a shared resource system in cooperative server processes quite successfully and the performance was exceptional and I didn't run into any notable bugs. I think the largest problem I had was proper cleanup given the different Os scoping issues with releasing of the shared memory, all easily dealt with but a pain if you don't think about it up front.
0

Share this post


Link to post
Share on other sites
[quote name='Antheus' timestamp='1313858675' post='4851648']
[quote name='Misery' timestamp='1313850744' post='4851603']
I wonder if it is possible that two or more applications can have access to the same part of memory.
Lets say I have one program that allocates and fills part of memory with some objects.
And I would like another program to be able to read, modify and write this part of memory.[/quote]

Memory is not localized. Entire memory is accessible at any time.

The mere concept of "application" or more accurately, process, is something that is arbitrarily defined by each operating system or runtime system. No such limitation exists when it comes to memory itself.

So a question needs more detail - which OS, which language and what kind of sharing?
[/quote]

This is not entirely true, your application is most likely in its own virtual address space (that is why two applications with the same entry point address can run simultaneously). So the OS is able to address physical memory in a linear way however your application is bound to his virtual address space and an other applications virtual address space would have to mapped to your virtual address space resulting in a different address for the same data (say app1 has code at 0xDEADBEEF and wants to access address 0xDEADBEEF of app2 it will have to be mapped at an other address then the original address). This is not really a problem unless the data you are trying to access contains pointers to addresses within this mapped memory (or even worse inside app2's private memory, then there is no way to know what will happen the address could be perfectly legal and pointing to valid data in app1 resulting in unpredictable results).
0

Share this post


Link to post
Share on other sites
[quote name='Chargh' timestamp='1313859959' post='4851663']

This is not entirely true, your application is most likely in its own virtual address space[/quote]

Which is a concept defined by operating and applies to concept of process.

The the request for details on OS, language, platform, the more the better.

There simply is no generic answer on how to share memory.
1

Share this post


Link to post
Share on other sites
In more detail:

lets say first application makes a vector of integers:
[code]
int A=new int[100];
for (int i=0;i<100;i++) A[i]=ARandomNumber();
[/code]


And the second application is supposed to count a sum of the elements of A and fill it with new numbers:
[code]
int s=0;
for (int i=0;i<100;i++)
{
s+=A[i];
A[i]=AnotherRandomNumber();
}
[/code]

This would be supposed to work on Windows 7, but solution for Debian would be cool as well.
The first application could probably put out to an output stream an address to A or something...
:D
0

Share this post


Link to post
Share on other sites
Addresses are meaningless between different processes.

A unix solution to this problem would be for the first application to write the array to stdout, and the second application to sum the integers arriving on stdin. You would combine them by using the shell to pipe the output from the first program to the second.
1

Share this post


Link to post
Share on other sites
You can use shared memory (which is an OS-dependant solution), but the design you're talking about makes no sense to me. Maybe step back a bit and give us some context. What is the ultimate goal of this system? What is the input? What is the output? What design constraints are there (and why do they exist)?


[quote name='rip-off' timestamp='1313873638' post='4851723']
Addresses are meaningless between different processes.

A unix solution to this problem would be for the first application to write the array to stdout, and the second application to sum the integers arriving on stdin. You would combine them by using the shell to pipe the output from the first program to the second.
[/quote]
He requires 2-way communication, though. I'm not really a command-line guru, so I don't know how you'd do that with pipes.
1

Share this post


Link to post
Share on other sites
Why don't you just pass the elements you want to add to the app that is holding the data, and then let the app that is responsible for that data pass the number of elements back to the calling app?

The reality is that sharing data between apps is a REALLY REALLY REALLY bad idea. It can lead to more problems then you can could count. You really want one and only one place that can change data.
1

Share this post


Link to post
Share on other sites
[quote name='Slavik81' timestamp='1313878833' post='4851742']
[quote name='rip-off' timestamp='1313873638' post='4851723']
Addresses are meaningless between different processes.

A unix solution to this problem would be for the first application to write the array to stdout, and the second application to sum the integers arriving on stdin. You would combine them by using the shell to pipe the output from the first program to the second.
[/quote]
He requires 2-way communication, though. I'm not really a command-line guru, so I don't know how you'd do that with pipes.
[/quote]
I was optimising out the redundant write, since the OP never specified any additional reads afterwards... :wink: More seriously, I just failed at reading that post closely enough.

Until we know the high level goal the OP has, it is hard to give concrete advice. I still think that any solution which avoids shared memory should be considered, as the potential for bugs is highest with such an approach.
0

Share this post


Link to post
Share on other sites
[quote name='rip-off' timestamp='1313940031' post='4851919']
[quote name='Slavik81' timestamp='1313878833' post='4851742']
[quote name='rip-off' timestamp='1313873638' post='4851723']
Addresses are meaningless between different processes.

A unix solution to this problem would be for the first application to write the array to stdout, and the second application to sum the integers arriving on stdin. You would combine them by using the shell to pipe the output from the first program to the second.
[/quote]
He requires 2-way communication, though. I'm not really a command-line guru, so I don't know how you'd do that with pipes.
[/quote]
I was optimising out the redundant write, since the OP never specified any additional reads afterwards... :wink: More seriously, I just failed at reading that post closely enough.

Until we know the high level goal the OP has, it is hard to give concrete advice. I still think that any solution which avoids shared memory should be considered, as the potential for bugs is highest with such an approach.
[/quote]

Sockets are a workable solution, and then the two processes don't even have to be on the same machine. (allthough it works best if the communcation can be broken down to messages that can be passed between the processes, for some applications shared memory might very well be the most appropriate solution)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0