All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH]pthread_barrier_wait/2-1.c: using mutext to protect global variable used by muti-thread
@ 2011-12-20  9:53 Wei.Yang
  2011-12-20  9:53 ` [LTP] [PATCH 1/1] using mutex to protect the global variable accessed by muti-threads Wei.Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Wei.Yang @ 2011-12-20  9:53 UTC (permalink / raw)
  To: ltp-list; +Cc: wei.yang


Hi all

   This patch are for POSIX test suite. using mutext to protect global
variable accessed by muti-threads. This ensures that it is a atomic operation, 
increasing global variable.

Thanks and Regards

wei

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH 1/1] using mutex to protect the global variable accessed by muti-threads
  2011-12-20  9:53 [LTP] [PATCH]pthread_barrier_wait/2-1.c: using mutext to protect global variable used by muti-thread Wei.Yang
@ 2011-12-20  9:53 ` Wei.Yang
  2011-12-21 14:02   ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Wei.Yang @ 2011-12-20  9:53 UTC (permalink / raw)
  To: ltp-list; +Cc: wei.yang

From: Wei Yang <Wei.Yang@windriver.com>


Signed-off-by: Wei Yang <Wei.Yang@windriver.com>
---
 .../interfaces/pthread_barrier_wait/2-1.c          |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_wait/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_wait/2-1.c
index ec6b7f0..5b9ceea 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_wait/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_wait/2-1.c
@@ -38,6 +38,7 @@
 static pthread_barrier_t barrier;
 static int serial;
 static int normal_rt;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static void* fn_chld(void *arg)
 {
@@ -59,7 +60,9 @@ static void* fn_chld(void *arg)
 	}
 	else
 	{
+		pthread_mutex_lock(&mutex);
 		normal_rt++;
+		pthread_mutex_unlock(&mutex);
 	}
 
 	pthread_exit(0);
@@ -122,4 +125,4 @@ int main()
 
 	printf("\nTest PASSED\n");
 	return PTS_PASS;
-}
\ No newline at end of file
+}
-- 
1.7.0.2


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH 1/1] using mutex to protect the global variable accessed by muti-threads
  2011-12-20  9:53 ` [LTP] [PATCH 1/1] using mutex to protect the global variable accessed by muti-threads Wei.Yang
@ 2011-12-21 14:02   ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2011-12-21 14:02 UTC (permalink / raw)
  To: Wei.Yang; +Cc: ltp-list

Hi!
> Signed-off-by: Wei Yang <Wei.Yang@windriver.com>
> ---
>  .../interfaces/pthread_barrier_wait/2-1.c          |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 

Commited, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-21 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20  9:53 [LTP] [PATCH]pthread_barrier_wait/2-1.c: using mutext to protect global variable used by muti-thread Wei.Yang
2011-12-20  9:53 ` [LTP] [PATCH 1/1] using mutex to protect the global variable accessed by muti-threads Wei.Yang
2011-12-21 14:02   ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.