Synchronizing file access between threads in a single program in java is 
trivial. Java has a built-in synchronized methods to implement critical 
sections. I'm not sure how well it would scale though as I guess there 
implemented by calling the pthread API. 

On 20/04/2012, at 9:01 PM, "Farley, Peter x23353" <[email protected]> 
wrote:

> The OP originally stated that he had two STC processes that updated the same 
> z/Unix file at the same time and wanted to prevent this.  Are two STC's both 
> considered z/Unix processes under the same kernel when they are running on 
> the same LPAR?  If so, ISTM that locking and unlocking the file around the 
> write code will work as a mechanism to prevent simultaneous writes.
> 
> But what about two STC's running on different LPAR's in the same sysplex?  
> Does z/Unix file locking work across LPAR's, or only within the same LPAR?
> 
> Just curious.
> 
> ISTR that simultaneous writes to a common file are classically solved in most 
> unix systems by implementing a daemon process that is the only process 
> allowed to write to the file, and other processes send messages to the daemon 
> to accomplish the write function, like the syslog daemon for system messages.
> 
> The new question is whether Java on z/Unix provides access to any file 
> locking mechanism at all, as the OP also just said it was a Java application 
> and he wants to share the file among tasks of the *same* program.  That would 
> argue that using whatever the Java equivalent of the C flockfile function is 
> would be the solution to use.
> 
> But can z/Unix Java do that?  Or does he have to write a JNI function to be 
> called from his z/Unix Java code to implement a file lock?  Or should he just 
> implement a third process/task under the same program for the file writes and 
> have both of the other tasks just send messages to the write process?
> 
> Peter
> 
> -----Original Message-----
> From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
> Of Walt Farrell
> Sent: Friday, April 20, 2012 8:27 AM
> To: [email protected]
> Subject: Re: USS File Integrity
> 
> On Fri, 20 Apr 2012 11:18:45 +0800, David Crayford <[email protected]> 
> wrote:
> 
>> Of course, fcntl() can be used to implement byte-range-locking. So in
>> theory you could use it to implement
>> row-level locking in a dictionary library. ENQ is not that granular.
> 
> ENQ is as granular as the application wants to make it, depending on how 
> clever the application programmer is at encoding information into the RNAME 
> the application will use.
> 
> The key point about UNIX files, though, is that all the locking is advisory, 
> and controlled by the applications that use the file. If they all implement 
> the same locking mechanism (whatever that may be), the locking will work. If 
> they don't, it won't work.
> --
> 
> 
> This message and any attachments are intended only for the use of the 
> addressee and may contain information that is privileged and confidential. If 
> the reader of the message is not the intended recipient or an authorized 
> representative of the intended recipient, you are hereby notified that any 
> dissemination of this communication is strictly prohibited. If you have 
> received this communication in error, please notify us immediately by e-mail 
> and delete the message and any attachments from your system.
> 
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to