openETCS / modeling

WP3 Top Level Project: to cover all tasks related with modeling
32 stars 42 forks source link

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

Open didierersa opened 9 years ago

didierersa commented 9 years ago

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 commented 9 years ago

Dear Didier,

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

Best regards, Stefan

didierersa commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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