Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a program in C, there needs to be two for-loops. Every UNIX process is guaranteed to have a unique numeric identifier called the

image text in transcribed

Please write a program in C, there needs to be two for-loops.

Every UNIX process is guaranteed to have a unique numeric identifier called the process ID. The process ID or PID is always a nonnegative integer. The only way under UNIX (with a few exceptions) to create a new process is when an existing process calls the fork function. You can find details about fork and wait in the manual pages (man fork) The ideal solution is composed of a single parent process which simultaneously opens up multiple child processes which performs their function once and then quits. Code to close up the child processes should be at the end of the program Also introduced in this lab are command-line options for UNIX programs. By convention, your program should start with the following two variables: int main(int arge, char argv //arge is an integer of the number of arguments //argv "argument vector" is a character array of the arguments Write a simple program that uses the fork function. Sample code: man wait& man getpid Program requirements: 1. The program should take either filenames or wildcards (for example) as input 2. Create as many child processes as there are files on the command line. Child processes should run simultaneously, not wait on each other. There are MANY ways that your code r sequential processing. To test for parallel code, make your child process wait for 1 second. If you have n files and your program is delayed 1 second, your code is parallel. If it is delayed n seconds, it is not parallel not wait on each other. There are MANY ways that your code may be liited to 3. For each child process, print the file name and the process ID of the child proces 4. The parent process should wait for all the children to finish then show the output from: system(ps omand to debug r): This statement placed in other locations of your program may be a helpfulo your code 5% Extra Credit: instead of Canvas, submit your assignment via https (MUST be private, invite swirsz) I will use Github's last modified date as the submission date. Make sure to put your full name in the header of your file if you submit it by Github. ://education.github.com/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions