Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1460
| 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> |
| Subject | Re: [Cross post: prog+asm+c]thread problem: one write, many read |
| Date | 2012-04-10 11:26 +0200 |
| Message-ID | <4f83fbbd$0$1388$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: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...]
> unsigned32bits v=0, mem=0;
>
> thread write:
/* atomic++mem means:
1) if mem has the lockWrite counter!=0 wait()
2) if the lockWrite counter == 0
increment lockWrire counter for mem
increment mem 1
decrement lockWrire counter for mem
3) if thread read it when lockWrite counter !=0
that thread read the before [or the pass?] value
of mem
4) if mem==-1 inc mem is seg fault
*/
atomic++mem;
wait(&v, 0);
write(buffer, len)
atomic--mem;
threads read:
/*waitLockWrite(&mem)
wait until mem is 0, in the same time mem is 0
lock it only for write <=>
increment the lock_write counter for mem
is this operation possible?
unlockWrite(&mem);
decrement the lock_write counter
*/
waitLockWrite(&mem); atomic++v; unlockWrite(&mem);
read(buffer, len)
atomic--v;
> 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