Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Reto Baettig <baettig@scs.ch>
To: axp-list@redhat.com
Subject: Re: [Fwd: Alpha SMP problem]
Date: Wed, 08 Nov 2000 08:51:37 -0800	[thread overview]
Message-ID: <3A098499.3F8987CF@scs.ch> (raw)
In-Reply-To: 3A09B857.79DB9BB2@appnet.com

[-- Attachment #1: Type: text/plain, Size: 2139 bytes --]

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

[-- Attachment #2: malloctest_2.tgz --]
[-- Type: application/octet-stream, Size: 1083 bytes --]

  reply	other threads:[~2000-11-08 21:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-08 13:51 [Fwd: Alpha SMP problem] Reto Baettig
2000-11-08 20:32 ` Jeff Sturm
2000-11-08 16:51   ` Reto Baettig [this message]
2000-11-08 22:44     ` Jeff Sturm
2000-11-09  6:11       ` should I use 8 DIMMs for UP2000 M/B when I put two 667Mhz processors? Jeong Hwan Park
2000-11-09  1:31         ` W Bauske
2000-11-09  6:31           ` Jeong Hwan Park
2000-11-09  2:09             ` W Bauske
2000-11-09  7:04               ` Greg Lindahl
2000-11-09  3:21                 ` W Bauske
2000-11-09 15:36                   ` Greg Lindahl
2000-11-09 20:49                     ` W Bauske
2000-11-10  3:10                       ` Greg Lindahl
2000-11-09 23:36                         ` W Bauske
2000-11-09 20:18         ` Tom Heibel
2000-11-09 20:25           ` Rich Payne
2000-11-09 20:24         ` Tom Heibel
2000-11-08 22:15   ` [Fwd: Alpha SMP problem] Richard Henderson
2000-11-08 17:39     ` Reto Baettig
2000-11-08 23:53     ` Jeff Sturm
2000-11-09  1:56       ` Richard Henderson
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox