<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is lib$movc3 &amp;quot;atomic&amp;quot; in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988343#M37114</link>
    <description>&lt;P&gt;Thanks for the difinitive answer :)&lt;/P&gt;&lt;P&gt;I know I&amp;nbsp;could use a lock, but was wondering if I could get away without it for performance purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just to complete the picture:&lt;/P&gt;&lt;P&gt;We have Global Section A (GS_A)&amp;nbsp;and Global Section B (GS_B)&lt;/P&gt;&lt;P&gt;Current Implementation:&lt;/P&gt;&lt;P&gt;1-&amp;nbsp;Process&amp;nbsp;A takes the lock on GS_A and copies&amp;nbsp;a list of&amp;nbsp;some memory pages from&amp;nbsp;GS_A to GS_B and releases lock.&lt;/P&gt;&lt;P&gt;2- Process A then copies the pages from GS_B to disk.&lt;/P&gt;&lt;P&gt;3-&amp;nbsp;Goto 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to&amp;nbsp;change&amp;nbsp;so that:&lt;/P&gt;&lt;P&gt;Process&amp;nbsp;B takes the lock on GS_A and copies&amp;nbsp;a list of&amp;nbsp;some memory pages from&amp;nbsp;GS_A to GS_B and releases lock. At the same time Process A&amp;nbsp;is copying the pages from GS_B to disk. I do not want to have a lock for the whole GS_B because writing to disk takes too long and Process B can't wait that long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2013 15:21:41 GMT</pubDate>
    <dc:creator>rachid_c</dc:creator>
    <dc:date>2013-03-08T15:21:41Z</dc:date>
    <item>
      <title>Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5987727#M37110</link>
      <description>&lt;P&gt;I have process A and process B.&lt;/P&gt;&lt;P&gt;In process A, I want to use lib$movc3 to move a number of&amp;nbsp;pages of memory from one location to another.&lt;/P&gt;&lt;P&gt;However, process B is periodically updating&amp;nbsp;some&amp;nbsp;of these pages of memory. If process B happens to try to update a page that process A is copying using lib$movc3, will the copy be successfully done (i.e. without partial updates by process B)?&lt;/P&gt;&lt;P&gt;Is lib$movc3 atomic?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2013 21:36:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5987727#M37110</guid>
      <dc:creator>rachid_c</dc:creator>
      <dc:date>2013-03-07T21:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5987799#M37111</link>
      <description>&lt;P&gt;No! It never was even as an instruction on VAX architecture.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Guenther&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2013 23:47:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5987799#M37111</guid>
      <dc:creator>GuentherF</dc:creator>
      <dc:date>2013-03-07T23:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988297#M37112</link>
      <description>&lt;P&gt;Thanks... Maybe there is one clarification I should make (I'm sure it doesn't make a difference) ... in the scenario presented,&amp;nbsp;Process B is also using lib$movc3 to modify a page of memory.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2013 14:29:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988297#M37112</guid>
      <dc:creator>rachid_c</dc:creator>
      <dc:date>2013-03-08T14:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988317#M37113</link>
      <description>&lt;P&gt;The answer is still NO, possibly: "No Way! What were you thinking?"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need some sort of synchronization method. Probably a LOCK.&lt;/P&gt;&lt;P&gt;Check out the manuals (or help) for SYS$ENQ(w)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For &amp;nbsp;very low frequency (less than 1/second?) and lazy programming you could even consider expoiting an RMS record lock with the WAIT (RAB$V_WAT) option, allthough SYS$ENQ is not all that much harder to program&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you explain more of the context, then perhaps we can provide a better answer.&lt;/P&gt;&lt;P&gt;Things like 'how often', 'how much (data)', 'how many (processes)',...&lt;/P&gt;&lt;P&gt;What changes can be made? threading? implemenation language.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hth,&lt;/P&gt;&lt;P&gt;Hein&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2013 14:46:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988317#M37113</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2013-03-08T14:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988343#M37114</link>
      <description>&lt;P&gt;Thanks for the difinitive answer :)&lt;/P&gt;&lt;P&gt;I know I&amp;nbsp;could use a lock, but was wondering if I could get away without it for performance purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just to complete the picture:&lt;/P&gt;&lt;P&gt;We have Global Section A (GS_A)&amp;nbsp;and Global Section B (GS_B)&lt;/P&gt;&lt;P&gt;Current Implementation:&lt;/P&gt;&lt;P&gt;1-&amp;nbsp;Process&amp;nbsp;A takes the lock on GS_A and copies&amp;nbsp;a list of&amp;nbsp;some memory pages from&amp;nbsp;GS_A to GS_B and releases lock.&lt;/P&gt;&lt;P&gt;2- Process A then copies the pages from GS_B to disk.&lt;/P&gt;&lt;P&gt;3-&amp;nbsp;Goto 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to&amp;nbsp;change&amp;nbsp;so that:&lt;/P&gt;&lt;P&gt;Process&amp;nbsp;B takes the lock on GS_A and copies&amp;nbsp;a list of&amp;nbsp;some memory pages from&amp;nbsp;GS_A to GS_B and releases lock. At the same time Process A&amp;nbsp;is copying the pages from GS_B to disk. I do not want to have a lock for the whole GS_B because writing to disk takes too long and Process B can't wait that long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2013 15:21:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988343#M37114</guid>
      <dc:creator>rachid_c</dc:creator>
      <dc:date>2013-03-08T15:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988365#M37115</link>
      <description>&lt;P&gt;Hmmm.. why use a second process, and (thus) global memory.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just start an thread in the local process to finish the disk write?&lt;/P&gt;&lt;P&gt;Can probably just use basic AST's to keep everythign alive and synchronized.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need that second process/second section, and do not want the copying of the next data to wait for the writing of the current buffer then you'll have to think about granularity. Don't lock the whole section (or do, but under there...) lock pages in the the section. If in use (locked), try for a next one?&lt;/P&gt;&lt;P&gt;I suspect you'll end up using a INSQTI to grab buffers from lists.&lt;/P&gt;&lt;P&gt;It has been done many times before.&lt;/P&gt;&lt;P&gt;Start with a list of free buffers in section B, and an empty &amp;nbsp;work list.&lt;/P&gt;&lt;P&gt;process A:&lt;/P&gt;&lt;P&gt;- Grab a buffer from free queue &amp;nbsp;fill it, release to work queue,&lt;/P&gt;&lt;P&gt;- $WAKE process B if work queue was empty&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- if free queue was empty, enter self on wait queue node, and $HIBER.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;process B:&lt;/P&gt;&lt;P&gt;- Grab a buffer from the work queue,&lt;/P&gt;&lt;P&gt;- do the work,&lt;/P&gt;&lt;P&gt;- release to free queue&lt;/P&gt;&lt;P&gt;- if free queue was emtpy then look in wait queue and $wake first entry&lt;/P&gt;&lt;P&gt;- Try to gran a next work buffer, if none then $Hiber.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No locks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hein&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2013 15:45:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988365#M37115</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2013-03-08T15:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988433#M37116</link>
      <description>&lt;P&gt;Thanks Hein... I will think about that.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2013 16:47:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988433#M37116</guid>
      <dc:creator>rachid_c</dc:creator>
      <dc:date>2013-03-08T16:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988449#M37117</link>
      <description>&lt;P&gt;You can also use LIB$BSSI and friends to use a flag in a quadowrd in that shared memory section to implement a semaphore (single bit lock). This is lightweight but the implementation typically is done in a tight CPU bound loop so the wait situation should better be very short.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Guenther&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2013 17:14:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5988449#M37117</guid>
      <dc:creator>GuentherF</dc:creator>
      <dc:date>2013-03-08T17:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is lib$movc3 "atomic"</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5989389#M37118</link>
      <description>&lt;P&gt;Just to complete the already detailed explanation... even on ancient uniprocessor VAX systems, the only instructions which are atomic are those which are explicitly atomic, ADAWI, BBxxI, INSQTxI etc... Any instruction can be interrupted, for example,&amp;nbsp;for a&amp;nbsp;page fault. Other processes can execute while your process is waiting for the fault to complete. A MOVC instruction can involve many pages, and in extreme cases could incur many page faults and therefore be interrupted many times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Always take the worst case&amp;nbsp;assumptions about process synchronisation.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2013 23:00:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/is-lib-movc3-quot-atomic-quot/m-p/5989389#M37118</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2013-03-10T23:00:58Z</dc:date>
    </item>
  </channel>
</rss>

