🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13406

Re: Multiple Threads & One Text File

#13406
From: Hans Galema
Date: Wed, 15 Oct 2003 19:26
44 lines
2620 bytes
Dennis Jones wrote:

> ...-- just trying
> to get suggestions before I start work on it.  

Very legitimate.

 > 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! 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.).

>>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.

>>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.

>>That would be all.
> 
> Unfortunately, I think there is a lot more to it than that.

You could have named some.

But give it a try. Just make one apllicatio that continuallly writes
a log sentence to the logfile. Then put it on all your computers and let
them run for a while. Tonight you will know.

Hans.

Hans.
Technical Details
Message-ID: <3f8d9eca$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!kibo.news.demon.net!demon!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f88f22a@newsgroups.borland.com> <3f890078$1@newsgroups.borland.com> <3f8cc993$1@newsgroups.borland.com> <3f8ced2e@newsgroups.borland.com> <3f8d6af9$2@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 12:40:33 PST
Date: Wed, 15 Oct 2003 21:26:44 +0200
From: Hans Galema <dontusethis@dontusethis.nl>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3.1) Gecko/20030425
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Multiple Threads & One Text File
References: <3f88f22a@newsgroups.borland.com> <3f890078$1@newsgroups.borland.com> <3f8cc993$1@newsgroups.borland.com> <3f8ced2e@newsgroups.borland.com> <3f8d6af9$2@newsgroups.borland.com>
In-Reply-To: <3f8d6af9$2@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 129.125.108.11
Message-ID: <3f8d9eca$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066245834 129.125.108.11 (15 Oct 2003 12:23:54 -0700)
Lines: 45
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!kibo.news.demon.net!demon!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail