Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How the Windows distributes a memory (*Ptr) ?

Author
Message
Leonid
User Banned
Posted: 13th Aug 2013 21:13
How the Windows distributes a memory (*Ptr) ? I want to make two different programs written on DBP (The first activates other), but I do not know, how these programs will does contact together: by system registry - No!, by File usage - No!, by Clipboard - NO!!! Only one way: *Pointer variable. Where the Windows hides its memory allocation table? And Clipboard: where it is in memory?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Aug 2013 21:46 Edited at: 13th Aug 2013 21:47
Use network commands and connect them to localhost (127.0.0.1)

Matrix1 Utils does have shared memory commands, but I strongly discourage the use of them for this situation.

TheComet

Leonid
User Banned
Posted: 13th Aug 2013 22:23
IP usage, NOT FOR ME too! Tooo slowly!

Bamber, please, help! Answer for your words, (and bugs too). You have told about direct memory usage, but where and how I can use it REALLY - no one word! Gates is not allowing or something else?
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 13th Aug 2013 22:25
Are you talking about this?

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Aug 2013 23:03 Edited at: 13th Aug 2013 23:04
Quote: "Tooo slowly!"


CRAP

Can someone please help me out here, the ignorance is overwhelming.

Network commands will be really fast because you're only connecting the programs locally on your computer.

Leonid
User Banned
Posted: 13th Aug 2013 23:13 Edited at: 13th Aug 2013 23:19
MrValentine: Are you talking about this? - No. Book included with russian version of DBP 1.055. Mr. Bamber hides very many commands in Help (in the book and in the editor). Code in the book:



The Asterix before variable allows to use a memory immediately like POKE and PEEK.

TheComet May be 1.7 GHz is TOO SLOWLY for DBP, but my computer waits 1 - 5 minutes after starting the second and the third DBP application, trying to connect 127.0.0.1 ... This manhole is not for me.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Aug 2013 23:16 Edited at: 13th Aug 2013 23:19
That's some dangerous code. It should cause a memory access violation because you're editing possibly already allocated memory space.

You have to allocate it:



And then you have to make sure to clean up again or you get memory leaks:



Leonid
User Banned
Posted: 13th Aug 2013 23:25
Good. But how I can use this memory with my second program, activated after first?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Aug 2013 23:28
Just use network commands it's really fast and it's safe.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 14th Aug 2013 00:01
Yes. Programs should never share memory. It could have many, many undesired effects like triggering your anti virus.

Please, use the net commands. If it's quick enough for online FPS games, it's quick enough for you.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Aug 2013 00:07
STYX is very relevant here if you bothered to read the link I gave you... It has some options you will like... Including SHARED MEMORY...

I rest my case here as I sense certain undertones which are familiar here...

Good Luck to you...

Leonid
User Banned
Posted: 14th Aug 2013 00:23 Edited at: 14th Aug 2013 00:29
I have Googled \"windows memory allocation table\" - OBALDEL !!! I can not use physical adresses because x86s upper than 386-th processors just will never give me to do it. Only kernel mode (OS program) has rights to control the whole memory of each under-OS program. Any other program lives in its own logical memory and will never read or write neighbour\'s code... And how to live with this misfortune ?

STYX uses the .NET , ActiveX and something else. I have confused with DirectX 9.1 2005 already to show my program for simple users.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Aug 2013 00:40
Leonid
User Banned
Posted: 14th Aug 2013 01:33
MrValentine, thank you very much.
Leonid
User Banned
Posted: 14th Aug 2013 02:08
Oops! I have been recalling one thing, important for me. It was 2004 or 2005. I was buing not licensed (to try) CorelDRAW 11 and MS Office 97. When I had been starting both CorelDRAW and MS Word, a crush appeared. I was reading somewhere, theese programs used something the same (I do not know what). MrValentine, what will be if I will buy your that thing and will start Word, Excel and Corel Grahic Suite?
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 14th Aug 2013 03:31
Communication between programs is normally done through sending messages. This of course have both it's pros and cons, but on the whole the advantages make up for the disadvantages.
You can use TCP to send data to the local computer at speeds that should be high enough for any application. You may also use windows messages if you prefer that, but on the whole it is a bit more messy to accomplish. It also would not scale well if you decided to put one of your processes on another computer one day; using TCP this could be done simply by changing the connection address (of course with a potentially great slowdown from having to send data over the net).

The only reason I would see for not wanting to use message sending for inter-process communication is if very large amounts of data need to be shared between both processes (for example real-time image processing in one process that is immediately made available to display for another process). Even this scenario should work with message sending on your local machine; there are applications like Team Viewer which samples the screen at some 25, 30 frames per seconds, compresses the image and sends it to another client - over the net. Of course this kind of program likely makes use of both efficient compression and perhaps prediction, but the point is that there should be no problem doing it on your local machine which is capable of much higher throughput.

So the question is, what is it that you're trying to do?
One of the core concepts of parallell programming is to break the solution up in such a way that it can be individually processed by individual processes that know nothing of - and can be completely separated from each other.

If what you want to accomplish is merely to utilize more of your processor cores you should probably look into using a different language instead. DarkGDK works well with C++ if you fancy that; using that you can have separate threads that all have access to shared memory within the program (note that you should not multithread calls to the DBPro / DarkGDK runtime however as it's designed to be sequential).


"Why do programmers get Halloween and Christmas mixed up?"
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Aug 2013 08:35
Quote: "Oops! I have been recalling one thing, important for me. It was 2004 or 2005. I was buing not licensed (to try) CorelDRAW 11 and MS Office 97. When I had been starting both CorelDRAW and MS Word, a crush appeared. I was reading somewhere, theese programs used something the same (I do not know what). MrValentine, what will be if I will buy your that thing and will start Word, Excel and Corel Grahic Suite? "


Can't help you there as I do not have those applications... I can however test for Office 2007 / 2010 / 2013 and no chance to test Coral, I believe in not wasting my money...

Quote: "
FILE MAPPING

The file mapping commands offer a way of sharing memory between applications. This opens up the possibility of communication between multiple applications on the same computer as data can be shared in memory.

When creating a file map a global, shared amount of memory will be set up in the Operating System. This can then be read and written to by a Dark Basic Professional application. Then either other Dark Basic Professional applications can access the shared memory or applications written in other programming languages that natively support file mapping.

"


Quote: "
CREATE FILE MAP
Creates a new file map with the specified name and given size.

SYNTAX
CREATE FILE MAP Map ID, Name$, Size
"


Quote: "
OPEN FILE MAP
Opens the specified file map. If the file map specified does not exist in memory then this command will fail.

SYNTAX
OPEN FILE MAP Map ID, Name$
"


Quote: "
SET FILE MAP STRING$
Sets a string at the specified offset.

SYNTAX
SET FILE MAP STRING$ Map ID, String$
"


Quote: "
GET FILE MAP STRING$
Returns a string from the specified offset.

SYNTAX
return string = Get FILE MAP STRING$( Map ID, Offset )
"


You can also SET/GET the following DWORD FLOAT and as above STRING

Quote: "
CLOSE FILE MAP
Closes an open file map.

SYNTAX
CLOSE FILE MAP Map ID
"


Quote: "
DESTROY FILE MAP
Destroys a file map.

SYNTAX
DESTROY FILE MAP Map ID
"


Hope this helps, and let me know if you would like more information on the other functions within the plugin...

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Aug 2013 08:40 Edited at: 14th Aug 2013 08:40
Just out of interest, can both applications open the file map at the exact same time? I'm going to assume not, because if both applications try to write to the same memory location at the same time, it's going to cause problems, which means that file maps are going to be no faster than network commands, since they'll have to wait for each other to open/close the file maps at different times.

TheComet

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Aug 2013 08:59
They are shared, and thus can write to the same file at the same time or there about, the file is open in memory therefore not requiring disk I/O, but then again I am not yet an expert on this matter...

Leonid
User Banned
Posted: 14th Aug 2013 18:21 Edited at: 14th Aug 2013 18:25
My Pentium-4 shows at start-up a Memory Test: 500000KB + 8000KB Shared Memory. Is that last memory used for file mapping? What uses the File Map commands ?: disk or memory ? (I am asking for who made that for DBP).
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Aug 2013 18:41
Quote: "the file is open in memory therefore not requiring disk I/O,"


Leonid - Are you Russian?

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Aug 2013 20:14 Edited at: 14th Aug 2013 20:30
db program:




C program:



The C prgram could be a windows WIN32 API program. You could pass pointers to windows and dialog boxes, music commands, direct x. The idea is the same. Just pass the pointer through a DLL to the windows code you want to run.

Information from the DLL can be returned through the pointer to DB as well.

EDIT:
I misunderstood your post - you want DB to talk to DB not to a windows program. You could do a similar thing with a DLL, the problem would be making sure only one DB program is accessing the memory cache at a time, otherwise you'll have each program writing over the same data and corrupting things and causing all kinds of problems. You could actually use pipes and use file commands in C++ or C to manage the data flow. The memory would be treated like a virtual drive. It's probably best to just use net commands so all the data flow is controlled for you and you don't have to build custom reading and writing routines.

Enjoy your day.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Aug 2013 22:10
Quote: "My Pentium-4 shows at start-up a Memory Test: 500000KB + 8000KB Shared Memory. Is that last memory used for file mapping? What uses the File Map commands ?: disk or memory ? (I am asking for who made that for DBP)."


DBP has no control over where it is located in memory. It's different on every computer.

Windows decides what memory which program can use.

TheComet

Leonid
User Banned
Posted: 14th Aug 2013 22:46
I am Russian. And many english words I may do not know.

How to use a Clipboard to exchange pictures between programs?

I think, C is not for me. If my project will have success, I will learn it and will buy offered addition to DBP with File Mapping and Printing tools (Dark Ink).
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 15th Aug 2013 01:10
Leonid - I think we still require more information from you about what you wish to achieve, if you feel it is something new to the market, you can send someone a private email should they offer you this option...

Я думаю, что мы по-прежнему требуют больше информации от вас о том, что вы хотите достичь, если вы считаете что-то новое на рынке, вы можете отправить кого-то частной электронной почты они должны предложить вам этот вариант...

^ This is probably really bad but I hope it helps...

You can try to use Russian along with English to explain your meaning as well...
Вы можете попробовать использовать русский язык наряду с английским языком объяснить смысл также...



Leonid
User Banned
Posted: 15th Aug 2013 15:21
Ñåòåâîå ïëàíîâîå óïðàâëåíèå (Net Planned Management, Pert). The main window shows a Net. The clicking on net node opens a new window with detailed information about local process. Two or more windows must work together and send information to the main window or back.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Aug 2013 16:16 Edited at: 15th Aug 2013 16:17
@ Leonid - Does this code look like it would be useful (pseudo code)?

Main Application


second application


Uses this: http://forum.thegamecreators.com/?m=forum_view&t=99188&b=5

TheComet

Leonid
User Banned
Posted: 21st Aug 2013 03:24 Edited at: 21st Aug 2013 03:56
TheComet, I will be trying it later. Thank you.

But what is wrong with my Direct Memory Access?

WRITTING application



READING application

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 21st Aug 2013 04:00 Edited at: 21st Aug 2013 04:06
Quote: "
But what is wrong with my Direct Memory Access?"


Because each thread is assigned its own area of memory.

Mutexing (mutual-exclusion) is a solution for sharing memory that allocates it and requires an unlocking mechanism to grant access to only thread at a time.

Quote: "In concurrent programming, a critical section is a piece of code that accesses a shared resource (data structure or device) that must not be concurrently accessed by more than one thread of execution. (WIKI:Critical Section)"


Quote: "In computer science, mutual exclusion refers to the requirement of ensuring that no two processes or threads (henceforth referred to only as processes) are in their critical section at the same time. (WIKI:Mutual Exclusion)"


Mutexing is easiest with Matrix1 utilities.

But..

There are a number of ways to communicate between two applications; the process is like purchasing a truck to deliver equipment from one location to another; only worth going through the hassle if the equipment can't be used where you are and the journey is to be made frequently. Another reason is to make use of more than one thread for an intensive operation; since DBP features no straight forward multi-threading solution.

It is not just a question of connecting; its going through the hassle of building message sending and receive commands every time you need to facilitate a shared feature.

Every single time a function requires access to a variable elsewhere in the other program; a new send and retrieval routine has to be made.

The real question is, do you really need more than one program to meet the requirement?

What are two programs going to do that one cannot be done with one?

Leonid
User Banned
Posted: 21st Aug 2013 05:44 Edited at: 21st Aug 2013 05:46
Chris Tate, thank you; I was finding in Matrix1 Utilities a Bank commands. See Download if want to test my sharing of the memory.

Now I am seeking for a Clipboard commands to get pictures from it.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st Aug 2013 11:48
Image from clipboard? Check this thread:

http://forum.thegamecreators.com/?m=forum_view&t=198292&b=1

Someone posted a nice example somewhere there.

TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 21st Aug 2013 16:11 Edited at: 21st Aug 2013 16:13
Quite interesting the method you selected; the method I was talking about was the System Object; this gives your memory bank a string name so there is no need to use the registry; mutexes also prevents two processes accessing it at the exact same time.

But see how it goes; perhaps Ian put a lock check in the shared bank functions.

If you do happen to get any access errors you will need to make use of the following commands

MAKE SYSOBJ MUTEX bank, system name$
IS SYSOBJ LOCKED
LOCK SYSOBJ
TRY LOCK SYSOBJ
UNLOCK SYSOBJ

Leonid
User Banned
Posted: 21st Aug 2013 17:01
Quote: "mutexes also prevents two processes accessing it at the exact same time."

What it prevents from? : accesing to registry or to the same bank?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st Aug 2013 17:21
The same bank

Leonid
User Banned
Posted: 23rd Aug 2013 18:05 Edited at: 23rd Aug 2013 18:07
TheComet, Chris Tate, GIGANTIC THANK YOU !

Login to post a reply

Server time is: 2026-07-07 15:09:40
Your offset time is: 2026-07-07 15:09:40