Thanks for the code, when I ran it I got this:
2.6.9/Xeon/3.2 MHz
(3 runs)
129186.76 semop/s (8784700/68) [100]
129367.65 semop/s (8797000/68) [100]
129257.35 semop/s (8789500/68) [100]
This is a little off-topic, but I am afraid I do not fully understand the code.
My understanding of the purpose of the initial loop
Quote:
Originally Posted by otheus
is to start the whole measurement at the point of change of the second. Right?
Next,
we have two loops: first run 8750000 times, given the maxloop value of 1000000,
Then we run loop up to 1250000 times where every 100th iteration we check for time and if second changed, we break out
Quote:
Originally Posted by otheus
What is this technique of checking every Nth iteration for? why not check time every iteration? is it because this would add to many extra time calls and muddy the measurements?
This is a little off-topic, but I am afraid I do not fully understand the code.
That's quite ON topic and one reason I posted the code.
Quote:
is to start the whole measurement at the point of change of the second. Right?
right.
Quote:
What is this technique of checking every Nth iteration for? why not check time every iteration? is it because this would add to many extra time calls and muddy the measurements?
You answered it. AFAIK each time() call involves a system call. I think there is a better way of handling this, but this is the first that came to mind.
I do appreciate you checking the code. That I'm prone to failure may be a modest understatement.
I checked the kernels. There were major changes in 1995 (before version 2.0), 1998 (before version 2.4), and then again with the introduction of the "O(1) scheduler" (not sure). Here's the code -- unchanged since 2.4 -- that does semctl(GETALL):
Here's the code from 2.0:
When you break it down, the only difference is in the semlock() call, which is needed on multi-CPU systems. It could be SCO is also similarly limited. Why don't you try a linux 2.0 distribution, like RedHat 5.2, which uses Linux 2.0.36 (and uses the same sem code as above). Install it and benchmark the same code. That would be a great help to all of us, I think.
I emailed the maintainers of the code. This is a response I got back from Alan "Maddog" Cox (with permission to post here):
Quote:
Quote:
Perhaps you can contribute to this discussion (concerning SCO vs linux performance differences with semget):
No but if you've got a good test case using gettimeofday() rather than time
so you get high precision time data file a bug in bugzilla.kernel.org as I
imagine Ingo Molnar and a few others might be interested.
High performance Linux code uses futex locks rather than sys5 locks but it
would still be nice to know if there really is such a big difference and why
Alan
So here is yet another version using gettimeofday(). Don't bother posting the benchmarks here, unless they are significantly different. But prepare them for bugzilla:
Otheus, I never dealt with reporting on bugzilla, it seems ti me I don't quite qualify and I'm afraid I will post something not pertinent, so if you would agree to do it yourself, here are the results from 2nd version of your 'gettimeofday-based' code, which I re-run 4 times as to get average:
Just for my clarification: somehow people who participated in this discussion on unix.com formu as well as on kerneltrap and other places were very concerned with 2 things, that in my perspective are irrelevant to the subject of this thread: time measurement accuracy and involvement of running multiple processes/shells etc that would muddy the results. I would wholeheartedly agree to that IF SCO vs Linux results were comparable. But this is not the case here. SCO is three times faster, no matter we used my method or gettimeofday very accurate method. With all the overhead being roughly similar, I would think we were kind of beating around the bush when we were trying to achieve have accuracy in measurement (which does not hurt, of cource!), but it made the thread bloated.
Again, thanks to Otheus for your suggestions, at this point I the kernel code you pinpoint shows that multi-cpu capability adds a layer of complexity and it does not help the speed. Your and strcmp's (kerneltrap forum) recomendations to upgrade Linux kernel are well taken.
migurus
Just for contrast on a modern intel SMP processor running linux 2.6.18 I get more
than a million operations/sec.
On that basis I don't believe this qualifies as a bug..more of a growing pain.
Linux has always been a project in forward motion. You either catch up or suffer.
Linus is short on apologies for this model that I've seen.
On a FreeBSD 6.0 machine (uniprocessor) the time is interesting...
Intel(R) Celeron(R) CPU 2.00GHz (1999.94-MHz 686-class CPU)
Last edited by ramen_noodle; 10-08-2008 at 02:43 PM..
Reason: typo on kernel version
I was asked to add this piece of code to a c program which I will execute through the shell:
for(long i = 0; i < NITER; i++)
{ sem_wait( &sema);
count++;
sem_post( &sema); }
I didn't get it, which is the critical section ? if it's "count++" how would a thread wake up in order to enter it... (1 Reply)
If I create a semaphore and then I fork a number of child processes then all the child process use that same semaphore.
Since the process address spaces are different rfom each other then how all the child process are able to access the same semaphore?
I understand that semaphore/mutex is at os... (0 Replies)
Control two exclusively shared resources(semaphore). The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers.
Can any one help me with the... (0 Replies)
I analysed disk performance with blktrace and get some data:
read:
8,3 4 2141 2.882115217 3342 Q R 195732187 + 32
8,3 4 2142 2.882116411 3342 G R 195732187 + 32
8,3 4 2144 2.882117647 3342 I R 195732187 + 32
8,3 4 2145 ... (1 Reply)
Hi,
I am looking to use a semaphore for the first time in one of my scripts. I am just wondering if there are any simple examples or tutorials around?
I am a beginner so the simpler the better :)
Thanks
-Jaken (2 Replies)
Hello,
I have a Supermicro server with a P4SCI mother board running Debian Sarge 3.1. This is the "dmidecode" output related to RAM info:
RAM speed information is incomplete.. "Current Speed: Unknown", is there anyway/soft to get the speed of installed RAM modules? thanks!!
Regards :)... (0 Replies)