Re: acquiring resources shared or exclusive

From: Andreas Dilger (adilger@turbolinux.com)
Date: Wed Oct 04 2000 - 16:13:55 EST


Jerry Kelley writes:
> I have a rudimentary question as I'm new to the Linux kernel. Is there a
> resource that can be acquired shared so that multiple threads can read data
> from a protected region and not block each other? It seems that the
> semaphore in the Linux kernel is only exclusively acquirable. I need to be
> able to share read access from several threads to some global structures and
> don't want them to block.
>
> I do want blocking whenever I have to modify the structures though. Thus I'm
> looking for a way to perform synchronization for reads (shared) and writes
> (exclusively) in the kernel. I assume it can be done it's just that I'm not
> sure how to do it yet. This is probably a very easy question.

There are read/write locks available in the kernel. Look in
include/linux/spinlock.h and include/linux/brlock.h.

Cheers, Andreas

-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Oct 07 2000 - 21:00:15 EST