From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.redhat.com (mail.redhat.com [199.183.24.239]) by listman.redhat.com (Postfix) with ESMTP id 0181C2F0AD for ; Wed, 8 Nov 2000 16:55:43 -0500 (EST) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id eA8LtXH03335 for axp-list@listman.redhat.com; Wed, 8 Nov 2000 16:55:33 -0500 Received: from k2.llnl.gov (k2.llnl.gov [134.9.1.1]) by mail.redhat.com (8.11.0/8.8.7) with ESMTP id eA8LtXD03331 for ; Wed, 8 Nov 2000 16:55:33 -0500 Received: from scs.ch (IDENT:baettig@fork.llnl.gov [134.9.11.114]) by k2.llnl.gov (8.9.3/8.9.3/LLNL-Sep98) with ESMTP id NAA20301 for ; Wed, 8 Nov 2000 13:55:24 -0800 (PST) Message-ID: <3A098499.3F8987CF@scs.ch> Date: Wed, 08 Nov 2000 08:51:37 -0800 From: Reto Baettig X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.17ext3 i686) X-Accept-Language: en MIME-Version: 1.0 To: axp-list@redhat.com Subject: Re: [Fwd: Alpha SMP problem] References: <3A095A5D.A5C7900D@scs.ch> <3A09B857.79DB9BB2@appnet.com> Content-Type: multipart/mixed; boundary="------------1AD8F87840F06BEECBDC8EDE" X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0beta4 Precedence: bulk Reply-To: axp-list@redhat.com List-Id: Linux and Red Hat on Alpha processors This is a multi-part message in MIME format. --------------1AD8F87840F06BEECBDC8EDE Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Jeff, I changed the test program as you suggested but unfortunately it does not help... I also changed the program so that we no longer need mb's. The fact that the problem only occurs when I start the program twice on a system should convince you that it's not a broken program... I attached the changed version of the program. Please try it when you find some time. More ideas? Reto Jeff Sturm wrote: > > Reto Baettig wrote: > > The strange thing is that a single instance of the program runs just > > fine. When I start the program a second time, I get segfaults and/or > > stuck threads. > > Actually I would expect stuck threads: > > mem.delete = 1; > > while (mem.delete) > Th_Delay(1); > > mem.delete must be declared `volatile' to prevent that from looping forever. > However as long you didn't compile with optimizations you can probably get by. > > Also, consider that the "Free" thread is writing: > > mem->buf = NULL; > mem->delete = 0; > // ...loop... > > while the "DoTest" thread is reading: > > // ...loop.... > mb(); > assert(mem.buf == NULL); > assert(mem.delete == 0); > > The writes to mem->buf and mem->delete may be reordered by the compiler and/or > CPU. Despite the memory barrier, DoTest can see a non-NULL mem.buf even after > it sees (mem.delete == 0). > > To get guaranteed sequential behavior, you need to use `volatile' and a few more > membar's, e.g.: > > mem->buf = NULL; > mb(); > mem->delete = 0; > mb(); > > and: > > mem.buf = malloc(len); > assert(mem.buf != NULL); > mb(); > > th_req[Th_Num]++; > > mem.delete = 1; > mb(); > > or save yourself the trouble and use a mutex instead. > > Honestly I didn't try your program, but I wouldn't consider blaming the kernel > or glibc as long as your code is incorrect. > > -- > Jeff Sturm > jeff.sturm@commerceone.com > > _______________________________________________ > Axp-list mailing list > Axp-list@redhat.com > https://listman.redhat.com/mailman/listinfo/axp-list --------------1AD8F87840F06BEECBDC8EDE Content-Type: application/octet-stream; name="malloctest_2.tgz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="malloctest_2.tgz" H4sIAA7hADoAA+1WW2/bNhTOq/grTtM2k5yLJcdJh6Qp5tZp+5D4IXWBAVtgyNJxTFQXj6TT eIX/+w5JyZaTdH3KLgA/BJJ47vwOD+PL+AtOeIZbT4gwCsPj4+5WGEZHrzpHjbdFdBxuha86 YXh42I06x2TfOTyKtiB8yqJqzKWKBcDWOEal+M137X6k/5/i3fuL3odPcAb7/avz88HwqjcY sov+SprN1FRgnDI27F19OB9qYR5nWZkolAoYo+8TeOFX2oCxJMO4OGGeyGF/0tBAUgpk//Z+ HTax7uVB8lQ5fjD/NOsdM/+dw+5RNyJ5dEgXgJv/fwLtFoMWNE8BrbXoCuWsLCQfZ3hCC1XC W8sA+BUVv8hEHiTToHL4yKUqxeLEi6L9kP5CeEcXh8LU88RYG3hG87PWCMzLW0whH/8kK3Wb MfacF0k2TxFeS5VmfHwwfdOULWRbLWYoHxHzHO9JleDFzaasuso2hbGUKNR9Wd6msApzLWfP U/oXWSAMPl+Ohh+vznv9TxCFjLVboPelplxCLES8APooSgUzUSokOlMYLyCfK7yjooErSEu0 FgWSkjjV/mNsOmASzyXCV6SQCGWRUdRCoaDekJpPKB2C3Yg07lLxLKPIIMscqZbiBkpRGS5I W85mmBqCs7K48agNajoS+Mdvje1c063+LdyD5SljmmLaMHmKeaIgx3xEn/CNebdlFlMyhGRK I9MazyenDSFVCSlmqPCULWs3indb8pQNp6M+ZvHCN1YqYBSuSqB7dxtn2p9e5ODZrwN1O5KY UGWpatMNEp42NXOr8lMFL0FrA6KisvLAgDJQOYnyaWODzxcXm88dGyugYm2NkC9G1QkZJebk +mDkLZjMi2SvWsTihqoHj3m1sYK7U0pGjPv3/Hfu6mw2gvYNNJOeN6PjqSb+9qYHoBCl+L3Y DnREz8M7rvz9iIr0lqs63wtE3xaTN4msO9WijzP/vjDIKQjzvk6pV35kqzAL8J+R0f4b27tA p111y2TeNKOuP7QhwURX5duTEawstXu9oHZpMlYim5CkYb29etAue7+OLs4H4Edhp9vSj8Bu vV8OaQ58fZCBChjMHyWA3hRR8j+RepNhoesj2UEjoWclG1U97L9meg8qroMd8jB73eCQ4utz KOIiLXM/aNni9COottGm31T9ES0C2IXIkLXObW9en6IYruxt5Nf6Z7Y4y3A1tnbf17u7pp+b G4t0jHXH1roAvt/XKtljJktPt4VOKstjXhgiDOF6irkuakJXjc8NpcBfN24UWu7uWoYe8mrb uGbWcBZwe8xZXRdEYAOsa9JzXm2xHqBLQ6BsD02Gk2pybF1nf1PVKsDLLoftPajY5dcmgbda npkbZdnIaMbTVipQzUWhD/DS/bJ1cHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBw+A/gL47BMjsA KAAA --------------1AD8F87840F06BEECBDC8EDE--