Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1461
| 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> <4f83d522$0$1385$4fafbaef@reader2.news.tin.it> <4f83ef7f$0$1378$4fafbaef@reader2.news.tin.it> <4f83fbbd$0$1388$4fafbaef@reader2.news.tin.it> |
| Subject | Re: [Cross post: prog+asm+c]thread problem: one write, many read |
| Date | 2012-04-10 12:56 +0200 |
| Message-ID | <4f8410cc$0$1389$4fafbaef@reader2.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
Cross-posted to 3 groups.
"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4f83fbbd$0$1388$4fafbaef@reader2.news.tin.it...
>
> "io_x" <a@b.c.invalid> ha scritto nel messaggio
> news:4f83ef7f$0$1378$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...]
Someone prefer the example using critical section?
but it seems i miss all... i don't know if it could be ok...
unsigned32bits v=0, v1=0, mem=0, mem1=0;
/*
InCS== in critical section; OutCS== out critical section
waitLock(&v, &v1)
means: wait until v is 0
in the same time v is 0: InCS(&v1)
*/
thread write:
InCS(&mem1); ++mem; OutCS(&mem1);
waitLock(&v, &v1); write(buffer, len); OutCS(&v1);
InCS(&mem1); --mem; OutCS(&mem1);
threads read:
waitLock(&mem, &mem1); InCS(&v1);
++v;
OutCS(&v1);
OutCS(&mem1);
read(buffer, len)
InCS(&v1); --v; OutCS(&v1);
>> where are deadLock and how to find them?
>> Do you know the right primitive for get threads go ok?
>>
>> thank you
>
>
>
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