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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education