Search

Last Downloaded

zip-0"Banshee" NSO-989 Tariq
zip-1EA Thunderbolt

Login

Threads and shared memory

GrandpaTrout's Avatar Topic Author
King of Space King of Space
  • Posts: 1135
  • Thanks: 0

Threads and shared memory

22 years 1 month ago
#17968
I wrote a small program to test some theories about how memory is shared between threads. The SDK states that threads have seperate memory, and cannot share.

But it does not comment on how globals are handled. Or how groups are handled. Tasks often want to move around groups of ships, or lists of objects.

I found some surprising results:
Both lists and groups can be shared between tasks.

I created a list and group in a first task, added some items, and then placed both into globals. (The group in a global handle).

I then used a second task to look at list and group and see if the items were there. They were. I then added another item.

I then used the first task to check if the new items showed up. They did.

I did not expect that groups could be used to share, because you must "create" a group (thus allocating memory). But it seems to work. This contradicts earlier findings - so I am betting it breaks in weird and unexpected ways.

Full source and package file here:

www.i-war2.com/epic/files/MemTest.zip

-Gtrout

Please Log in or Create an account to join the conversation.

MajorTom's Avatar
Junkie Junkie
  • Posts: 992
  • Thanks: 0

Re:

22 years 1 month ago
#9036
Originally posted by GrandpaTrout

I
This contradicts earlier findings - so I am betting it breaks in weird and unexpected ways.


-Gtrout

The winner (culprit) is: Group.Flatten() !!!

We use group globle handles to deal with bot groups in the MP games but always copy them into a list (like you did) before changing properties because Group.Flatten() side effects the original groups.


Have Gun, Will Travel

Please Log in or Create an account to join the conversation.