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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,17f674692867d416 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 04 Jan 2010 15:25:35 +0100 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Atomic file creation References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4b41fa5f$0$7620$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 04 Jan 2010 15:25:35 CET NNTP-Posting-Host: 06e8b48d.newsspool1.arcor-online.net X-Trace: DXC==jjLh>_cHTX3jmi vlc schrieb: > But this is not completely safe as it is not atomic. A higher-priority > task e.g. could intercept my task between lines 1 and 2 and create the > same file. In this case the file would be overwritten. A multitasking program can use a protected object for this. Have all tasks perform I/O if and only if it is their turn as decided by the queuing control of the protected object. > Is there something like C's O_EXCL flag for "open" in Ada? Strictly speaking, O_EXCL is not C, but it is provided by Unix's open(2) call. fopen(3), which is C, does not offer exclusive access IIRC. The Form string parameter of your Ada implementation might provide sharing control. The docs will then explain how a Form value affects files opened by many tasks; possibly even explain whether the form strings have an effect on using the external file in other programs.