CS计算机代考程序代写 #include

#include
#include
#include
#include

#define MAX_COUNT 5

void Process1(void); /* Process1 declaration */
void Process2(void); /* Process2 declaration */

int main()
{

pid_t ret_val;
pid_t pid;
int num = 8;

ret_val = fork();

if (ret_val == 0) {
num = num + 10;
Process2();
printf(“I am Process2, pid %i: num = %i\n\n”, getpid(), num);
printf(“\n***Process2 is done ***\n\n”);
}
else {
Process1();
printf(“I am Process1, pid %i: num = %i\n\n”, getpid(), num);
printf(“\n***Process1 is done***\n\n”);
}
return (0);
}

void Process2()
{
int i;
pid_t pid;

pid = getpid();

for (i = 1; i <= MAX_COUNT; i++) { usleep (1000); printf (" This line is from Process2, value = %d, pid = %d\n", i, pid); } } void Process1() { int i; pid_t pid; pid = getpid(); for(i=1; i <= MAX_COUNT; i++) { usleep (1000); printf("This line is from Process1, value = %d, pid = %d\n", i + 6, pid); } }