السلام عليكــم ورحمـة الله وبركاتــه
ارجو مساعدنكم بحل ال assinment،،
المطلوب حل السؤالين التاليين بلغة سي بلس بلس
Part-1
Write a program (C++) that has a parent and child process. The parent process forks the child, then calls a function which prints out the parent and child process id (with a tag indicating which pid is which). The parent then waits for the child to complete.
Once forked, the child calls a function which sleeps for a period of seconds where the sleep time in seconds is (command line) input as a startup parameter to the program (data sharing between parent and child). Once the child wakes up, it prints out the date (do not use system to do the date, but find the underlying OS system call) and terminates. The printout should delineate between parent and child.
Part-2
The PI value is computed as the series is:
PI = 4.0 - 4.0/3 + 4.0/5 – 4.0/7 + 4.0/9
Write a (C++) program using the fork() system call that that compute the PI value in the child process. The accuracy number to compute the value will be inputted from user .
The PI output 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 value. 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.
