Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C API: Current generated code is not reentrant and not thread safe #894

Open
didierersa opened this issue Nov 6, 2015 · 5 comments
Open
Assignees

Comments

@didierersa
Copy link

Dear all,

It is a bit unfortunate that all scade API use global extern variables (API_fromxx, ....), it make the whole code not re-entrant and will definitively disallow us to have several "EVC" instance in the same process, which may have been useful in the case of a full traffic simulation, with many train at the same time.

The generated code is also a bit fragile in a multithreaded environment as special care need to be taken to be sure to not access this global extern variable in different thread at the same time.

The previous paradigm ( using a rentrant EVC operator like outEVCData = EVC( inEVCData ) ) was safer and more versatile.

Best regards,
Didier

@stefan-karg
Copy link
Member

Dear Didier,

thanks for the notice. I will adjust the code generator setting and regenerate the C-code now.

Best regards,
Stefan

@stefan-karg stefan-karg self-assigned this Nov 6, 2015
@didierersa
Copy link
Author

Well since it change completely the API and we already have changed the implementation, maybe we can wait for the other partners approval since other may be affected.

BTW, I guess @BerndHecklele already have generated a special version for us (just be sure we have the tcp/ip code for dmi communication)

thanks a lot,

Didier

@stefan-karg
Copy link
Member

Dear Didier,

my assumption was, that you were talking about the code I generated yesterday located in the srcAndBinary repository under:

Green openETCS Non-Vital Demonstrator/Source Code/Source Code ETCS Onboard Unit System/Generated_Code/KCG-ERSA/

Is the interface in the source code in this directory according your expectations?

Stefan

@didierersa
Copy link
Author

Sorry, my fault, I was still looking in Green openETCS Non-Vital Demonstrator/Source Code/Source Code ETCS Onboard Unit System/Generated_Code/KCG-release.

The "ERSA" version is reentrant and is more appropriate for us.

Didier

@didierersa
Copy link
Author

Anyway, avoiding like hell global non-const variables is always safer, so I guess code generated in "release" should also follow that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants