Clients for Tswitch
Clients for the F06 Assignment
This is a very simple test program which just creates
and runs two threads. The output is:
Returned 5 and 7. Bye, now.
// This function is run by each of two threads. They just loop and print,
// then exit with their first arg.
int fred(int i, char *msg)
int origi = i;
printf("%s %d\n", msg, i);
th_id_t t1, t2;
int a, b;
// Start the threads.
if((t1 = th_fork()) == ARE_CHILD) fred(5,"First");
if((t2 = th_fork()) == ARE_CHILD) fred(7,"Second");
// Wait for them to finsh.
a = th_wait(t1);
b = th_wait(t2);
// Say what happened.
printf("Returned %d and %d. Bye, now.\n", a, b);