 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Serialization: Mutexes vs. Semaphores</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/serialization-mutexes-vs-semaphores-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/serialization-mutexes-vs-semaphores-2/</link>
	<description></description>
	<lastBuildDate>Sat, 18 May 2013 20:55:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/serialization-mutexes-vs-semaphores-2/#comment-68933</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Mon, 12 Oct 2009 04:49:37 +0000</pubDate>
		<guid isPermaLink="false">#comment-68933</guid>
		<description><![CDATA[In general, if you want only one job at a time to run a program, just have the program place an exclusive lock on itself when it starts and release the lock when it finishes. For ILE RPG, the *PSDS contains the object name of the program and the library it&#039;s running out of.
&lt;pre&gt;
ALCOBJ     OBJ(( mylib/thispgm *PGM *EXCL)) WAIT(60)
&lt;/pre&gt;
...do program logic here...
&lt;pre&gt;
DLCOBJ     OBJ(( mylib/thispgm *PGM *EXCL))
&lt;/pre&gt;
But usually it&#039;s not the program that should be &quot;serialized&quot;; rather, resources used by the program need to be protected. Place locks on the appropriate resources and it doesn&#039;t matter how many jobs are running the program.

Further, without placing locks on the resources, a second program can do the same processing as the program being &quot;serialized&quot;. That totally defeats the intention making it pointless.

Tom]]></description>
		<content:encoded><![CDATA[<p>In general, if you want only one job at a time to run a program, just have the program place an exclusive lock on itself when it starts and release the lock when it finishes. For ILE RPG, the *PSDS contains the object name of the program and the library it&#8217;s running out of.</p>
<pre>
ALCOBJ     OBJ(( mylib/thispgm *PGM *EXCL)) WAIT(60)
</pre>
<p>&#8230;do program logic here&#8230;</p>
<pre>
DLCOBJ     OBJ(( mylib/thispgm *PGM *EXCL))
</pre>
<p>But usually it&#8217;s not the program that should be &#8220;serialized&#8221;; rather, resources used by the program need to be protected. Place locks on the appropriate resources and it doesn&#8217;t matter how many jobs are running the program.</p>
<p>Further, without placing locks on the resources, a second program can do the same processing as the program being &#8220;serialized&#8221;. That totally defeats the intention making it pointless.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wilsonalano</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/serialization-mutexes-vs-semaphores-2/#comment-67284</link>
		<dc:creator>wilsonalano</dc:creator>
		<pubDate>Mon, 24 Aug 2009 17:48:57 +0000</pubDate>
		<guid isPermaLink="false">#comment-67284</guid>
		<description><![CDATA[Hi,

Scott Klement wrote a good article about semaphore uses here:

http://systeminetwork.com/article/get-synch-semaphore-sets

Regards,
Wilson]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Scott Klement wrote a good article about semaphore uses here:</p>
<p><a href="http://systeminetwork.com/article/get-synch-semaphore-sets" rel="nofollow">http://systeminetwork.com/article/get-synch-semaphore-sets</a></p>
<p>Regards,<br />
Wilson</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sloopy</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/serialization-mutexes-vs-semaphores-2/#comment-67280</link>
		<dc:creator>sloopy</dc:creator>
		<pubDate>Mon, 24 Aug 2009 15:39:41 +0000</pubDate>
		<guid isPermaLink="false">#comment-67280</guid>
		<description><![CDATA[There is an old-fashioned method for restricting a program to a single caller at a time, which I am giving you here because it&#039;s quick to implement and needs no expertise beyond &#039;normal&#039; programming knowledge - I hope that someone else can come up with the mutex and semaphore methods. I would love to try them!

In the *INZSR of the RPG program, write a loop to lock a data area: 

C DoU not *In91  
C *Lock In PGNAME 91 
C EndDo  

At the end of the program (when *INLR is set on before returning to the caller), unlock the data area: 

C Out PGNAME  

(In this example, the data area is assumed to have the same name as the program, which is reasonable.) 

The first job to call the program will get the lock. Subsequent callers will stick in the loop, waiting for the time determined by the class of the object (I think it&#039;s 60 seconds for a data area) in each run through the loop. 

When the first job leaves the program it unlocks the data area and the next job to start a *LOCK IN operation on the data area will get it. 

There is no &#039;proper&#039; serialisation here, in that you can&#039;t guarantee that the second caller will get the next call, the third the call after that and so on. It&#039;s first lock, first served. 

Regards, 

Sloopy]]></description>
		<content:encoded><![CDATA[<p>There is an old-fashioned method for restricting a program to a single caller at a time, which I am giving you here because it&#8217;s quick to implement and needs no expertise beyond &#8216;normal&#8217; programming knowledge &#8211; I hope that someone else can come up with the mutex and semaphore methods. I would love to try them!</p>
<p>In the *INZSR of the RPG program, write a loop to lock a data area: </p>
<p>C DoU not *In91<br />
C *Lock In PGNAME 91<br />
C EndDo  </p>
<p>At the end of the program (when *INLR is set on before returning to the caller), unlock the data area: </p>
<p>C Out PGNAME  </p>
<p>(In this example, the data area is assumed to have the same name as the program, which is reasonable.) </p>
<p>The first job to call the program will get the lock. Subsequent callers will stick in the loop, waiting for the time determined by the class of the object (I think it&#8217;s 60 seconds for a data area) in each run through the loop. </p>
<p>When the first job leaves the program it unlocks the data area and the next job to start a *LOCK IN operation on the data area will get it. </p>
<p>There is no &#8216;proper&#8217; serialisation here, in that you can&#8217;t guarantee that the second caller will get the next call, the third the call after that and so on. It&#8217;s first lock, first served. </p>
<p>Regards, </p>
<p>Sloopy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joy stalnecker</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/serialization-mutexes-vs-semaphores-2/#comment-67265</link>
		<dc:creator>joy stalnecker</dc:creator>
		<pubDate>Mon, 24 Aug 2009 11:53:35 +0000</pubDate>
		<guid isPermaLink="false">#comment-67265</guid>
		<description><![CDATA[I have several different job flows that call the same program. I want to limit access to this program to one job at a time. So only one job will ever be running this program at any given time.]]></description>
		<content:encoded><![CDATA[<p>I have several different job flows that call the same program. I want to limit access to this program to one job at a time. So only one job will ever be running this program at any given time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yorkshireman</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/serialization-mutexes-vs-semaphores-2/#comment-67260</link>
		<dc:creator>yorkshireman</dc:creator>
		<pubDate>Mon, 24 Aug 2009 08:07:37 +0000</pubDate>
		<guid isPermaLink="false">#comment-67260</guid>
		<description><![CDATA[could you amplify 

&#039;serialise access across jobs&#039;

- you intend several jobs to use a single program?   
- you need several jobs to share something concurrently?]]></description>
		<content:encoded><![CDATA[<p>could you amplify </p>
<p>&#8216;serialise access across jobs&#8217;</p>
<p>- you intend several jobs to use a single program?<br />
- you need several jobs to share something concurrently?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/8 queries in 0.009 seconds using memcached
Object Caching 325/326 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-18 21:32:05 -->