Changeset 7af0383 in OpenModelica


Ignore:
Timestamp:
2024-04-10T17:23:37+02:00 (3 months ago)
Author:
Adrian Pop <adrian.pop@…>
Children:
a75e9cad
Parents:
e8a1fdac
git-author:
Adrian Pop <adrian.pop@…> (04/10/24 10:36:42)
git-committer:
Adrian Pop <adrian.pop@…> (04/10/24 17:23:37)
Message:

add a lock to prevent several threads to enter until we set things up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/Compiler/Template/CodegenC.tpl

    re8a1fdac r7af0383  
    14111411    #undef threadData
    14121412    #endif
     1413
     1414    #if defined(OMC_DLL_MAIN_DEFINE_LOCK)
     1415    pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
     1416    #endif
     1417
    14131418    /* call the simulation runtime main from our main! */
    14141419    #if defined(OMC_DLL_MAIN_DEFINE)
     
    14181423    #endif
    14191424    {
     1425      #if defined(OMC_DLL_MAIN_DEFINE_LOCK)
     1426      pthread_mutex_lock(&mutex);
     1427      #endif
    14201428      #if defined(OMC_DLL_MAIN_DEFINE_BOEHM_GC)
    14211429        GC_init();
     
    14261434        GC_register_my_thread(&sb);
    14271435      #endif
    1428       pthread_mutex_t mutex;
    1429       pthread_mutex_lock(&mutex);
    14301436      char** newargv = omc_fixWindowsArgv(argc, argv);
    1431       pthread_mutex_unlock(&mutex);
    14321437      /*
    14331438        Set the error functions to be used for simulation.
     
    14521457      compiledWithSymSolver = <% intSub(Flags.getConfigEnum(Flags.SYM_SOLVER), 0) %>;
    14531458      <%mainInit%>
     1459      #if defined(OMC_DLL_MAIN_DEFINE_LOCK)
     1460      pthread_mutex_unlock(&mutex);
     1461      #endif
    14541462      <%mainTop(mainBody,"https://trac.openmodelica.org/OpenModelica/newticket")%>
    1455 
    14561463      <%if Flags.isSet(HPCOM) then "terminateHpcOmThreads();" %>
    14571464      <%if Flags.getConfigBool(Flags.PARMODAUTO) then "dump_times(pm_model);" %>
Note: See TracChangeset for help on using the changeset viewer.