Message from discussion
Port Driver. erl_drv_thread_join and ErlDrvTid reuse.
Received: by 10.204.5.194 with SMTP id 2mr1682261bkw.7.1349896371466;
Wed, 10 Oct 2012 12:12:51 -0700 (PDT)
X-BeenThere: erlang-programming@googlegroups.com
Received: by 10.204.13.17 with SMTP id z17ls1127543bkz.5.gmail; Wed, 10 Oct
2012 12:12:51 -0700 (PDT)
Received: by 10.204.6.19 with SMTP id 19mr1108433bkx.8.1349896371076;
Wed, 10 Oct 2012 12:12:51 -0700 (PDT)
Received: by 10.204.6.19 with SMTP id 19mr1108432bkx.8.1349896371061;
Wed, 10 Oct 2012 12:12:51 -0700 (PDT)
Return-Path: <erlang-questions-boun...@erlang.org>
Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net. [192.121.151.104])
by gmr-mx.google.com with ESMTP id k7si276512bks.2.2012.10.10.12.12.50;
Wed, 10 Oct 2012 12:12:51 -0700 (PDT)
Received-SPF: pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) client-ip=192.121.151.104;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) smtp.mail=erlang-questions-boun...@erlang.org
Received: from hades.cslab.ericsson.net (hades [192.121.151.104])
by hades.cslab.ericsson.net (Postfix) with ESMTP id CC0F05C166;
Wed, 10 Oct 2012 21:12:38 +0200 (CEST)
X-Original-To: erlang-questi...@erlang.org
Delivered-To: erlang-questi...@erlang.org
Received: from mailgw2.ericsson.se (mailgw2.ericsson.se [193.180.251.37])
by hades.cslab.ericsson.net (Postfix) with ESMTP id 916755C14E
for <erlang-questi...@erlang.org>; Wed, 10 Oct 2012 21:12:36 +0200 (CEST)
X-AuditID: c1b4fb25-b7f046d00000644c-38-5075c8a426c0
Received: from esessmw0197.eemea.ericsson.se (Unknown_Domain [153.88.253.125])
by mailgw2.ericsson.se (Symantec Mail Security) with SMTP id
C7.FC.25676.4A8C5705; Wed, 10 Oct 2012 21:12:36 +0200 (CEST)
Received: from super.otp.ericsson.se (153.88.115.8) by
esessmw0197.eemea.ericsson.se (153.88.115.88) with Microsoft SMTP Server id
8.3.279.1; Wed, 10 Oct 2012 21:12:36 +0200
Received: from [147.214.122.88] (gorbag.otp.ericsson.se [147.214.122.88]) by
super.otp.ericsson.se (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id
q9AJCXx8016470; Wed, 10 Oct 2012 21:12:35 +0200
Message-ID: <5075C8A1.9020...@erlang.org>
Date: Wed, 10 Oct 2012 21:12:33 +0200
From: Rickard Green <rick...@erlang.org>
Organization: Erlang/OTP, Ericsson AB
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
rv:15.0) Gecko/20120827 Thunderbird/15.0
MIME-Version: 1.0
To: Zhemzhitsky Sergey <Sergey_Zhemzhit...@troika.ru>
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprALMWRmVeSWpSXmKPExsUyM+Jvre6SE6UBBo1H5S3mvznKbjFz5QZG
ByaPD/emMXlcOfKFMYApissmJTUnsyy1SN8ugSvj2O6bbAUbuCqubd/F3sB4mKOLkZNDQsBE
YnbjbjYIW0ziwr31QDYXh5DAKUaJe9f72CGcjYwSl95PZoZwDjNKzD19gRGkhVdAU+LokSvM
IDaLgKpET+smdhCbTUBDYtm080wgNj9Q/MW1vawgtqhAiMSMy5OZIXoFJU7OfMICYosImEqc
+N8JNpNZwEjid0sf2EnCAuES3/88BurlAIrbSzzYWgZRIi/RvHU22BghIHvH9xa2CYyCs5BM
nYXQMQtJxwJG5lWMwrmJmTnp5UZ6qUWZycXF+Xl6xambGIGhenDLb9UdjHfOiRxilOZgURLn
td66x19IID2xJDU7NbUgtSi+qDQntfgQIxMHp1QDI8dnLqFJi37oX+w+O9/7Q0F/8X63ypKn
XLGSZsK3WPhnXn5S3er9Rv9Vq9zj91x1vBVtxp5HZX59+/iYLdEg/snL3OnTMltfslemOZ5r
fPjz+JqD3tphWRmXf6o1KYtYxQi8Vztfo6im8Hm252MzlZS/vUw3v31Ov1i398zFtU87o+/5
igZfV2Ipzkg01GIuKk4EALpWE/MjAgAA
Cc: Erlang Questions <erlang-questi...@erlang.org>
Subject: Re: [erlang-questions] Port Driver. erl_drv_thread_join and
ErlDrvTid reuse.
X-BeenThere: erlang-questi...@erlang.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: General Erlang/OTP discussions <erlang-questions.erlang.org>
List-Unsubscribe: <http://erlang.org/mailman/options/erlang-questions>,
<mailto:erlang-questions-requ...@erlang.org?subject=unsubscribe>
List-Archive: <http://erlang.org/pipermail/erlang-questions>
List-Post: <mailto:erlang-questi...@erlang.org>
List-Help: <mailto:erlang-questions-requ...@erlang.org?subject=help>
List-Subscribe: <http://erlang.org/mailman/listinfo/erlang-questions>,
<mailto:erlang-questions-requ...@erlang.org?subject=subscribe>
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="windows-1252"; Format="flowed"
Errors-To: erlang-questions-boun...@erlang.org
Sender: erlang-questions-boun...@erlang.org
>>From time to time erl_drv_thread_join returns error EDEADLK=3D35, i.e. th=
e current thread (scheduler thread) tries to join itself.
>
> According to the documentation =93A Thread identifier may be reused very =
quickly after a thread has terminated. Therefore, if a thread corresponding=
to one of the involved thread identifiers has terminated since the thread =
identifier was saved, the result of erl_drv_equal_tids() might not give the=
expected result.=94
>
> I suppose that thread terminates earlier then erl_drv_thread_join call ha=
ppens, so ErlDrvTid is already reused.
>
This reuse will not cause problems for erl_drv_thread_join() as long as =
it is used correctly (a tid wont be reused until after the thread has =
been joined). erl_drv_thread_join() will also refuse to join threads not =
created by erl_drv_thread_create(), and would in case the scheduler =
thread tried to join itself fail with EINVAL.
> So the question is how to use erl_drv_thread_join properly and how to gua=
rantee that the saved ErlDrvTid value points to the same data that was retu=
rned from erl_drv_thread_create?
>
It is important that the thread is joined once and *only* once. Are you =
sure that you don't do two calls to erl_drv_thread_join() for the same =
thread?
Regards,
Rickard
-- =
Rickard Green, Erlang/OTP, Ericsson AB.
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions