public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep
@ 2011-12-31  3:32 Kang Kai
  2012-01-09  1:58 ` Kang Kai
  2012-01-09  5:19 ` Caspar Zhang
  0 siblings, 2 replies; 7+ messages in thread
From: Kang Kai @ 2011-12-31  3:32 UTC (permalink / raw)
  To: ltp-list

Child process sends the last signal before parent process enter the
final sleep sometimes, so sleep in parent will not be interrupted then
the case fails.
Sleep 1 second before send the last signal in child to make sure parent
enter the final sleep.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
index 96daf72..37993c8 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
@@ -82,6 +82,9 @@ int main()
 		sleep(1);  // give parent time to set up handler
 		for (i=0; i<MAXMSG+1; i++) {
         		mq_timedsend(gqueue, msgptr, strlen(msgptr), 1, &ts);
+            /* make sure parent enter the final sleep */
+			if (i == MAXMSG) 
+                sleep(1);
 			/* send signal to parent each time message is sent */
 			kill(getppid(), SIGABRT);
 		}
@@ -138,4 +141,4 @@ int main()
 	}
 
 	return PTS_UNRESOLVED;
-}
\ No newline at end of file
+}
-- 
1.7.5.4


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep
  2011-12-31  3:32 [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep Kang Kai
@ 2012-01-09  1:58 ` Kang Kai
  2012-01-09  5:19 ` Caspar Zhang
  1 sibling, 0 replies; 7+ messages in thread
From: Kang Kai @ 2012-01-09  1:58 UTC (permalink / raw)
  To: Kang Kai; +Cc: ltp-list

On 2011年12月31日 11:32, Kang Kai wrote:
> Child process sends the last signal before parent process enter the
> final sleep sometimes, so sleep in parent will not be interrupted then
> the case fails.
> Sleep 1 second before send the last signal in child to make sure parent
> enter the final sleep.
>
> Signed-off-by: Kang Kai<kai.kang@windriver.com>
> ---
>   .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
>   1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> index 96daf72..37993c8 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> @@ -82,6 +82,9 @@ int main()
>   		sleep(1);  // give parent time to set up handler
>   		for (i=0; i<MAXMSG+1; i++) {
>           		mq_timedsend(gqueue, msgptr, strlen(msgptr), 1,&ts);
> +            /* make sure parent enter the final sleep */
> +			if (i == MAXMSG)
> +                sleep(1);
>   			/* send signal to parent each time message is sent */
>   			kill(getppid(), SIGABRT);
>   		}
> @@ -138,4 +141,4 @@ int main()
>   	}
>
>   	return PTS_UNRESOLVED;
> -}
> \ No newline at end of file
> +}

Could anyone give some comments about this patch?
Thanks a lot!

Regards,
Kai

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep
  2011-12-31  3:32 [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep Kang Kai
  2012-01-09  1:58 ` Kang Kai
@ 2012-01-09  5:19 ` Caspar Zhang
  2012-01-10  2:14   ` Kang Kai
  1 sibling, 1 reply; 7+ messages in thread
From: Caspar Zhang @ 2012-01-09  5:19 UTC (permalink / raw)
  To: Kang Kai; +Cc: ltp-list

On 2011年12月31日 11:32, Kang Kai wrote:
> Child process sends the last signal before parent process enter the
> final sleep sometimes, so sleep in parent will not be interrupted then
> the case fails.
> Sleep 1 second before send the last signal in child to make sure parent
> enter the final sleep.
> 
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
>  .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> index 96daf72..37993c8 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> @@ -82,6 +82,9 @@ int main()
>  		sleep(1);  // give parent time to set up handler
>  		for (i=0; i<MAXMSG+1; i++) {
>          		mq_timedsend(gqueue, msgptr, strlen(msgptr), 1, &ts);
> +            /* make sure parent enter the final sleep */
> +			if (i == MAXMSG) 
> +                sleep(1);

You only make sure parent enters to the last iteration before child
does, but same issue still might occur in previous iterations.

Also, please use hard tab instead of 4/8 spaces for indentation. patch
style-guide could be found at: doc/style-guide.txt

Thanks,
Caspar

>  			/* send signal to parent each time message is sent */
>  			kill(getppid(), SIGABRT);
>  		}
> @@ -138,4 +141,4 @@ int main()
>  	}
>  
>  	return PTS_UNRESOLVED;
> -}
> \ No newline at end of file
> +}


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep
  2012-01-09  5:19 ` Caspar Zhang
@ 2012-01-10  2:14   ` Kang Kai
  0 siblings, 0 replies; 7+ messages in thread
From: Kang Kai @ 2012-01-10  2:14 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: ltp-list

On 2012年01月09日 13:19, Caspar Zhang wrote:

Hi Caspar,

> On 2011年12月31日 11:32, Kang Kai wrote:
>> Child process sends the last signal before parent process enter the
>> final sleep sometimes, so sleep in parent will not be interrupted then
>> the case fails.
>> Sleep 1 second before send the last signal in child to make sure parent
>> enter the final sleep.
>>
>> Signed-off-by: Kang Kai<kai.kang@windriver.com>
>> ---
>>   .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
>>   1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> index 96daf72..37993c8 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> @@ -82,6 +82,9 @@ int main()
>>   		sleep(1);  // give parent time to set up handler
>>   		for (i=0; i<MAXMSG+1; i++) {
>>           		mq_timedsend(gqueue, msgptr, strlen(msgptr), 1,&ts);
>> +            /* make sure parent enter the final sleep */
>> +			if (i == MAXMSG)
>> +                sleep(1);
> You only make sure parent enters to the last iteration before child
> does, but same issue still might occur in previous iterations.
It needn't to care the sleep in parent iteration, because at last 
mq_timedsend() will make child block when the message queue is full.
Then the in parent iteration, sleep(3) will return 0 then quit the 
iteration. After mq_receive() child will be unblocked.
In my test, at this point the child is scheduled and call kill() before 
call last sleep(3) in parent, so the test fails.
This patch could make parent call last sleep() before child call kill().

>
> Also, please use hard tab instead of 4/8 spaces for indentation. patch
> style-guide could be found at: doc/style-guide.txt

Sorry about the indentation.

Regards,
Kai

>
> Thanks,
> Caspar
>
>>   			/* send signal to parent each time message is sent */
>>   			kill(getppid(), SIGABRT);
>>   		}
>> @@ -138,4 +141,4 @@ int main()
>>   	}
>>
>>   	return PTS_UNRESOLVED;
>> -}
>> \ No newline at end of file
>> +}


------------------------------------------------------------------------------
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] 7+ messages in thread

* [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep
  2012-02-06  9:52 [LTP] V2: " Kang Kai
@ 2012-02-06  9:52 ` Kang Kai
  2012-02-07  7:33   ` Wanlong Gao
  2012-02-16 18:41   ` Cyril Hrubis
  0 siblings, 2 replies; 7+ messages in thread
From: Kang Kai @ 2012-02-06  9:52 UTC (permalink / raw)
  To: ltp-list, caspar

Child process sends the last signal before parent process enter the
final sleep sometimes, so sleep in parent will not be interrupted then
the case fails.
Sleep 1 second before send the last signal in child to make sure parent
enter the final sleep.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
index 96daf72..77fe2e0 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
@@ -82,6 +82,9 @@ int main()
 		sleep(1);  // give parent time to set up handler
 		for (i=0; i<MAXMSG+1; i++) {
         		mq_timedsend(gqueue, msgptr, strlen(msgptr), 1, &ts);
+			/* make sure parent enter the final sleep */
+			if (i == MAXMSG)
+				sleep(1);
 			/* send signal to parent each time message is sent */
 			kill(getppid(), SIGABRT);
 		}
@@ -138,4 +141,4 @@ int main()
 	}
 
 	return PTS_UNRESOLVED;
-}
\ No newline at end of file
+}
-- 
1.7.5.4


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
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-dev2
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep
  2012-02-06  9:52 ` [LTP] [PATCH] " Kang Kai
@ 2012-02-07  7:33   ` Wanlong Gao
  2012-02-16 18:41   ` Cyril Hrubis
  1 sibling, 0 replies; 7+ messages in thread
From: Wanlong Gao @ 2012-02-07  7:33 UTC (permalink / raw)
  To: Kang Kai; +Cc: ltp-list

On 02/06/2012 05:52 PM, Kang Kai wrote:

> Child process sends the last signal before parent process enter the
> final sleep sometimes, so sleep in parent will not be interrupted then
> the case fails.
> Sleep 1 second before send the last signal in child to make sure parent
> enter the final sleep.


So many sleep() makes me confused.
Anyway, your patch makes sense. so,

Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

> 
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
>  .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> index 96daf72..77fe2e0 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> @@ -82,6 +82,9 @@ int main()
>  		sleep(1);  // give parent time to set up handler
>  		for (i=0; i<MAXMSG+1; i++) {
>          		mq_timedsend(gqueue, msgptr, strlen(msgptr), 1, &ts);
> +			/* make sure parent enter the final sleep */
> +			if (i == MAXMSG)
> +				sleep(1);
>  			/* send signal to parent each time message is sent */
>  			kill(getppid(), SIGABRT);
>  		}
> @@ -138,4 +141,4 @@ int main()
>  	}
>  
>  	return PTS_UNRESOLVED;
> -}
> \ No newline at end of file
> +}



------------------------------------------------------------------------------
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] 7+ messages in thread

* Re: [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep
  2012-02-06  9:52 ` [LTP] [PATCH] " Kang Kai
  2012-02-07  7:33   ` Wanlong Gao
@ 2012-02-16 18:41   ` Cyril Hrubis
  1 sibling, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2012-02-16 18:41 UTC (permalink / raw)
  To: Kang Kai; +Cc: ltp-list

Hi!
> Child process sends the last signal before parent process enter the
> final sleep sometimes, so sleep in parent will not be interrupted then
> the case fails.
> Sleep 1 second before send the last signal in child to make sure parent
> enter the final sleep.
> 
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
>  .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> index 96daf72..77fe2e0 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
> @@ -82,6 +82,9 @@ int main()
>  		sleep(1);  // give parent time to set up handler
>  		for (i=0; i<MAXMSG+1; i++) {
>          		mq_timedsend(gqueue, msgptr, strlen(msgptr), 1, &ts);
> +			/* make sure parent enter the final sleep */
> +			if (i == MAXMSG)
> +				sleep(1);
>  			/* send signal to parent each time message is sent */
>  			kill(getppid(), SIGABRT);
>  		}
> @@ -138,4 +141,4 @@ int main()
>  	}
>  
>  	return PTS_UNRESOLVED;
> -}
> \ No newline at end of file
> +}

Okay, I think I see the possible race condition between the mq_recieve()
in parent and the mq_timedsend() in the the child.

Commited, thanks (and sorry for the delay).

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2012-02-16 18:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-31  3:32 [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep Kang Kai
2012-01-09  1:58 ` Kang Kai
2012-01-09  5:19 ` Caspar Zhang
2012-01-10  2:14   ` Kang Kai
  -- strict thread matches above, loose matches on Subject: below --
2012-02-06  9:52 [LTP] V2: " Kang Kai
2012-02-06  9:52 ` [LTP] [PATCH] " Kang Kai
2012-02-07  7:33   ` Wanlong Gao
2012-02-16 18:41   ` Cyril Hrubis

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