#include #include int value = 5;int main(){pid t pid;pidfork();if (pid == 0) { /* child process */value += 15;return 0;}else if (pid > 0) { /* parent process /wait (NULL);printf ("PARENT:...


144<br>Chapter 3 Processes<br>#include <sys/types.h><br>#include <stdio.h><br>#include <unistd.h><br>int value = 5;<br>int main()<br>{<br>pid t pid;<br>pid<br>fork();<br>if (pid == 0) { /* child process */<br>value += 15;<br>return 0;<br>}<br>else if (pid > 0) { /* parent process /<br>wait (NULL);<br>printf (

Extracted text: 144 Chapter 3 Processes #include #include #include int value = 5; int main() { pid t pid; pid fork(); if (pid == 0) { /* child process */ value += 15; return 0; } else if (pid > 0) { /* parent process / wait (NULL); printf ("PARENT: value = %a",value); /* LINE A / return 0; } Figure 3.30 What output will be at Line A? Write a C program using the fork() system call that generates the Fibonacci sequence in the child process. The number of the sequence will be provided in the command line. For example, if 5 is provided, the first five nunbers in the Fibonacci sequence will be output by the child process. Because the parent and child processes have their own copies of the data, it will be necessary for the child to output the sequence. Have the parent invoke the wait() call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a non-negative number is passed on the command line. 3.16 Repeat the preceding exercise, this time using the CreateProcess() function in the Win32 API. In this instance, you will need to specify a separate program to be invoked from CreateProcess (). It is this separate program that will run as a child process outputting the Fibonacci sequence. Perform necessary error checking to ensure that a non-negative number is passed on the command line. 3.17 Modify the date server shown in Figure 3.19 so that it delivers random jokes rather than the current date. Allow the jokes to contain multiple lines. The date client shown in Figure 3.20 can be used to read the multi-line jokes returned by the joke server. 3.18 An echo server echoes back whatever it receives from a client. For example, if a client sends the server the string Hello there! the server will respond with the exact data it received from the client-that is,
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here