Is it necessary to use semaphores with shared variables

is it ok to use semaphores with shared variables to prevent race conditions or is that built into the shared variable?
- James
Using LV 2012 on Windows 7 64 bit

Semaphores are more of a method to protect a section of code from executing, and as tst as said they won't really help you.  There is nothing inherently harmful about having 2 sections of code trying to write to a shared variable at the same time.  Nothing like a crashed program, scrambled value, or an error message.  What will happen is that whatever happens 2nd is the value that sticks.  So a shared variable can still have the possiblility of race conditions just like local and global variables if you are dealing with multiple writers.  That is really an architecture problem.

Similar Messages

  • Issues with Shared Variables in Systems Running for Extended Periods of Time

    I am designing a large SCADA system using LabVIEW DSC and cRIOs. My plan is to use shared variables to communicate the majority of the information across my network (much like "tags" in a normal SCADA system).
    I'm wondering if anyone has experienced issues (connection failures, etc...) with shared variables running on systems for months (both real-time and windows based PCs) without the cRIO or PC being restarted/redeploying the variables. What is the stability of the Shared Variable Engine over extended periods of time?
    Thank you for the input.
    --CLD--
    LV 6.1, 8.6.1, 2011 SP1, 2012 SP1

    I have a system with 2 cRIO's each with Ethercat extension chassis.  Each cRIO hosts ~100 NSV's and is running the scan engine at 40 Hz.
    Each cRIO is coupled to a HMI that has front panel control bindings to NSV's hosted on the cRIO as well as a windows hosted mirror library (used for citadel db logging) that is also bound to the cRIO NSV library.  The cRIO's have monay months of contiguous run time without reboot and I closely monitor cpu and memory usage and also rt performance metrics and will log faults if there are any such events.  I also use NSV's for messaging from the HMI to the cRIO for such things as setting zero offset values and deploying configuration parameters.  My overall findings are that the SV engine and the PSP are stable and efficient (especially NSV<->NSV and NSV<->HMI binding)

  • Modbus Ethernet read and write to a Eurotherm 6180XIO Modbus server using LV8.2 shared variables

    I am having EXTREME difficulty trying to establish communications with a Modbus device using LV8.2 shared variables.  The device is a Eurotherm 6180XIO Datalogger configured as a Modbus master.  The PC and a cFP-1804 are slaves.  All IP addresses are set correctly.  This approach using shared variables would seem simple, but I can't find any examples or proper guidance on how to get it working.  I am trying to avoid having to mess around with TCP/IP, OPC, or any other old-fashioned method.
    I have read many threads on related topics but none directly apply to this situation.  I have created a library containing a Modbus I/O server and shared variables bound to read and write holding registers.  I have followed all recommended tips for creating such variables but I can neither read or write data.  All data types are U16 due to Modbus protocol limitations.  I have also applied the LV x10 factor in the most significant digit in the register offset (6 digits instead of 5).
    I have a cFP-1804 on the same network which reads into the datalogger OK.  The registers I use are 31000 (for CH0 on module 0, 31002 for CH1, etc) and the data can be read as FLOAT32.  I have updated the firmwate on the 1804 to the latest level.  I cannot even get shared variables to read SGL values.  Using registers 301001 for CH0 and 301002 for CH1 I can only read U16 values, and not a 2-word SGL.
    Third party Modbus simulation software is able to write to and read from registers very easily, but not LabVIEW.
    Some questions are:
    - do I use a Modbus master or slave as an I/O server in the library as a target for binding the shared variables?
    - is there some other wierd translation in register offsets between LabVIEW and traditional Modbus?
    - is this actually possible using shared variables or am I wasting my time?

    Sending the whole 60-character string using a string or array would be the most efficient.  I have tried both methods, and these only cause the datalogger to flag a message log but no text is displayed.
    For a string variable, I have used the following binding "My Computer\Modbus Test.lvlib\ModbusServer6180\442305", where ModbusServer6180 is a Modbus I/O server configured with the logger IP address, and 42304 is the register offset at the start of the text block in the logger.  I need to write to 30 consecutive registers starting with this one.  I am not using buffering and have not enabled single writer.
    Can anyone confirm whether this method should work in 8.2?
    Does the string need a special termination character?

  • TPC 2012 - Problems with shared variable

    Hi,
    I tried to program simmilar thing to this one http://zone.ni.com/devzone/cda/tut/p/id/5548 on TPC 2012. But it doesn't work.I can see that both programs on my laptop and TPC are working(I've added an additional counter with display), but I cannot see any effect on TPC when I change the value of shared variable on my laptop. I use LabView 8.6 with Touch Panel Module. My question is what are the exact steps to run such application on TPC2012? Are they the same as for TPC 2006?
    I've noticed following issues:
    1.I cannot deploy the program from Project Manager(there is an information that maybe TPC Service is not started. - I've found such information about TPC Service http://digital.ni.com/public.nsf/allkb/DE177828D27A14A48625734E00768B66 but in fact I cannot find Start » All Programs»National Instruments » NI TPC Service » NI TPC Service Manager 1.0 Does it mean, that the TPC Service is not installed and the programm with shared varibles won't be working or can I start it somehow in another way? Do I need to have TPC service installed on TPC2012?
    Until now, I've built the project and sent it through FTP to TPC(the folder was /TEMP) and then started it.
    2.Ping works OK
    Thank you in advance for any hints how to solve this problem.
    Martin

    Well no problem, but I'm frustrated with this issue... I've tested many things and nothing. Just to help someone else as I in the future, these are my sources:
    http://forums.ni.com/t5/LabVIEW/TPC-2012-Problems-with-shared-variable/m-p/1009631/highlight/false#M...
    http://digital.ni.com/public.nsf/allkb/28536DE7E2D9E98B8625770B00738920?OpenDocument
    http://zone.ni.com/reference/en-XX/help/372507B-01/lvtpcgsm/tpc_install_sharvar/
    http://zone.ni.com/reference/en-XX/help/372507C-01/lvtpcgsm/tpc_install_sharvar/
    http://digital.ni.com/public.nsf/allkb/23532363F4905EC28625727A00730B80?OpenDocument
    http://forums.ni.com/t5/FieldPoint-Family/TPC-2006-Not-Listed-in-Targets-and-Devices/td-p/566325
    http://forums.ni.com/t5/LabVIEW/MAX-can-t-detect-TPC-2106T/td-p/831524
    http://zone.ni.com/devzone/cda/tut/p/id/5868
    http://digital.ni.com/public.nsf/websearch/28B748B9697B79E18625725A00009066?OpenDocument
    http://digital.ni.com/public.nsf/websearch/D1726990DCEB82E4862570F20069C57D?OpenDocument
    http://digital.ni.com/public.nsf/allkb/3B469103BBDD4CE48625726000665B36
    I hope find some hint..
    Fabian León
    Certified LabVIEW Associate Developer

  • I want to work with shared variables. How can I add a remote pc?

    I did an aplication to work with shared variables, but I do not know how add a remote pc. I tried make it in Variable Manager, but Labview showed a error message: "Cannot Connect to Target xxxxxxxx". What can I do?

    Message Edité par JeromeL le 08-28-2007 06:44 AM
    Jérôme LIBBRECHT

  • How to use Decode with a variable

    Maybe you've seen this done.
    I want to take statement strMenu4 and subtract the previous value
    that is stored in an array as shown in strMenu5.
    My problem is this change as shown in strMenu5 produces
    an error code:
    ORA-00904 invalid column name
    So either I'm coding something wrong or it can't be done within the
    SUM(decode) construct. If I replace the variable with a literal
    like 1000 the code works:
    SUM(decode(name,'DBWR lru scans', c1.value) - 1000) DBWR_lru_scans
    but with an array variable or even a constant the code fails:
    SUM(decode(name,'DBWR lru scans', c1.value) - Array(3)) DBWR_lru_scans, "
    Any ideas how I can use Decode with a variable and not have it interrupt it
    as a invalid column name?
    Thanks,
    Joseph Karpinski
    [email protected]
    [email protected]
    strMenu4 = "SELECT d1.instance, " _
    & " to_char(sysdate, 'dd-mon-yy hh24:mi:ss') start_time, " _
    & " SUM(decode(name,'DBWR buffers scanned', c1.value)) DBWR_buffers_scanned, " _
    & " SUM(decode(name,'DBWR lru scans', c1.value)) DBWR_lru_scans, " _
    & " SUM(decode(name,'db block gets', c1.value)) db_block_gets , " _
    & " SUM(decode(name,'consistent gets', c1.value)) consistent_gets , " _
    & " SUM(decode(name,'physical reads', c1.value)) physical_reads " _
    & " from dual, v$sysstat c1, v$thread d1 " _
    & " group by d1.instance "
    strMenu5 = "SELECT d1.instance, " _
    & " to_char(sysdate, 'dd-mon-yy hh24:mi:ss') start_time, " _
    & " SUM(decode(name,'DBWR buffers scanned', c1.value) - Array(2)) DBWR_buffers_scanned, " _
    & " SUM(decode(name,'DBWR lru scans', c1.value) - Array(3)) DBWR_lru_scans, " _
    & " SUM(decode(name,'db block gets', c1.value) - Array(4)) db_block_gets , " _
    & " SUM(decode(name,'consistent gets', c1.value) - Array(5)) consistent_gets , " _
    & " SUM(decode(name,'physical reads', c1.value) - Array(6)) physical_reads " _
    & " from dual, v$sysstat c1, v$thread d1 " _
    & " group by d1.instance "

    Re-posting in the SQL and PL/SQL forum.
    It's more appropriate.
    Thanks,
    Closing

  • Using semaphores with the SEM_UNDO flag

    I open a semaphore with the SEM_UNDO flag to have the semaphore released if the process crashes when it's locked.
    When the process terminates normally, the semaphore's value is still adjusted because the process increments and decrements operations on the semaphore were not even and are reversed on exit.
    Is there a way to prevent that?
    Can I clear the semaphore history structure in the process before exit?

    When your process terminates normally it calls exit() which in turn calls semexit() this adjust the value of any semaphores with outstanding SEM_UNDO operations. The call to semexit() is hardcoded and can't be removed.
    It deoesn't appear to be possible for a process to directly manipulate the semaphore data structures used to implement the SEM_UNDO feature.
    Regards
    Andrew Walton
    Sun Developer Technical Support

  • Problem with shared variable

    I am a newbie to labVIEW, after working on this program for 3 months with the help of NI people, the good news is, I finally can get a running program. The bad news is, the program is especially slow and 3 parallel loops only 1 ran. My code includes modbus, however, modbus works much faster than the shared variables of fieldpoint.
      Hence qn:
    1) Why are the shared variables not working? I am using network published variables as my host computer passes value to the FP target and I set a buffer for the program. The program entails read and writing of shared variables, however, it was made sure that only 1 variable is allowed to read and write at one time.
    2) Why only 1 of the 3 parallel loops will run? They are having the same time wait function, no loop should eat up the whole time share of the processor.
    Attached are my program.
    Really hope someone can help.
    :1
    THanks a million!
    Attachments:
    Heater Control.vi ‏612 KB
    cFP- Heater Control.vi ‏331 KB
    cFP- Temperature Control.vi ‏532 KB

    Hi cfp!
    Are the three parallel loops you're talking about then ones in cFP - Temperature Control? If so, they're not parallel at all. You're wiring the error cluster from the top loop into the middle loop and then into the bottom loop. This causes a data dependency of the bottom loop on the middle loop and the middle loop on the top loop.
    Remember that a node (such as a VI, function, or loop structure) can not execute until it receives all its inputs. Furthermore, a node can't release its output values until it's completely finished executing. In the case of a while loop, this means the terminal condition must be met and the while loop has stopped executing. This means that the middle loop must wait for the top loop to finish before it can even start. And the bottom loop must wait for the middle loop to stop before it can start.
    Delete the error cluster wires between the loops and you should have three bona fide parallel loops. Consider some other method of transfer between the loops for your error information if it's pertinant to your code, such as local variables, queues, notifiers, etc.
    Jarrod S.
    National Instruments

  • Creating a Cross tab that contains fields with shared variables

    I am trying to create a cross tab in CR2008. I can get the field in the details but cannot choose it when trying to create a cross tab. Please help.
    Thanks.
    Shared numbervar MonHrs;
    Shared numbervar TueHrs;
    Shared numbervar WedHrs;
    Shared numbervar ThuHrs;
    Shared numbervar FriHrs;
    Shared numbervar SatHrs;
    Shared numbervar SunHrs;
    If dayofweek(today) = 1
        then {@CapacityTeamCount} * SunHrs else
    if dayofweek(today) = 2
        then {@CapacityTeamCount} * MonHrs  else
    if dayofweek(today) = 3
        then {@CapacityTeamCount} * TueHrs else
    if dayofweek(today) = 4 
        then {@CapacityTeamCount} * WedHrs else
    if dayofweek(today) = 5
        then {@CapacityTeamCount} * ThuHrs else
    If dayofweek(today) = 6
        then {@CapacityTeamCount} * FriHrs else
    if dayofweek(today) = 7
        then {@CapacityTeamCount} * SatHrs

    I don't use CR cross tabs as a matter of preference so I can't tell you if the shared variables are having an impact on their availability in the cross tab dialog or how to make the necessary adjustments...
    I can, however, tell you that you don't need a cross tab for what you are trying to do. All you need to do is split all of the IF formulas in to their own formulas.
    This will place each day in it's own column.
    Now... you'll notice that there's a lot white space and nothing's aggregated... Not to worry, it's easy to fix.
    Just create a grouping on which ever field you were going to use as "rows" in the cross tab... insert SUM totals in the group header... and hide the details.
    Now you have created your own manual cross tab, without using CR's cross tab object.
    HTH,
    Jason

  • Using TCP or shared variable for data transfer

    I am trying to send a large amount of numbers from a real-time module to a host computer.  These numbers have been arranged into a large array, such as an array with 10s of thousands of points.  The time critical portion of getting the information has already been done, so the data transfer back to the host VI is not time critical.  I know I will need to break the large array down into smaller arrays and then reform the large array after all the information has been sent.  I know how to use both TCP and shared variables with FIFO.  What I am unsure of is which one is better to use for this application.  I do not know what the maximum size arrays I can send through either.
    Also, from what I have gathered from using LabView is that the sender has to be listening for a connection before the client opens a connection, or else it will throw an error.  When I tried breaking it down into 50 points, if i did not wait long enough in the host VI or if I did not put a long enough wait function in the RT loop, and error would throw, so it would take a long time to transfer the data when it worked properly.
    Any help or suggestions is appreciated, thanks.

    Regarding the array size question, there is no real limit (other then the amount of memory in your system) to the size of data that you can transfer in a single block using either TCP or the Shared Variable. In your case you can easily transfer an array with 10's of thousands of data points in a single write operation. Both TCP and the Shared Variable will automatically handle breaking up the data for the maximum packet size on Ethernet and then reconstitute the array on the receiving end. In LabVIEW you will simply get back the array as a whole without needing to worrying about how the data is broken into smaller packets on the Ethernet.
    I tested the attached example which transfers 400kB per block (50000 Doubles) without any problems. You do need to have the Server (in this case RT) running first before the client (Windows) can connect.
    Message Edited by Christian L on 02-09-2007 11:34 AM
    Christian Loew, CLA
    Principal Systems Engineer, National Instruments
    Please tip your answer providers with kudos.
    Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system,
    or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject
    to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense
    Attachments:
    TCP.JPG ‏44 KB

  • How to use the "Get Shared Variable List" VI on an RT target?

    Hello,
    I'd like to programatically iterate through all the shared variables in a library hosted on my CompactRIO. I dropped the "Get Shared Variable List" VI into my Real-Time VI, but when I tried deploying it, LabVIEW said
    Deploying PRC_GetVarList.viPRC_GetVarList.vi loaded with errors on the target and was closed.
    LabVIEW: Failed to load shared library dscProc.dll:ni_lvdsc_process_GetTagListEnd:C. Ensure that the library is present on the RT target. Use MAX to install NI software or FTP to transfer custom libraries to the RT target.
    LabVIEW: Failed to load shared library dscProc.dll:ni_lvdsc_process_GetTagListBegin:C. Ensure that the library is present on the RT target. Use MAX to install NI software or FTP to transfer custom libraries to the RT target.
    I looked at the MAX Software Wizard, but couldn't find any DSC-related modules. Where should I be looking?
    Thanks!
    Solved!
    Go to Solution.

    Hello,
    The DSC palette is not supported on Real-Time VIs and will lead to errors when deployed.  Unfortunately, to have a successful build you will need to modify your application and remove any of the VIs from the DSC palette on your RT Target.
    Regards,
    M. Whitaker
    ni.com/support

  • Print-time charting with shared variables on a report without groups...

    hello all,
    I have an interesting conundrum; I am working on a report (Crystal XI) with no groups to it, just several subreports. Presently the report is run weekly and sent to the manager of one of our departments.
    The report itself showcases all areas of the department with total tasks, longest outstanding task, average days outstanding, MTD tasks completed, and YTD tasks completed. Due to the variety of tables the data pulls from, I have it set up as subreports that simply display the data.
    All total, there are 20 different shared variables that have been obtained from 10 different subreports. I have the shared variables set as the running totals from the subreports (hence, all are print time). Since the running totals and all the subreports are time based and are not actually linked to ANYTHING on the main report, I am struggling with how to set up the formulas described in the white paper, "Charting on Print Time Formulas".
    The setting up of the two formulas ({@onchngof} and {@showval}) will be different for my situation, as all of the subreports run off of date information relative to when the report is ran. I've got all of the subreports that the shared variables originate in early in the report; but where to from here?
    Would I set up maybe a date grouping or some other non-essential consistent grouping to make it work? The way this report is, it really doesn't need grouping, because the main report is just a display agent for the subreports...
    As always, any help is greatly appreciated!

    Let me ask couple of questions before trying to resolve this.
    1. The chart you are trying to built is placed in which section and is it on Main report or sub-report of its own. This is needed because if you are trying to access shared variables values in Main report, the section should be below the sub-report placed sections.
    2. Try pacing few test formulas in Main report and make sure the correct values are being pulled in on Main report.
    If you are successfully pulling the variable values on the report, try creating a simple chart in report footer with the values you have pulled and see if its taking you somewhere...
    Would need more information on how those variables are being accessed form sub to main or sub to other sub for example are you making an array of those variables and splitting or bringing it in as separate...

  • Multiple use of a shared variable - buffers?

     Hi all,
    I have an application on a RT target that measured data (around 60 variables stored in a big cluster) in a TCL, sends it via RT-FIFO
    (a modified U8-Array buffer that contains the data converted into string and then flattened to U8-Array) to the NTCL which then
    writes the data to a file and sends it via TCP/IP to the user interface on a PC.
    This is slow. I know that strings should be avoided on RT and especially extensive formatting of variables into strings. I want to
    switch over to shared variables now and write files on the PC only.
    Problem: I need the data on the RT target as well for control purposes (PID regulation of a cooling system). Can I read the same shared
    variable twice, once in the control sub-vi and once on the PC? How does that affect the buffeing of the shared varaible. Does each
    "subscriber" gets its own read buffer?
    Or should I use a global variable (this will again be a 60 element cluster) on the RT for communication between the read-data-vi, the
    control-vi and the send-shared-variable-to-host PC-vi. As I've read, big global variables should be avoided as well on RT-systems.
    Or can I use a queue instead of the global variable for the data-cluster? 
    Cheers,
    Olaf

    Hey,
    Transfering data from a TCL to a NPL (Normal Priority Loop) via RT FIFOs and then via TCP/IP to a Host System has a better performance then a shared variable.
    So using shared variables instead of your actual architecture wont result in a better performance. I would suggest to optimize your code.
    According to the shared variables behaviour: yes, you can read it at your Host and the RT System at the same time without loosing data when configured as RT FIFO.
    Christian

  • Can I Use defaultTab with a Variable?

    Hello. I need to use the defaultTab values of a Spry tabbed panels with a variable but can't figure out how to do so. In short, I am creating links to specific tabs on another page like this:
    <a href="registration.html?sport=soccer&clinic=youth>
    The tabs are opened by assigning the sport and clinic names to their respective tabs like this:
    var params = Spry.Utils.getLocationParamsAsObject();
    theClinic = params.clinic;
    switch (theClinic)
    case 'youth':
        var Soccer = new Spry.Widget.TabbedPanels("Soccer", {defaultTab: 0});
      break;
    However, I now want to make sure that a default tab can be defined like this:
    var Soccer = new Spry.Widget.TabbedPanels("Soccer", {defaultTab: defaultClinic ? defaultClinic : 0});
    I was hoping to set up defaultClinic in the first piece of code (before the break) like this:
    var defaultClinic = defaultTab;
    But that doesn't work, so is there another way to take the defaultTab value and work it into a variable?
    Thank you.

    Hi,
    I don´t know the number of variables.
    Example 1:
    if (s = true) then
    column_clause:= 'emp';
    using_clause := 'var_emp';
    value_clause := ':x';
    end if
    if (y = true) then
    column_clause:= column_clause || ', emp';
    using_clause := using_clause || ', var_emp';
    value_clause := value_clause || ', :x';
    end if;
    EXECUTE IMMEDIATE
    'INSERT INTO TABLE (' || column_clause ||') VALUES ('|| value_clause ||') ||
    USING || using_clause;
    Because if I use:
    EXECUTE IMMEDIATE cmd_insert; --without "USING" clause, I have low performance.
    Someone have a sugestion to make the "Example 1" to work ?
    Thank you very much.

  • Is it possible to use attachMovie with a variable ID reference?

    Hello:
    I am trying to write an attachMovie statement with a variable
    feeding the ID parameter. Is that possible?
    For Example:
    fadeInVar = '"LS_body_home_ID"';
    _level0.LS_hitArea_body.attachMovie([fadeInVar],
    "attached_LS_body", 1);
    I can't quite figure out how to write this. I tried an eval
    function as well...
    If you have any ideas, please let me know.
    Thank you!
    - Garrett

    I'm not so sure that this will even work but off the top of my head I can say remove the [] from around [fadeInVar].
    AS2... not sure if this will work. I know in AS3 it wouldn't. It would for sure work if you externalized your images/swfs from the library and used a moviecliploader to load in a swf/image from a URL.
    function loadFile(fileURL:String):Void
         var mcl:MovieClipLoader = new MovieClipLoader();
         mcl.load(fileURL, container); //Where container would be the display object (movieclip or Bitmap) that you wanted to load the item into.
         //To dynamically create something you can add the image into, do this
         var mcContainer:MovieClip = stage.createEmptyMovieClip("containerClip" + stage.getNextHighestDepth()");
         mcl.load(fileURL, mcContainer); //Where container would be the  display object (movieclip or Bitmap) that you wanted to load the item  into.
    Use of the above function would be:
    loadFile("images/image1.jpg");
    Let me know if that helps.

Maybe you are looking for

  • Goods receipt by using Vl31N for production order.

    Hi we can do Goods receipt by using inbound delivery VL31N, with confirmation control key in PO, for purchase orders. I want to do Goods receipt using Inbound delivery( VL31N), this is my requirement. how to do it.

  • Inspection lot without batch no.

    Hi For 03 inspection type, inspection lot is creating without batch number, while doing UD it is asking for batch number. Client will give the batch number only at GR. Im unable to clear the lot. Please advise, how to create a inspection lot without

  • Activity group in the tolerance limit

    Hi experts, I have a question related to 'Define Tolerence limits of the availability control'. I hope someone can help me with this. My doubt is related to how activity groups works in this settings. For example : If i had a tolerence limit for all

  • Regarding modification in va01/vao2/va03 tcode

    as per we can configure the screen of mm01,mm02,mm03 in spro by modifying the datascreen and assining the data screen to mm01/mm02/mm03.teis requirement i executed. but now i need to modify th screen of va01/va02/va03 with specific order type.in the

  • Diff between fb60 and f-43

    Hi What is the difference beween the FB-60 and F-43