Exemple #1
0
void do_parent(void)
{
  int s;
  char buf[2];
  struct sigaction sa;
  subtest = 2;

  sa.sa_handler = dead_child;
  sa.sa_flags = 0;
  if (sigaction(SIGCHLD, &sa, NULL) == -1) err(1);

  s = 0;
  close(pipefdp[1]);
  close(pipefdc[0]);

  while(s < SWAPS) {
	/* Wait for child to wake me up */	
	read(pipefdp[0], buf, 1);

	do_calcs();

	/* Wake up child */
	write(pipefdc[1], buf, 1);
	s++;
  }

  while(child_is_dead == 0) { fflush(stdout); } /* Busy wait */

  quit();
}
Exemple #2
0
void do_parent(void)
{
  ucontext_t dummy;
  int s;
  s = 1;

  /* Initialize FPU context and verify it's set to round to nearest. */
  if (fegetround() != FE_TONEAREST) err(10, 1);

  /* Now we change the rounding to something else, and this should be preserved
     between context swaps. */
  if (fesetround(FE_UPWARD) != 0) err(10, 2);

  /* Quick check to make sure that getcontext does not reset the FPU state. */
  getcontext(&dummy);

  if (fegetround() != FE_UPWARD) err(10, 3);

  while(s < SWAPS) {
	do_calcs();
	if (fegetround() != FE_UPWARD) err(10, 4);
	s++;
	if (swapcontext(&ctx[1], &ctx[2]) == -1) err(10, 5);
  }
  /* Returning to main thread through uc_link */
}
Exemple #3
0
void do_child(void)
{
  int s;
  s = 1;

  /* Initialize FPU context and verify it's set to round to nearest. */
  if (fegetround() != FE_TONEAREST) err(9, 1);

  /* Now we change the rounding to something else, and this should be preserved
     between context swaps. */
  if (fesetround(FE_DOWNWARD) != 0) err(9, 2);

  while(s < SWAPS) {
	s++;
	if (swapcontext(&ctx[2], &ctx[1]) == -1) err(9, 2);
	do_calcs();
	if (fegetround() != FE_DOWNWARD) err(9, 4);
  }
  quit();
}
Exemple #4
0
void do_child(void)
{
  char buf[2];
  int s;

  s = 0;
  close(pipefdp[0]);
  close(pipefdc[1]);

  while(s < SWAPS) {
	do_calcs();

	/* Wake up parent */
	write(pipefdp[1], buf, 1);
	
	/* Wait for parent to wake me up */
	read(pipefdc[0], buf, 1); 
	
	s++;
  }
  exit(0);
}