Skip to contentSkip to conversation

mq_timedsend/5-1: make parent has chance to sleep

PATCH In review Kang Kai 2 participants 4 messages Dec 31, 2011 – Jan 10, 2012

lore
Share & tools
lore

Kang Kai

author
#0 lore raw

PATCH 1/1 mq_timedsend/5-1: make parent has chance to sleep

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.

---
 .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +4 -1
index 96daf72..37993c8 100644
@@ -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
+}
Signature · 13 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#1 lore raw
Quoted 26 lines · Kang Kai

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.

---
  .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +3 -0
index 96daf72..37993c8 100644
@@ -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);
  		}

testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c int main() · line 144

Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +1 -1
@@ -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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
In reply to Kang Kai
Quoted 16 lines · Kang Kai

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.

---
 .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +0 -0
index 96daf72..37993c8 100644

testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c int main() · line 87

Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +3 -0
@@ -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

testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c int main() · line 144

Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +1 -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
+}

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#3 lore raw

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

Hi Caspar,

Quoted 12 lines · Kang Kai
Quoted 11 lines

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.

---
  .../conformance/interfaces/mq_timedsend/5-1.c      |    5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)
Quoted 13 lines

testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c int main() · line 87

Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +3 -0
index 96daf72..37993c8 100644
@@ -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().

Quoted 3 lines

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

Quoted 10 lines

Thanks,
Caspar

Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +0 -0
  			/* send signal to parent each time message is sent */
  			kill(getppid(), SIGABRT);
  		}
@@ -138,4 +141,4 @@ int main()
  	}
 
Quoted 4 lines

testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c int main() · line 144

Quoted 4 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +1 -1
  	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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list