For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > December 2004 > Role of process priority in locking mechanism









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Role of process priority in locking mechanism
Kamal R. Prasad

2004-12-24, 3:57 pm

From: Casper H.S. Dik (Casper.Dik@Sun.COM)
Subject: Re: Role of process priority in locking mechanism

View this article only
Newsgroups: comp.unix.programmer
Date: 2004-12-24 01:17:35 PST

kamalp@acm.org (Kamal R. Pra) writes:

>splxxx() are a set of routines -which provide a priority level(xxx),
>which preempts other lower priority interrupts from preempting the
>code. They are used throughout the UNIX kernel, but they do not
>necessarily have anything to do with the hw. You could use splxxx()
>within an implementation of a syscall() , a device's read(), mmap(),
>ioctl() etc.. Its just to ensure atomicity of execution of a certain
>fragment of a code block.


>Except that it doesn't in a Solaris kernel (there is more than one

CPU)
>and you also block progress of all unrelated threads; in that it
>is a very primitive, coarse grained, lock.
>(splnet(), e.g., locks at the network interrupts so you can safely
>do administrative in the network stack)


It is coarse grained, and it is not a lock but rather a software
priority level (=SPL). Having more than one cpu is like having an
extra source for incoming interrupts, meaning that another block of
code will try to execute for either of the 2 reasons (interrupt or a
syscall on another cpu). I don't see why MP or MT should make a
difference to how splxxx() are used.

>a primitive lock would be something like a spinlock().


>Why is that primitive? Spinlocks are used a lot in MP systems
>for short term waits (the Solaris kernel spins when it tries to
>grab a lock held by a thread currently running on a CPU); it assumes
>the lock will be short term. (It is an adaptive lock)


Primitive as in basic type. splxxx() is not a (primitive) lock as you
stated in your earlier mail.

>Well -whether the kernel is multi-threaded or not does not ahve much
>to do with the nature of locks. Perhaps you mean, MP has a lot to

with
>the implementation of locks.
>then how will you implement splnet()? Its not related to any driver.


>You don't; the Solaris kernel does not have any interrupt level
>manipulation routines available for use by driver writers.


I see.

>netbsd, freebsd etc.. are all examples of multi-threaded kernels that
>dont work that way You are describing an implementation.


>Yes, I did not claim otherwise; threaded implementations which still
>require spl*() calls are not MT-hot as those which do not.


Im not sure what is MT-hot (in terms of terminology).
I was saying that splxxx() retains its relevance in most MT systems
-unlike your statement "used in traditional Unix systems .. but in a
modern, multithreaded systems.."

regards
-kamal

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Rich Teer

2004-12-24, 3:57 pm

On Fri, 24 Dec 2004, Kamal R. Pra wrote:

> From: Casper H.S. Dik (Casper.Dik@Sun.COM)
> Subject: Re: Role of process priority in locking mechanism
>
> View this article only
> Newsgroups: comp.unix.programmer
> Date: 2004-12-24 01:17:35 PST


[...]

Kamal, would you please learn how to post properly to an existing
thread, rather than creating a new one each time? It makes the
thread very hard to follow!

Thanks,

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

. * * . * .* .
. * . .*
President, * . . /\ ( . . *
Rite Online Inc. . . / .\ . * .
.*. / * \ . .
. /* o \ .
Voice: +1 (250) 979-1638 * '''||''' .
URL: http://www.rite-online.net ******************
Casper H.S. Dik

2004-12-24, 8:56 pm

kamalp@acm.org (Kamal R. Pra) writes:

>It is coarse grained, and it is not a lock but rather a software
>priority level (=SPL). Having more than one cpu is like having an
>extra source for incoming interrupts, meaning that another block of
>code will try to execute for either of the 2 reasons (interrupt or a
>syscall on another cpu). I don't see why MP or MT should make a
>difference to how splxxx() are used.


It's the way other stuff is "locked out"; so it is a "lock".

>Primitive as in basic type. splxxx() is not a (primitive) lock as you
>stated in your earlier mail.


I was under the impression that we were speaking english; not
using narrow definitions without first declaring them.

>Im not sure what is MT-hot (in terms of terminology).
>I was saying that splxxx() retains its relevance in most MT systems
>-unlike your statement "used in traditional Unix systems .. but in a
>modern, multithreaded systems.."


Depends on your definition of "traditional Unix systems" and
"modern Unix systems" :-)

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com