Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #390

Re: POSIX threads hard to implement in Windows

Message-ID <97nhe8-u1i.ln1@wilbur.25thandClement.com> (permalink)
From William Ahern <william@wilbur.25thandClement.com>
Subject Re: POSIX threads hard to implement in Windows
Newsgroups comp.lang.c, comp.programming.threads, comp.unix.programmer
References (12 earlier) <37pfe8-4gl.ln1@jones.homeip.net> <iv42dd$ed2$2@dont-email.me> <iv4blu$79l$1@dont-email.me> <c1ahe8-hi.ln1@wilbur.25thandClement.com> <97mi1gFbcvU4@mid.individual.net>
Date 2011-07-07 15:06 -0700

Cross-posted to 3 groups.

Show all headers | View raw


In comp.unix.programmer Ian Collins <ian-news@hotmail.com> wrote:
> On 07/ 8/11 06:21 AM, William Ahern wrote:
<snip>
> > But anyone who has used POSIX threads and Windows' native API quickly learns
> > that they're quite different approaches. The biggest difference that I'm
> > aware of is that Windows' mutexes cannot be statically initialized.
> > pthreads-win32 handles this with a global Windows' CriticalSection in
> > pthread_mutex_lock(). AFAIK, the C1x proposal doesn't allow statically
> > initialized objects, presumably so the interface can be implemented atop
> > Windows' API without such ugliness.
>
> Does the windows API support process shared mutexes?  The C1x proposal 
> doesn't include them probably because the process model is beyond the C 
> standard.

Yes, according to MSDN:

	Multiple processes can have handles of the same mutex object,
	enabling use of the object for interprocess synchronization. The
	following object-sharing mechanisms are available:

	o A child process created by the CreateProcess function can inherit
	  a handle to a mutex object if the lpMutexAttributes parameter of
	  CreateMutex enabled inheritance. This mechanism works for both
	  named and unnamed mutexes.

	o A process can specify the handle to a mutex object in a call to
	  the DuplicateHandle function to create a duplicate handle that can
	  be used by another process. This mechanism works for both named
	  and unnamed mutexes.

	o A process can specify a named mutex in a call to the OpenMutex or
	  CreateMutex function to retrieve a handle to the mutex object.

	Use the CloseHandle function to close the handle. The system closes
	the handle automatically when the process terminates. The mutex
	object is destroyed when its last handle has been closed.

	-- http://msdn.microsoft.com/en-us/library/ms682411%28v=VS.85%29.aspx

Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

POSIX threads hard to implement in Windows (was: C is fixed or not ?) Noob <root@127.0.0.1> - 2011-07-07 15:17 +0200
  Re: POSIX threads hard to implement in Windows William Ahern <william@wilbur.25thandClement.com> - 2011-07-07 11:21 -0700
    Re: POSIX threads hard to implement in Windows Ian Collins <ian-news@hotmail.com> - 2011-07-08 08:07 +1200
      Re: POSIX threads hard to implement in Windows Robert Wessel <robertwessel2@yahoo.com> - 2011-07-07 16:01 -0500
        Re: POSIX threads hard to implement in Windows "MikeP" <mp011011@some.org> - 2011-07-07 21:12 -0500
          Re: POSIX threads hard to implement in Windows Robert Wessel <robertwessel2@yahoo.com> - 2011-07-07 23:33 -0500
            Re: POSIX threads hard to implement in Windows "MikeP" <mp011011@some.org> - 2011-07-07 23:49 -0500
          Re: POSIX threads hard to implement in Windows BGB <cr88192@hotmail.com> - 2011-08-03 07:32 -0700
      Re: POSIX threads hard to implement in Windows William Ahern <william@wilbur.25thandClement.com> - 2011-07-07 15:06 -0700
    Re: POSIX threads hard to implement in Windows lawrence.jones@siemens.com - 2011-07-10 16:08 -0400
      Re: POSIX threads hard to implement in Windows William Ahern <william@wilbur.25thandClement.com> - 2011-07-10 16:09 -0700
        Re: POSIX threads hard to implement in Windows James Kuyper <jameskuyper@verizon.net> - 2011-07-11 06:20 -0400
          Re: POSIX threads hard to implement in Windows Ian Collins <ian-news@hotmail.com> - 2011-07-11 22:36 +1200
      Re: POSIX threads hard to implement in Windows scott@slp53.sl.home (Scott Lurndal) - 2011-07-11 16:18 +0000
        Re: POSIX threads hard to implement in Windows Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-07-12 13:30 +0100
  Re: POSIX threads hard to implement in Windows (was: C is fixed or not ?) Joshua Maurice <joshuamaurice@gmail.com> - 2011-07-07 19:01 -0700
  Re: POSIX threads hard to implement in Windows (was: C is fixed or not ?) "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2011-07-14 23:05 +0200

csiph-web