
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>

#define N 1

/* Test code for 12.c and 14.c */

int fd;

void do_action(int cpu)
{
	char buf[10];

	run_on_cpu(cpu);
	
	if (cpu == 0) write(fd, buf, sizeof(buf));
	else read(fd, buf, sizeof(buf));
}

main()
{
	int status, retval, pid;

	fd = open("foo", O_RDWR);
	assert(fd >= 0);

	if((pid=fork()) == 0) 
		do_action(0);	
	else {
		do_action(1);
		retval = wait(&status);
		if(retval != pid) printf("wait returned: %d\n", retval);
	}
}
	
