Re: Problems in 1.3.93

Matthias Urlichs (smurf@smurf.noris.de)
Tue, 23 Apr 1996 08:45:08 +0100


In linux.dev.kernel, article <4lgcah$4e1@flint.inr.ac.ru>,
inr-linux-kernel@ms2.inr.ac.ru (really kuznet@ms2.inr.ac.ru) writes:
>=20
> All the textbooks (well, maybe, not all, I've read nothing=20
> except for Stevens 8)8)) explain that nobody knows for what
> mandatory locking was invented. Nobody knows useful applications

You're reading the wrong textbooks.

Assume, for instance, that you have a database with lots of readers but=
few
writers. Any update will temporarily leave the database in an inconsist=
ent
state. You therefore need locking. With advisory locks, every reader mu=
st
lock-read-unlock every piece of data it accesses, thereby requiring thr=
ee
times as many system calls.

> for SYSV IPC semaphores and message queues.
>=20
You need semaphores for locking concurrent access to shared memory. Giv=
en
that some CPUs do not _have_ atomic test-and-set instructions...

You can emulate message queues with semaphores and shared memory, true,=
but
you'd need reasonably reliable signals to do that, or pipes which liste=
n to
message boundaries. Remember that this was System Five, which didn't _h=
ave_
reliable signals, and message boundaries is something nobody seems to k=
now
about either (you can fake them, but only when there's only one reader,=
or
when you can use fixed-length short-enough messages) -- Unix-domain soc=
kets
obey message boundaries, but they hadn't been invented at that time eit=
her.
Not under Sys5, anyway. :-/

> Unfortunately, linux should comply any standards.
Linux complies with a lot of standards. If you don't want the Sys5 IPC
semaphores and message queues, fine: don't include them in the kernel.
Do your shared memory with mmap() instead.

> POSIX must be respected. The requirements of SVID are allowed
> to be ignored:
Linux is closer to the SVID than SysV in some areas. Mandatory locking,=
for
instance. Read the appropriate parts of the kernel if you want to know =
why
this is so.

> linux is not UNIX, isn't it?
>=20
The distinction is rather meaningless these days, I'd say.

--=20
Murphy's Eleventh Law
It is impossible to make anything foolproof because
fools are so ingenious.
--=20
Matthias Urlichs \ Noris Network GmbH i.Gr/ Xlink-POP N=FCrnberg=
=20
Schleiermacherstra=DFe 12 \ Linux+Internet / EMail: urlichs@nor=
is.de
90491 N=FCrnberg (Germany) \ Consulting+Programming+Networking+etc'i=
ng
PGP: 1B 89 E2 1C 43 EA 80 44 15 D2 29 CF C6 C7 E0 DE=20
Click <A HREF=3D"http://smurf.noris.de/~smurf/finger">here</A>. =
42