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

#define N 10000

/* Test code for 5.c */

int fd;

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

	run_on_cpu(cpu);
	for(i = 0; i < N; i++)
		write(fd, buf, sizeof(buf));
}

main()
{
	int status, retval, pid;
	char buf[100];

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

    /* Try running parent and child
     * on the same CPU as well as
     * on different CPU's.
     */

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