* [LTP] [PATCH] mmstress: make shared global variables volatile
@ 2012-03-13 10:32 Jan Stancek
2012-03-13 12:09 ` Wanlong Gao
0 siblings, 1 reply; 2+ messages in thread
From: Jan Stancek @ 2012-03-13 10:32 UTC (permalink / raw)
To: ltp-list; +Cc: Jeffrey Burke
[-- Attachment #1: Type: text/plain, Size: 514 bytes --]
Synchronization of threads depends on shared global variable.
With gcc version 4.6.2 this test spins forever on:
while (wait_thread)
sched_yield();
Make global shared variables volatile, so each thread
sees current value.
See also:
Bug 36081 - gcc optimizations and threads (pthread)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36081
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/mem/mtest05/mmstress.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
[-- Attachment #2: 0001-mmstress-make-shared-global-variables-volatile.patch --]
[-- Type: text/x-patch, Size: 1116 bytes --]
diff --git a/testcases/kernel/mem/mtest05/mmstress.c b/testcases/kernel/mem/mtest05/mmstress.c
index 8a0c6f6..a8d4e7d 100644
--- a/testcases/kernel/mem/mtest05/mmstress.c
+++ b/testcases/kernel/mem/mtest05/mmstress.c
@@ -140,8 +140,8 @@ typedef struct { /* structure returned by map_and_thread() */
caddr_t mapaddr; /* address at which the file is mapped */
} RETINFO_t;
-static int wait_thread = 0; /* used to wake up sleeping threads */
-static int thread_begin = 0; /* used to coordinate threads */
+static volatile int wait_thread = 0; /* used to wake up sleeping threads */
+static volatile int thread_begin = 0; /* used to coordinate threads */
static int verbose_print = FALSE; /* print more test information */
static int pages_num = NUMPAGES; /* number of pages to use for tests */
@@ -989,4 +989,4 @@ main(int argc, /* number of command line parameters */
tst_resm(TPASS, "Test Passed");
}
exit(global_rc);
-}
\ No newline at end of file
+}
[-- Attachment #3: Type: text/plain, Size: 381 bytes --]
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
[-- Attachment #4: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] mmstress: make shared global variables volatile
2012-03-13 10:32 [LTP] [PATCH] mmstress: make shared global variables volatile Jan Stancek
@ 2012-03-13 12:09 ` Wanlong Gao
0 siblings, 0 replies; 2+ messages in thread
From: Wanlong Gao @ 2012-03-13 12:09 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list, Jeffrey Burke
On 03/13/2012 06:32 PM, Jan Stancek wrote:
>
> Synchronization of threads depends on shared global variable.
> With gcc version 4.6.2 this test spins forever on:
> while (wait_thread)
> sched_yield();
>
> Make global shared variables volatile, so each thread
> sees current value.
>
> See also:
> Bug 36081 - gcc optimizations and threads (pthread)
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36081
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
> testcases/kernel/mem/mtest05/mmstress.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
pushed, thanks Jan.
Wanlong Gao
>
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
>
>
>
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-13 12:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-13 10:32 [LTP] [PATCH] mmstress: make shared global variables volatile Jan Stancek
2012-03-13 12:09 ` Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox