Respond to this messageReturn to Index
Original Message
  • Re: Sharing Variables
    • (Login MCalkins)
      Moderator
      Posted Apr 1, 2012 3:14 PM

      I played around a bit with creating a 2nd thread of QB64 execution:

      http://www.qb64.net/forum/index.php?topic=5787.0

      Note that the program crashes with access violations. I believe that this is because the PRINT statement is probably not re-entrant.

      >Only one program would need to write a certain variable, the rest would just read it, so I don't think that synchronization would be an issue.

      Maybe.

      http://msdn.microsoft.com/en-us/library/windows/desktop/ms684122%28v=vs.85%29.aspx

      ----- quote
      Simple reads and writes to properly-aligned 32-bit variables are atomic operations. In other words, you will not end up with only one portion of the variable updated; all bits are updated in an atomic fashion. However, access is not guaranteed to be synchronized. If two threads are reading and writing from the same variable, you cannot determine if one thread will perform its read operation before the other performs its write operation.

      Simple reads and writes to properly aligned 64-bit variables are atomic on 64-bit Windows. Reads and writes to 64-bit values are not guaranteed to be atomic on 32-bit Windows. Reads and writes to variables of other sizes are not guaranteed to be atomic on any platform.
      ----- end quote

      >What would you recommend, should I just be very careful to make sure all the variables are being distributed correctly or should I look into WriteProcessMemory or something?

      I don't know. I think threads are the proper solution, but QB64 isn't mature yet in that regard.

      >but both times it created the o and rc files and compiled the program, it just isnt embedding the icon in the exe

      When you look at the folder in Windows Explorer, does the icon show up as the .EXE's icon? Note that it won't show up as the application icon while the program is running, because that is an icon that the QB64 program loads manually, and is not a resource in the .EXE file.

      >Also when it creates the cpp file when I compile QB64 code, where does it store it? I would like to look at them :)

      First of all, note that QB64 can create numbered qbx.cpp files and temp subfolders. I think that this is related to whether you have multiple copies of QB64 open at the same time. If you only have one copy, it seems to not use the numbers.

      the main file is:

      internal\c\qbx.cpp

      it #includes various .txt files from your internal\temp subfolder, the most interesting of which will probably be:

      internal\temp\main.txt

      There are also other files, like:

      internal\temp\maindata.txt

      and numbered data.txt files for your SUBs and FUNCTIONs.

      The object file created by compiling qbx.cpp is statically linked to a precompiled libqbx.o, the source code of which is:

      internal\c\libqbx.cpp

      Regards,
      Michael
    Your Name
    Message Title
    Message Text
    Options
          


     Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement