From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.236.41 with SMTP id ur9mr18467578pac.12.1441639123848; Mon, 07 Sep 2015 08:18:43 -0700 (PDT) X-Received: by 10.182.49.225 with SMTP id x1mr77916obn.16.1441639123775; Mon, 07 Sep 2015 08:18:43 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!kq10no1901977igb.0!news-out.google.com!f6ni3784igi.0!nntp.google.com!kq10no1901960igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 7 Sep 2015 08:18:43 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.111.149.24; posting-account=Ies7ywoAAACcdHZMiIRy0M84lcJvfxwg NNTP-Posting-Host: 50.111.149.24 References: <6725e7d9-eb8e-49b0-985d-9c1b1bbd6fd8@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Exclusive file access From: brbarkstrom@gmail.com Injection-Date: Mon, 07 Sep 2015 15:18:43 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:27728 Date: 2015-09-07T08:18:43-07:00 List-Id: On Sunday, September 6, 2015 at 3:52:08 PM UTC-4, bj=F6rn lundin wrote: > > On Saturday, September 5, 2015 at 11:56:28 AM UTC-4, bj=F6rn lundin wro= te: > >> > >>> I have no idea about Linux but it is perfectly possible under Windows= .=20 > >>> However this doesn't stop people (including Microsoft) from creating = lock > >>> files that then sometimes get left behind when a program crashes > >>> rendering the file locked forever! > >>> So the presence of lock files doesn't mean that the opsys can't lock > >> exclusively. > >> > >> That is why you do not want to use gnat.lockfiles, (at least on linux) > >> but instead use somthing like linux' lockf. > >> > >> If the process holding the lock gets killed, (even by kill -kill) > >> the kernel (or something) releases the lock. > >> No stale lockfiles. > >> > >> > >> -- > >> Bj=F6rn > >=20 > > I have been debugging a concurrent Ada program (on Windows XP, but I > > expect the GNAT GPL would work the same on Linux).=20 >=20 > We are talking about different things. > The op said he had *several processes*. Not one process with several > tasks. My posting above is directed to the case with several processes, > not several tasks. >=20 > Say you have a program that should run almost all the time. > But when it experiences external trouble (network down), its easier to > just exit the program, and have a scheduler to restart it. > (crude but simple and good enough in my case) >=20 > Now, the scheduler needs find out if one instance is running > or not. More than one instance is no good. >=20 > The program then uses lockf to lock a file exclusively at startup. > The scheduler runs once a minute and tries to lock that same file. > If failure - the process runs and that is it. > If success - release the lock, and restart the process. >=20 > Also, if the process is restarted by mistake, it > will fail to lock the file, and exit. > There is already an instance running. >=20 > Has nothing to do with tasks. > Its like opening the file with notepad and word at the same time. >=20 >=20 > --=20 > -- > Bj=F6rn I understand the context of your thinking. My comment was specifically directed at separating contexts dealing with Ada approaches to the problem. There's a context in which there's only a sequential Ada program, another in which the Ada program involves several tasks, possibly including=20 interactions with processes under the control of the OS on a single=20 machine. There's a third involving processes running on different machines= . The context you're assuming appears to fall into the second or third of the= se. The second context may involve what's usually called "low level" interactio= ns with the OS, possibly using mutexes or other library procedures. From an A= da=20 perspective the third may require items discussed in the Distributed System= =20 Annex. Bruce B.