Thursday, 16 April 2009

Feature or Bug - named sync object mystery

If you think that a good old Win32 API call like CreateSemaphore() can't come to surprise us old war horses (I'm celebrating my last 3x birthday today :-)
you're just plain wrong.

The mystery
What's the difference in behavior, when you create multiple times a semaphore on Windows CE and on Windows XP with the following 2 different code snippets?

handle = CreateSemaphore( NULL, initialCount, maxCount, NULL);

and
handle = CreateSemaphore( NULL, initialCount, maxCount, _T("") );


Dear readers - enlighten us.
I will unravel the mystery later this week ;-)

2 comments:

Anonymous said...

Hey boy that's easy
the first snipped means
* unnamed semaphore (no IPC access)
the second
* named semaphore (IPC access possible)

hmm - second snipped has a strange name _T("") but should work.

Peter Himmler said...

Great my first comment :-)

Hi Anonymous,
it's right that the first snipped is a unnamed semaphore :-)
But what's the second one?
And is there any difference between running on e.g. Windows XP or on Windows CE?

I will unravel later this week :-)