03-20-2017 05:39 PM
Does anyone really understand the difference between PropFlags_Shared and PropFlags_SharedAtRunTime?
I’m using the PropFlags_Shared for both Locals and for FileGlobals. I was originally using PropFlags_SharedAtRunTime but realized after some time that it was not working correctly.
I have read another forum discussion regarding this however it seems quite old and also didn’t really clarify the issue for me.
Here is a brief description of the File Globals PropFlags_Shared usage:
Thanks,
Roxanne
03-21-2017 01:01 PM
Hi Roxanne,
Without digging incredibly deep into the functionality of those flags, my initial suspicion is that while set to SharedAtRunTime the FileGlobal will be shared between threads only when the sequence starts. After which there is no sharing of the data. When set to Shared, the FileGlobal is shared continuously across threads throughout the sequence execution.
Best Regards,
Mitchell Faltin
Applications Engineer
National Instruments
03-21-2017 01:28 PM
Thank You Mitchell,
Can I assume that "shared between threads only when the sequence starts" essentially means the first time the variable is encountered? E.g. The sequence starts running and at some point down in the code the variable is encountered, that point is where SharedAtRunTime will share across all threads? All future places in the code the variable is not shared and all future batches the variable is not shared. This is how SharedAtRunTime seems to be behaving.
03-21-2017 06:04 PM
I'd recommend trying to clone a shared object at runtime and observe the difference in behavior between the two flags. For example:
1. Create a Sequence with a numeric FileGlobal "Global1"
2. Run Statement:
RunState.SequenceFile.Data.FileGlobalDefaults.SetPropertyObject("Global2",1,FileGlobals.Global1.Clone("",0))
3. Observe the difference in behavior when Global1 has the shared vs shared at runtime flag set.
As for your actual use case, you should consider changing the scope of your FileGlobals in the Sequence File Properties instead of using the shared flag.
How Do I Share Data Stored in a File Global between Different Executions?
Hope this helps!
Trent
03-22-2017 02:59 PM
The shared flags apply to when TestStand creates a clone of a property. Note that when the PropOption_DoNotShareProperties option is used with Clone, a shared flag is ignored.
If the original object has a parent property, that parent ownership is maintained, and the parent in the copy contains an alias to the original object.
One main use of shared flags in TestStand is to save memory when TestStand creates runtime copies of sequences, specifically all the properties under Step.TS.
Common examples of when TestStand clones property objects and use of shared flags will affect behavior:
The shared at runtime flag applies only when the TestStand engine makes a runtime copy of a property, such as the runtime copy of a sequence. Performing a "runtime" clone is not exposed via the TestStand API.
Some considerations:
Note: TestStand does not clone an object when it does a copy and a paste, it instead does a serialization and a deserialization, so the copy of the property does not have any sharing.
10-21-2021 10:59 AM
" you should consider changing the scope of your FileGlobals in the Sequence File Properties instead of using the shared flag."
But this shares all FileGlobals. My wish is to share on some containers and have the edit time values changed, when runtime values do change.