[<prev] [next>] [day] [month] [year] [list]
Message-ID: <4BED2620.2070607@colorfullife.com>
Date: Fri, 14 May 2010 12:29:52 +0200
From: Manfred Spraul <manfred@...orfullife.com>
To: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
CC: Chris Mason <chris.mason@...cle.com>, Nick Piggin <npiggin@...e.de>
Subject: [CFT] System V sem: test app for comparison with other Unices
Hi all,
Attached is a test app that checks three details of the system V
semaphore implementation:
- is forward progress guaranteed before other tasks are woken up?
- is sem_ctime updated by semctl(SETVAL)?
- is it handled that a "decrease" operation can wake up a task that does
a wait-for-zero, even if the result of the decrease is not 0?
If I read the available sources correctly, Linux
- implements sem_ctime differently from all other Unices I found.
- tries to implement more (hopefully: all) corner cases with complex
semops's.
Here is the result of my code review:
http://calculix-rpm.sourceforge.net/sysvsem.html
It would be great if someone with access to e.g. FreeBSD or other Unix
versions could run it and confirm my review.
Chris, Nick: Btw, Linux is the only implementation that guarantees FIFO
for semop().
Here is the Linux output:
<<<
****************************************
test1: do a non-trivial sleep
got semaphore array d0002h.
SETVAL succeeded.
IPC_RMID returned 0, errno now 0 (expected: 0, 0).
Child 0(3636): sys 0.000000, user 0.000000.
Child 1(3637): sys 0.000000, user 0.000000.
Child 2(3638): sys 0.000000, user 0.000000.
Child 3(3639): sys 0.000000, user 0.000000.
Child 4(3640): sys 0.000000, user 0.000999.
Total time: sys 0.000999, user 0.000000.
+++ test1 success: No Livelock
got semaphore array d8002h.
****************************************
test2: does SETVAL update sem_ctime?
before SETVAL: ctime now 1273832652 (3).
SETVAL succeeded.
before SETVAL: ctime now 1273832655 (0).
INFO: OS updates sem_ctime in semctl(SETVAL)
****************************************
test3: check that kernel wakes up child that waits for non-zero value.
SETVAL succeeded.
child completed, before exit: GETVAL now 2.
parent: after sleep: GETVAL now 2.
parent: after waitpid: GETVAL now 2.
+++ test3 success: kernel wakes up child correctly.
****************************************
Done, cleanup.
IPC_RMID returned 0, errno now 0 (expected: 0, 0).
>>>
And here opensolaris:
<<<
./complexdec
****************************************
test1: do a non-trivial sleep
got semaphore array 2h.
SETVAL succeeded.
IPC_RMID returned 0, errno now 0 (expected: 0, 0).
Child 0(6815): sys 0.000000, user 4.160000.
Child 1(6816): sys 0.000000, user 4.160000.
Child 2(6817): sys 0.000000, user 4.130000.
Child 3(6818): sys 0.000000, user 4.090000.
Child 4(6819): sys 0.000000, user 4.080000.
Total time: sys 20.20620000, user 0.000000.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
test 1 bad: OS should hide in shame, Livelock detected.
got semaphore array 3h.
****************************************
test2: does SETVAL update sem_ctime?
before SETVAL: ctime now 1273830869 (3).
SETVAL succeeded.
before SETVAL: ctime now 1273830869 (3).
INFO: OS performs no update to sem_ctime in semctl(SETVAL)
****************************************
test3: check that kernel wakes up child that waits for non-zero value.
SETVAL succeeded.
parent: after sleep: GETVAL now 1.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Test 3 bad: got unexpected value (child not woken up?).
****************************************
Done, cleanup.
IPC_RMID returned 0, errno now 0 (expected: 0, 0).
child: semop failed.
>>>
--
Manfred
View attachment "complexdec.c" of type "text/plain" (7470 bytes)
Powered by blists - more mailing lists