Click here to Skip to main content
13,139,132 members (83,931 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am planning to do project in Analysis and evalution of posix threads vs win32 threads.
I am actually measuring thread creation time, thread scheduling latency(time taken by scheduler to stop one thread and start another thread), inter-thread communication with mutex.
I am not able to find what kind of more latencies, I can measure.
This is my term project.
Any Ideas are welcome.
Posted 10-Sep-12 3:13am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That's a good question... You've already chosen some things to measure, but since you're measuring performance between two competing implementations of standards, I'd also like to see shared memory access performance when using critical sections instead of mutexes. It's supposed to be faster since it doesn't require going to the kernel, but it be interesting to find out exactly how much faster.

Good luck and please do post as an article when you're done. It's always interesting to see performance statistics for different implementations.
Chuck O'Toole 10-Sep-12 15:49pm
Theorethically, a mutex does not need the kerenl either. Mutex is supposed to be the best of a "spin lock" (requires a hardware atomic test-and-change instruction) and a "semaphore" to queue waiters. If there's no contention for the interlock, a mutex can determine that in a single instruction (test and set) and proceed but if another thread owns the lock then there's a queue to wait in. While "spin locks" are fast when acquiring a lock, they have the downside of chewing up cpu cycles waiting for the contending lock to release it. This can effectively slow down the system when the number of lock contenders is greater than the number of processors / cores available to run them.
Albert Holguin 10-Sep-12 17:04pm
I seem to remember reading on msdn that mutexes did go to the kernel, I don't exactly remember the context or anything, but it was their rationale for explaining that critical sections are a better/faster option in most cases (depending on use of course)... but then again, I can't recall what I wore Friday. :)
Chuck O'Toole 10-Sep-12 17:57pm
Well, I'm not exactly sure of Windows NT based kernels so I'll defer to msdn. Mutexes have been around longer than Windows NT and existed before POSIX codified them in a standard. As early as 1970 I was using read/modify/write instructions to do the "fast lock check" part of the mutex followed by a semaphore / queueing operation if the lock was taken. So, that's why I said that in theory, you don't need to involve "a kernel" until you need to block / wait for the release event.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100