SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 4 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 18 Nov 2017 My Price 10.00

modify the code to make parent process print out the even number

Can someone help me with my homework? It's due Sunday at 11pm

WBIT 3500 Architecture and Operating System

 

Assignment 8

Multi-Process and Multi-Thread Programming

 

 


Fork a Process

The following code can fork a child process. Both parent and child process can all print out 50 lines. Please modify the code to make parent process print out the even number of lines among the 50 lines, and the child process will only print out the odd number of lines. In your output message, please specify if the process is a parent process or a child process. And also output the process id.Please submit your source code, and the screenshot of the running result.

 

#include  <stdio.h>

#include  <string.h>

#include  <sys/types.h>

 

#define   MAX_COUNT  50

#define   BUF_SIZE   100

 

void  main(void)

{

pid_tpid;

inti;

charbuf[BUF_SIZE];

 

fork();

pid = getpid();

for (i = 1; i<= MAX_COUNT; i++) {

sprintf(buf, "This line is from pid %d, value = %d\n", pid, i);

write(1, buf, strlen(buf));

     }

}

 

Submission:

1.      Please submit your C language source code;

2.      Please submit at least two snapshots to show your compiling and running results under Cygwin.

 

Grading Rubric

Criteria

Points

Source code without compiling error

30

Screenshotsclearly show all the required information

20

 

Testing:

Even number output for parent process

10

Odd number output for child process

10

Specify parent process with correct Process ID

15

Specify child process with correct Process ID

15

 

 

 





 

 

 

 

Attachments:

Answers

(5)
Status NEW Posted 18 Nov 2017 07:11 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)