Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Use Model Create Similar Program Program Write List Eight Strings Char Words Time Good Men Q35563842

Write a C program. Thank you.Use this as a model to create a similar program. The program you write will have a list of eight strings char* words]now,I am the parent, and my pid is 3780 (P) writing now to the shared memory I am the child, and my pid is 3781 (C) read this f

Use this as a model to create a similar program. The program you write will have a list of eight strings char* words]”now”, “is”, “the”, “time”, “for”, “all”, “good”, “men”; nt numwords- 8; It’s OK to define these as global variables. Here’s what the program should do: the main0 should create a 32-byte shared-memory block the parent should fork a child process the parent should attach to the shared-memory block .in a for-loop, the parent should write each word from the array to the shared-memory block and then usleep(500000) and then read a string from the shared memory and print it out parent should wait for the child to exit the child should attach to the shared-memory block in a for-loop, the child should read a string from the shared memory, then convert it to upper case, and then write the converted string back to the shared memory and then usleep(1000000) * the child then exits and the parent exits Here’s the output you might get (your pid values will be different): I am the parent, and my pid is 3780 (P) writing ‘now’ to the shared memory I am the child, and my pid is 3781 (C) read this from the shared memorynow’ (C) write this to the shared memory NOW (P) read ‘NOW’ from the shared memory (P) writing ‘is’ to the shared memory (C) read this from the shared memory: ‘is’ (C) write this to the shared memory: ‘IS’ (P) read ‘IS’ from the shared memory (P) writing ‘the’ to the shared memory (C) read this from the shared memory: ‘the’ (C) write this to the shared memory: ‘THE” (P) read ‘THE’ from the shared memory (P) writing ‘time’ to the shared memor (C) read this from the shared memory: ‘time’ (C) write this to the shared memory: ‘TIME (P) read ‘TIME’ from the shared memory (P) writing ‘for’ to the shared memory (C) read this from the shared memory:’for’ (C) write this to the shared memory: ‘FOR’ (P) read ‘FOR’ from the shared memory (P) writing ‘all’ to the shared memory (C) read this from the shared memory “al1′ (C) write this to the shared memory “ALL’ (P) read ‘ALL’ from the shared memory (P) writing “good’ to the shared memory (C) read this from the shared memory: good’ (c) write this to the shared memory: GOOD (P) read “GOOD’ from the shared memory (P) writing men’ to the shared memory (C) read this from the shared memory: men (C) write this to the shared memory: MEN (P) read ‘MEN’ from the shared memory You won’t necessarily get this output. The next programming assignment will explore the reason why you won’t necessarily get this output. Show transcribed image text Use this as a model to create a similar program. The program you write will have a list of eight strings char* words]”now”, “is”, “the”, “time”, “for”, “all”, “good”, “men”; nt numwords- 8; It’s OK to define these as global variables. Here’s what the program should do: the main0 should create a 32-byte shared-memory block the parent should fork a child process the parent should attach to the shared-memory block .in a for-loop, the parent should write each word from the array to the shared-memory block and then usleep(500000) and then read a string from the shared memory and print it out parent should wait for the child to exit the child should attach to the shared-memory block in a for-loop, the child should read a string from the shared memory, then convert it to upper case, and then write the converted string back to the shared memory and then usleep(1000000) * the child then exits and the parent exits Here’s the output you might get (your pid values will be different):
I am the parent, and my pid is 3780 (P) writing ‘now’ to the shared memory I am the child, and my pid is 3781 (C) read this from the shared memorynow’ (C) write this to the shared memory NOW (P) read ‘NOW’ from the shared memory (P) writing ‘is’ to the shared memory (C) read this from the shared memory: ‘is’ (C) write this to the shared memory: ‘IS’ (P) read ‘IS’ from the shared memory (P) writing ‘the’ to the shared memory (C) read this from the shared memory: ‘the’ (C) write this to the shared memory: ‘THE” (P) read ‘THE’ from the shared memory (P) writing ‘time’ to the shared memor (C) read this from the shared memory: ‘time’ (C) write this to the shared memory: ‘TIME (P) read ‘TIME’ from the shared memory (P) writing ‘for’ to the shared memory (C) read this from the shared memory:’for’ (C) write this to the shared memory: ‘FOR’ (P) read ‘FOR’ from the shared memory (P) writing ‘all’ to the shared memory (C) read this from the shared memory “al1′ (C) write this to the shared memory “ALL’ (P) read ‘ALL’ from the shared memory (P) writing “good’ to the shared memory (C) read this from the shared memory: good’ (c) write this to the shared memory: GOOD (P) read “GOOD’ from the shared memory (P) writing men’ to the shared memory (C) read this from the shared memory: men (C) write this to the shared memory: MEN (P) read ‘MEN’ from the shared memory You won’t necessarily get this output. The next programming assignment will explore the reason why you won’t necessarily get this output.

Leave a Reply

Your email address will not be published. Required fields are marked *