Re: Is this the right list?

Gabor Kuti (ksx@sch.bme.hu)
Mon, 7 Dec 1998 20:57:10 +0100 (MET)


On Mon, 7 Dec 1998, Jason A. Pfeil wrote:

> To all respected and revered Linux developers,
>
> I apologize in advance in case this is not the right forum for my
> questions. I am a candidate for a Master's degree in Computer Science,
> and my project deals in adding functionality to the TCP/IP stack in
> linux. I am running into some problems, and I am curious about some
> synchronization mechanisms I am using. When is it safe and not safe to
> use the start_bh_atomic() and end_bh_atomic() calls to try to guarantee
> single access to critical sections of code? I am working on the 2.0.36
> kernel until I get this working, then I will port it to 2.1.x or 2.2.x (if
> it's released before I finish). If start/end_bh_atomic() is not supposed
> to be used for a general synch. mechanism, is there one to use, or should
> I roll my own? Also, when I look at the defs for the
> start/end_bh_atomic() calls, they reference a function called barrier()
> that is #defined as:
>
> #define barrier() __asm__("": : :"memory")
>
> I have never seen an assembly instruction like this, and I was wondering
> if I could ask anyone what this was and how to use it so that if I have
> to, I can roll my own synch. mechanisms.
For critical sections you should use spinlocks [asm/spinlock.h]
like:

spin_lock_t some_lock = SPIN_LOCK_UNLOCKED;

blah()
{
..
.
<crtical section begins here>
spin_lock_irq(&some_lock);
.
.
.
spin_unlock_irq(&some_lock);
<end>
..
}

You may use it without irq if you don't need to disable irqs.
It is used many places, so easily you'll find an example :)

And.. (un)lock_kernel() may also be used to for process synchronization
[asm/smplock.h?]

Seasons
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
"One who has time to complain has time to submit patches." <chinese proverb>
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/