From: Aurel Balmosan <ab@oab.orga.com>
Subject: Re: mutex between processes?
Date: 1998/08/09 [thread overview]
Message-ID: <ExFH0r.JsF@orga.com> (raw)
In-Reply-To: 35CBBDEE.17958205@ne.mediaone.net
Monty Brandenberg <mcbinc.MAPS.SPAM@ne.mediaone.net> wrote:
> Problems due to incorrect SMP algorithms are very difficult to debug. It is
> much easier to do the research and get it right the first time....
From this discusion I made following concept. Following structures
are in the shared memory.
Proc 1: spinlock, some data, current_accessed_item
Proc 2:
ItemTable:
Item 1: index_to_the_real_item
Item 2: ..
RealItem:
Item 1: (Some data depending on the item)
Item 2: ...
So now the proc 1 tries to access Item 1:
- lock its spinlock
- read real address of item1 from ItemTable
- set the current_accessed_item to the found address
- unlock its spinlock
- read the data
If a writer (there is only one at a time) want to
change item 1 it do following:
- lock global writer spinlock
- alloc and set a new item in RealItem,
- queue the old address of item 1 in a cleanup-queue.
- write new address into item 1 in ItemTable
- unlock global writer spinlock.
Some server do following:
- lock gloabal writer spinlock
- get an item address out of cleanup-queue
- unlock gloabal writer spinlock.
- check if someone accesses this item currently.
if yes put it again in the queue
if no
lock gloabal writer spinlock
mark the item as reusable
unlock gloabal writer spinlock.
- continue
The critical part is writing the current_accessed_item
and the index_to_the_real_item. It must be guaranteed that
after the unlock of the proc spinlock current_accessed_item
has the correct value for any process on any processor.
(How do I handle that?)
For the index_to_the_real_item it is needed that the reader
will allways get a valid (which may be old) address. I think
that ATOMIC_EXCHANGE... can be used by the writer.
(with or without _MB?)
Bye,
Aurel.
--
Aurel Balmosan | Department SE-SW
ORGA Kartensysteme GmbH | phone: +49 5254 991 824
An der Kapelle 2 | fax : +49 5254 991 749
33104 Paderborn, Germany | mailto:ab@orga.com
next prev parent reply other threads:[~1998-08-09 4:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-08-04 4:00 mutex between processes? Aurel Balmosan
1998-08-05 4:00 ` Jeff Denham
1998-08-05 4:00 ` Dirk Grunwald
1998-08-07 4:00 ` Aurel Balmosan
1998-08-07 4:00 ` Jeff Denham
1998-08-07 4:00 ` Aurel Balmosan
1998-08-07 4:00 ` Monty Brandenberg
1998-08-09 4:00 ` Aurel Balmosan [this message]
1998-08-10 4:00 ` Dirk Grunwald
1998-08-10 4:00 ` Monty Brandenberg
1998-08-10 4:00 ` Dirk Grunwald
1998-08-10 4:00 ` Monty Brandenberg
1998-08-11 4:00 ` Aurel Balmosan
1998-08-11 4:00 ` Monty Brandenberg
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox