ux Program homework need help, dont give the wrong answer please, show the result and output plz. also if you have definition that will help a lot

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

C linux Program homework need help, dont give the wrong answer please, show the result and output plz.

also if you have definition that will help a lot

 

 

Instructions
Write a C program that will start a race between 4 processes to get a number from the user inputs. The user will enter
4 numbers (1 to 4), the process that receives the first number (1) will be the winner, and in the first place, processes
afterward will get second, third, and fourth place depending on the number they get from the user.
The program will start using the fork() System call to create 4 child processes; each process created is identified by a
number from 1 to 4. This number indicates its creation sequence. For example, the first child process created gets ID =
1 and so on.
After all child processes are created, each process will request a number from the user. Each process will print the
number it got from the user and also print its ID number. The parent does not participate in the race and waits for all
child processes to finish before it exits.
Notice: The numbers and the order of processes on your computer might be different. This is an example of a Race
condition. Processes race for input and output resources.
Sample Output
vocstartsoft:~/environment/test 5 gcc ForkGame.c -o FG
vocstartsoft:~/environment/test $
vocstartsoft:~/environment/test $
vocstartsoft:~/environment/test $ ./FG
Enter nubmers for processes to race for >>>>
I am a process with pid 11790 and I am process number 3 in the race.
I am a process with pid 11791 and I am process number 4 in the race.
I am a process with pid 11789 and I am process number 2 in the race.
I am a process with pid 11788 and I am process number 1 in the race.
1
I am a process with pid 11790 and I am process number 3 in the race and I am in the 1st place.
2
I am a process with pid 11791 and I am process number 4 in the race and I am in the 2nd place.
I am a process with pid 11789 and I am process number 2 in the race and I am in the 3rd place.
4
I am a process with pid 11788 and I am process number 1 in the race and I am in the 4th place.
vocstartsoft:~/environment/test $I
Transcribed Image Text:Instructions Write a C program that will start a race between 4 processes to get a number from the user inputs. The user will enter 4 numbers (1 to 4), the process that receives the first number (1) will be the winner, and in the first place, processes afterward will get second, third, and fourth place depending on the number they get from the user. The program will start using the fork() System call to create 4 child processes; each process created is identified by a number from 1 to 4. This number indicates its creation sequence. For example, the first child process created gets ID = 1 and so on. After all child processes are created, each process will request a number from the user. Each process will print the number it got from the user and also print its ID number. The parent does not participate in the race and waits for all child processes to finish before it exits. Notice: The numbers and the order of processes on your computer might be different. This is an example of a Race condition. Processes race for input and output resources. Sample Output vocstartsoft:~/environment/test 5 gcc ForkGame.c -o FG vocstartsoft:~/environment/test $ vocstartsoft:~/environment/test $ vocstartsoft:~/environment/test $ ./FG Enter nubmers for processes to race for >>>> I am a process with pid 11790 and I am process number 3 in the race. I am a process with pid 11791 and I am process number 4 in the race. I am a process with pid 11789 and I am process number 2 in the race. I am a process with pid 11788 and I am process number 1 in the race. 1 I am a process with pid 11790 and I am process number 3 in the race and I am in the 1st place. 2 I am a process with pid 11791 and I am process number 4 in the race and I am in the 2nd place. I am a process with pid 11789 and I am process number 2 in the race and I am in the 3rd place. 4 I am a process with pid 11788 and I am process number 1 in the race and I am in the 4th place. vocstartsoft:~/environment/test $I
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning