Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1468
| From | "io_x" <a@b.c.invalid> |
|---|---|
| Newsgroups | comp.programming, alt.lang.asm, comp.lang.c |
| References | <4f83d0ff$0$1377$4fafbaef@reader2.news.tin.it> <ddce2d45-1528-43d0-8c2f-367fbb14ec4f@z38g2000vbu.googlegroups.com> |
| Subject | Re: thread problem: one write, many read |
| Date | 2012-04-14 10:56 +0200 |
| Message-ID | <4f893aab$0$1380$4fafbaef@reader2.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
Cross-posted to 3 groups.
"christian.bau" <christian.bau@cbau.wanadoo.co.uk> ha scritto nel messaggio news:ddce2d45-1528-43d0-8c2f-367fbb14ec4f@z38g2000vbu.googlegroups.com... >On Apr 10, 7:24 am, "io_x" <a...@b.c.invalid> wrote: >> there is one buffer, only one thread write, >> many threads read that buffer >And what exactly is it that you want to achieve? one C/Asm answer to this post below, that has need only win32 api... then when i wrote it, i realize i have to use my functions too [C++/asm] and can not be 100% sure this is the right solution [no deadlock etc]...so i can not answer because i not uderstand very well the problem and its answer is not 100% sure... i have only my little workaround... i would like to see too, even if i never study their article on threads, i could came out with one soultion... than the question is: it is better imagine all these trheads that write or read one buffer [not a sure solution] or use some library api that do all, and sure good, for you? :) *************************** Path: reader1.news.tin.it!spool.news.tin.it!feeder.news.tin.it!bofh.it!tornado.fastwebnet.it!53ab2750!not-for-mail From: Beppe <xxxxxxxxxxx> User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 Newsgroups: it.comp.lang.delphi Subject: Re: Ancora su Thread e buffer condiviso References: <yeidr.153036$GZ3.62223@tornado.fastwebnet.it> <4f78c703$1@news.x-privat.org> In-Reply-To: <4f78c703$1@news.x-privat.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit Lines: 28 Message-ID: <DOher.153937$GZ3.83683@tornado.fastwebnet.it> Date: Mon, 02 Apr 2012 15:27:04 +0200 NNTP-Posting-Host: 93.50.78.98 X-Complaints-To: newsmaster@fastweb.it X-Trace: tornado.fastwebnet.it 1333373219 93.50.78.98 (Mon, 02 Apr 2012 15:26:59 CEST) NNTP-Posting-Date: Mon, 02 Apr 2012 15:26:59 CEST Xref: reader1.news.tin.it it.comp.lang.delphi:5233078 Il 01/04/2012 23:21, morde ha scritto: > On 30.03.2012 15:07, Beppe wrote: >> Il mio dubbio è , visto che ogni scrittura e lettura del buffer viene >> fatta all'interno di un thread gestito dai TCPserver (TContext)questo è >> sufficiente perchè non si verifichino letture e scritture contemporanee >> con blocco dell'applicazione oppure dovrei usare ad esempio un oggetto >> TCriticalSection con i relativi enter e leave ? > > Visto il contesto parallelo con cui i client richiedono i dati, per > evitare le race conditions è opportuno che proteggi la struttura shared > con una critical section nel getter ma anche nel setter dei dati, in > modo che una sola richiesta di copia alla volta venga servita e che > evita che mentre stai copiando i dati il thread che scrive ci vada sopra > a sporcarli. > > Se vuoi approfondire e/o ottimizzare il tuo server vedi questo: > http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/Ch9.html > Grazie per la risposta. Visto che il buffer viene scritto da una sola fonte ad intervalli di un secondo e letto in modo random da tanti utenti ho trovato questo oggetto che sembra fare al caso mio: TMultiReadExclusiveWriteSynchronizer si crea un istanza a livello globale e poi si utilizza BeginWrite ed EndWrite per la scrittura e BeginRead ed EndRead per la lettura. Sai se esistono controindicazioni o problemi conosciuti ? ***********************
Back to comp.programming | Previous | Next — Previous in thread | Find similar
[Cross post: prog+asm+c]thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-10 08:24 +0200
Re: [Cross post: prog+asm+c]thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-10 08:42 +0200
Re: [Cross post: prog+asm+c]thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-10 10:34 +0200
Re: [Cross post: prog+asm+c]thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-10 11:26 +0200
Re: [Cross post: prog+asm+c]thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-10 12:56 +0200
Re: [Cross post: prog+asm+c]thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-14 07:20 +0200
Re: [Cross post: prog+asm+c]thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-15 08:04 +0200
Re: [Cross post: prog+asm+c]thread problem: one write, many read "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-04-10 10:01 +0200
Re: thread problem: one write, many read "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-04-13 17:13 -0700
Re: thread problem: one write, many read "io_x" <a@b.c.invalid> - 2012-04-14 10:56 +0200
csiph-web