Author |
Topic: use of the static variables (Read 770 times) |
|
yee
New Member
member is offline


Posts: 4
|
 |
use of the static variables
« Thread started on: Nov 15th, 2014, 12:08am » |
|
Hi, there
I am intrigue by the static variable (A%-Z%) in BBC4W
- if I have 2 compiled bbc programs accesing them (A%-Z%) run separately,
- do they come from the same RAM memory space (as on the BBC micro)
- if not, are there any BBC4W variable that do?
- a simple basic way for 2 programs to "talk" ?
|
|
Logged
|
|
|
|
Matt
Developer
member is offline


Gender: 
Posts: 210
|
 |
Re: use of the static variables
« Reply #1 on: Nov 15th, 2014, 05:34am » |
|
on Nov 15th, 2014, 12:08am, yee wrote: - if I have 2 compiled bbc programs accesing them (A%-Z%) run separately, |
|
The help explains a lot of this. Look under 'Variables' in the 'General Information' section, and 'CHAIN' under 'Keywords'
If the programs are running independently, the variable will be independent. However, if one program is CALLed or RUN from another, the static variables are not cleared and can be accessed.
Quote: - do they come from the same RAM memory space (as on the BBC micro) |
|
One thing I'm not sure about is that, running tests, I found that the location of the static variables and pseudo-variables - e.g. HIMEM - seems to be the same in two independent programs. I'm struggling to work out why they would be the same. I would have expected two independent programs to be working in two different areas of memory.
Quote: - if not, are there any BBC4W variable that do? |
|
Not with two independent programs.
Quote: - a simple basic way for 2 programs to "talk" |
|
One easy way is to store information in a disk file that can be accessed by both programs. (Remember, only one can access it at a time, so error handling is important here.)
I don't know if there is a way to use memory locations directly by two programs, or if Windows will lock the locations to the individual program. I would guess accessing 'unauthorised' memory would cause a protection fault.
Matt
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: use of the static variables
« Reply #2 on: Nov 15th, 2014, 06:33am » |
|
on Nov 15th, 2014, 05:34am, Matt wrote:I would have expected two independent programs to be working in two different areas of memory. |
|
They do, of course, but you need to distinguish between 'physical' memory addresses and 'virtual' memory addresses. Every process sees the same virtual address space, but the physical memory it occupies will be different.
Quote:I don't know if there is a way to use memory locations directly by two programs |
|
Shared memory? Yes indeed - in fact I am currently working on an application in which three programs, running as separate processes, share a data structure:
http://bb4w.wikispaces.com/Sharing+a+structure+between+processes
Richard.
|
|
Logged
|
|
|
|
|