Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #1454

[Cross post: prog+asm+c]thread problem: one write, many read

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!border1.nntp.ams.giganews.com!nntp.giganews.com!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
Subject [Cross post: prog+asm+c]thread problem: one write, many read
Date Tue, 10 Apr 2012 08:24:31 +0200
X-Priority 3
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.2900.2180
X-RFC2646 Format=Flowed; Original
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.2180
Lines 32
Message-ID <4f83d0ff$0$1377$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.95
X-Trace 1334038784 reader2.news.tin.it 1377 213.45.245.95:6371
X-Complaints-To Please send abuse reports to abuse@retail.telecomitalia.it
Xref csiph.com comp.programming:1454 comp.lang.c:19466

Cross-posted to 3 groups.

Show key headers only | View raw


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);
atomic++(&v); /* if v==-1 seg fault :) */
leggi(buffer, len)
atomic--(&v);

you see dead lock on all this? i not...



Back to comp.programming | Previous | NextNext in thread | Find similar


Thread

[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