Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can some one told me what's the exactly differences between mutexes and critical?

1 view
Skip to first unread message

张聪

unread,
Apr 18, 2009, 12:11:04 PM4/18/09
to
the question is the same as title :)

thanks and regards

Doug Harrison [MVP]

unread,
Apr 18, 2009, 1:30:54 PM4/18/09
to
On Sun, 19 Apr 2009 00:11:04 +0800, ???? <wso_...@hotmail.com> wrote:

>the question is the same as title :)
>
>thanks and regards

You can find a lot on this by plugging "mutex critical_section difference"
into Google, minus the quotes. Briefly, both implement the (recursive)
mutex concept. Some of their properties and differences are:

MUTEX (my caps)

1. Kernel object represented by a HANDLE. It can be used between processes
and with functions such as WaitForSingleObject.

2. All operations require kernel transitions, making it potentially slower.

CRITICAL_SECTION

1. A poorly named mutex that is sort of a mix between kernel and non-kernel
objects. Can only be used within a single process and cannot be used with
WaitForSingleObject and other HANDLE functions.

2. Acquisition in the uncontended state and release do not involve kernel
transitions, making these operations potentially faster than the
corresponding MUTEX operations.

The CRITICAL_SECTION should be used by default.

--
Doug Harrison
Visual C++ MVP

张聪

unread,
Apr 28, 2009, 12:33:11 AM4/28/09
to
Thank you, I think it's clear enough :)

"Doug Harrison [MVP]" <d...@mvps.org> 写入消息
news:ll2ku4p9k7o31fqq0...@4ax.com...

pm

unread,
Jun 2, 2009, 7:04:39 AM6/2/09
to

Sachin

unread,
Aug 21, 2009, 5:19:01 AM8/21/09
to

can you explain me what is kernal transition ?
what does it mean when we say mutex are kernal object ?

Igor Tandetnik

unread,
Aug 21, 2009, 7:49:49 AM8/21/09
to
Sachin wrote:
> can you explain me what is kernal transition ?
> what does it mean when we say mutex are kernal object ?

http://en.wikipedia.org/wiki/Kernel_(computing)

--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Scot T Brennecke

unread,
Aug 22, 2009, 5:32:15 AM8/22/09
to
Although the Wikipedia article linked by Igor is informative, it doesn't directly answer either of your questions. Once you know
WHAT the kernel is (from reading the article), you may still wish to understand "kernel transition" and "kernel object". Here is a
simplistic definition of each:
kernel transition: when a thread executing in user mode needs to make a function call to a module that is running in the kernel, a
transition must be made from user mode to kernel mode until such time as the kernel-mode function initiates the transition back into
user mode. These transitions are a little more "expensive" than regular function calls.
kernel object: These are objects that are owned and maintained by the kernel, as opposed to any user-mode process. These are
typically objects that must be known and sometimes shared by more than one process. These are also objects that might require
"secret knowledge" that is kept in the kernel only. Synchronization objects, such as mutexes, semaphores, events, etc., are all
kernel objects.

Sachin

unread,
Aug 24, 2009, 1:46:01 AM8/24/09
to

thanks a lot Scot !!
It was very simple and powerful explanation for what i wanted to know
0 new messages