Article View: borland.public.cppbuilder.nativeapi
Article #13410Re: Multiple Threads & One Text File
From: Dennis Jones
Date: Wed, 15 Oct 2003 20:13
Date: Wed, 15 Oct 2003 20:13
51 lines
3010 bytes
3010 bytes
"Hans Galema" <dontusethis@dontusethis.nl> wrote in message news:3f8d9eca$1@newsgroups.borland.com... > > I was assuming that any kind > > of file locking being done by the OS would have to be done with some sort of > > internal kernel object, which of course, no other machine would know about. > > Heh, the other machine does not lock the file! Well, now that is the real quesiton. If an application on one computer tries to lock a file on a shared network drive, who is responsible for actually performing the lock? The OS on the machine running the application? Or the OS on the machine where the shared network drive exists? > The other machine askes if > the os will lock the file. There is only one os (on the machine with the file) > that decides. (Well if it is different, I'm wrong.). Well, if Windows is smart enough to know that the file is on a shared network drive and then ask the other machine for permission to lock the file, then you would be right. > >>Isn't appending to a file with fwrite() an atomic process ? > > > No, I don't think so, not even for multiple processes/threads on the same > > machine. > > But this even is simpler than many processes on one machine! > There are not several threads running then. Only the os that > has to handle requests. That is your server already. Are you under the impressiong that I am running a client/server type application? I am not. That was Remy's suggestion, and I was hoping for a simpler solution; hence this question about shared network file locking. > >>Every client could open the file once for a whole session. > >>You do not have to lock. After fwrite() you could flush. > > > > I would be very suspicous of code that did that. > > It would help the discussion if you told why. Because I am not sure there is anything to prevent multiple writes to a shared file from occuring at the same time from different machines. - Dennis
Technical Details
Message-ID:
<3f8daa84$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f88f22a@newsgroups.borland.com> <3f890078$1@newsgroups.borland.com> <3f8cc993$1@newsgroups.borland.com> <3f8ced2e@newsgroups.borland.com> <3f8d6af9$2@newsgroups.borland.com> <3f8d9eca$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,2cf03e35cbac1db7 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-10-15 13:39:59 PST From: "Dennis Jones" <djones@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f88f22a@newsgroups.borland.com> <3f890078$1@newsgroups.borland.com> <3f8cc993$1@newsgroups.borland.com> <3f8ced2e@newsgroups.borland.com> <3f8d6af9$2@newsgroups.borland.com> <3f8d9eca$1@newsgroups.borland.com> Subject: Re: Multiple Threads & One Text File Date: Wed, 15 Oct 2003 13:13:57 -0700 Lines: 53 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 204.200.27.7 Message-ID: <3f8daa84$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1066248836 204.200.27.7 (15 Oct 2003 13:13:56 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail