Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion copying pthread_mutex_t, pthread_cond_t

View Parsed - Show only message text

Path: g2news2.google.com!postnews.google.com!m7g2000prd.googlegroups.com!not-for-mail
From: David Schwartz <dav...@webmaster.com>
Newsgroups: comp.unix.programmer
Subject: Re: copying pthread_mutex_t, pthread_cond_t
Date: Sat, 4 Jul 2009 03:41:38 -0700 (PDT)
Organization: http://groups.google.com
Lines: 26
Message-ID: <051c18ed-6071-446a-aabe-f67fe5826dbe@m7g2000prd.googlegroups.com>
References: <11b4bf56-2145-4bce-bfec-116e4d92957a@b9g2000yqm.googlegroups.com>
NNTP-Posting-Host: 67.142.166.23
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1246704098 1808 127.0.0.1 (4 Jul 2009 10:41:38 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 4 Jul 2009 10:41:38 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: m7g2000prd.googlegroups.com; posting-host=67.142.166.23; 
	posting-account=BRCrIAoAAAAKkZeVD15S8K-frMEzBaTk
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) 
	Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 youknow.youwant.to (squid/3.0.STABLE15)

On Jul 4, 2:50=A0am, James Kanze <james.ka...@gmail.com> wrote:

> Basically, is it legal to copy a pthread_mutex_t or a
> pthread_cond_t, and use the copy?

No. The reason is simple -- that is semantically ambiguous. Does the
copy refer to the mutex, simply copying the reference to it? Or does
it refer to a new mutex initialized to the same state as the original
mutex? If the mutex copied is locked, is the copy locked?

>=A0If not (which is the only
> answer which makes sense to me), where does the Posix
> specification say this?

Where does the POSIX specification say you can't add one to a
pthread_mutex_t? The standard does not have to explicitly prohibit
every crazy thing you can imagine to do.

>=A0If so, what does it mean: what happens,
> for example, if a copy a mutex which is held by a thread, wait
> on the copy, and the holding thread frees the original?

The standard doesn't say. So, anything can happen. (Or, if it does, I
couldn't find where.)

DS

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google