News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Read/Write Locking library

Started by u, February 25, 2007, 12:29:41 PM

Previous topic - Next topic

u

This is my attempt at solving this problem in the best way possible (fast and small, no drawbacks).

(the problem is: allowing multiple threads to simultaneously read from a shared object, and one thread to be able to write exclusively there. While a thread gains readwrite access to the object, no other thread can read or write to that object). Mostly applicable in internet-servers)

The object is only 4 bytes big, supports up to 65535 simultaneously-running readers, has optimized behaviour for its environment (number of processors and type of OS), and is completely safe.

Each of the lib's procs expects ECX to contain the address of the 4-byte RWLock object. The only modified register in each of the procs is EAX.

Since the 4-byte object contains only numbers (and no Windows objects), with CreateFileMapping you can even do inter-process synchronization.
[EDIT]Attachment updated[/EDIT]
Please use a smaller graphic in your signature.

u

#1
[updated the above attachment]
Polished-up the code, made an example project in C++, and wrote an article on the topic, eventually to send it to *.com  :toothy.
Hopefully I've not made striking errors in the RWLock object's design, led by incomplete understanding of the Windows internals. At least to me, this design seems universal.
Please use a smaller graphic in your signature.

TNick

If guys that created the site for the company I work for would use this or something like that, my life would be a lot easier! :)

Thanks for sharing!
Nick

Draakie

Hi Ultrano

Great project - You know I needed it - did'nt you ?! :clap:

Keep up the great work.

Thanx
Draakie

Does this code make me look bloated ? (wink)