Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1455
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!feeder.news.tin.it!spool.news.tin.it!not-for-mail |
|---|---|
| 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> |
| Subject | Re: [Cross post: prog+asm+c]thread problem: one write, many read |
| Date | Tue, 10 Apr 2012 08:42:10 +0200 |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.2900.2180 |
| X-RFC2646 | Format=Flowed; Response |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2900.2180 |
| Lines | 56 |
| Message-ID | <4f83d522$0$1385$4fafbaef@reader2.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
| X-Comments | Please send technical notifications to newsmaster@tin.it |
| NNTP-Posting-Host | 213.45.245.98 |
| X-Trace | 1334039843 reader2.news.tin.it 1385 213.45.245.98:3959 |
| X-Complaints-To | Please send abuse reports to abuse@retail.telecomitalia.it |
| Xref | csiph.com comp.programming:1455 comp.lang.c:19467 |
Cross-posted to 3 groups.
Show key headers only | View raw
"io_x" <a@b.c.invalid> ha scritto nel messaggio news:4f83d0ff$0$1377$4fafbaef@reader2.news.tin.it... > there is one buffer, only one thread write, > many threads read that buffer > > what is the best solution for this problem for the x86 cpu? > How do you useful express that using the C language? :) i'm not ot > > i think it is this: [because i believe it is possible many > threads can read one peace of memory in the same time...] > > thread write: > unsigned32bits v=0, mem=0; > > mem=7; > /* wait until v is 0 */ > Wait(&v, 0); > change(buffer, len) > mem=0; > > -------------- > > threads read: > /* wait until mem is 0 */ > Wait(&mem, 0); because here it is possible the thread write change mem... > atomic++(&v); /* if v==-1 seg fault :) */ > leggi(buffer, len) > atomic--(&v); > > you see dead lock on all this? i not... unsigned32bits v=0, mem=0; thread write: /*atomic means if it is lock not write ...*/ atomic_move(&mem, 7); /* wait until v is 0 */ Wait(&v, 0); change(buffer, len) atomic_move(&mem, 0); threads read: /* wait until mem is 0 if is 0 lock mem and atomic increment v unlock mem */ WaitIncrement(&mem, &v); /* if v==-1 seg fault :) */ leggi(buffer, len) atomic--(&v);
Back to comp.programming | Previous | Next — Previous in thread | Next 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