Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose: To lcarn Linux/Unix programming using system calls for process creation and manipulation. Use only basic process related system calls: fork, exec (any of 6

image text in transcribed
image text in transcribed
Purpose: To lcarn Linux/Unix programming using system calls for process creation and manipulation. Use only basic process related system calls: fork, exec (any of 6 versions), exit, and wait, plus usleep, kill and getpid (check man pages for details of these system calls), and file system calls from Labl. Also, you may use printf for displaying on screen and scanf for input from keyboard. Assignment: Write six C programs AA.c, BB.c, CC.c, DD.c,EE.c and FF.c, with executable codes in files AA, BB, CC, DD, EE and FF, that function as follows: 1. First you run your code AA (as a process, call it Process A). Process A creates three processes a process with code BB (call it Process B), a process with code CC (call it Process C1) and another process with code CC (call it Cla). Then Process A waits one of its children to terminate. 2. Process B creates file "XYZ.txt" and writes the last 200 characters from file test.file (the one from Labl into it, and then it terminates. 3. Process Cl enters infinite loop (include "usleep(100)" in cach loop iteration). 4. Process Cla enters infinite loop. 5. When process A continues, it creates three new processes: a process with code DD, call it Process D, a process with code CC, call it Process C2, and a process with code EE, call it Process E. Then Process A waits for Process D to terminate. 6. Process E reads file XYZ.txt, character by character, and each character is printed as read. Then Process E deletes the file and terminates. 7. Process D creates a process with code CC, call it Process C3, and then Process D waits for 0.5 sec (use system call "usleep) 8. When Process D continues, it creates new process which executes Unix command: ps-u user- name user-name your user name 9. Process D waits for ps process to terminate, then it kills its second child (Process C3) and then t exits. 10. Process A now continues. It kills its remaining three child processes (C, Cla and C2) and sleeps for 0.25 sec. 11. When is awaken, Process A prompts for an arbitrary string of characters and you are to provide it from a keyboard. Then Process A prompts for an arbitrary integer and you are to provide it from a keyboard; For reading a value for an integer above (named say xyzlnteger) use the following C statements: int xyzlnteger scanf("%d", &xyzintegerk. 12. Then, Process A creates new process from code FF (call it Process F). Then Process A terminates. Purpose: To lcarn Linux/Unix programming using system calls for process creation and manipulation. Use only basic process related system calls: fork, exec (any of 6 versions), exit, and wait, plus usleep, kill and getpid (check man pages for details of these system calls), and file system calls from Labl. Also, you may use printf for displaying on screen and scanf for input from keyboard. Assignment: Write six C programs AA.c, BB.c, CC.c, DD.c,EE.c and FF.c, with executable codes in files AA, BB, CC, DD, EE and FF, that function as follows: 1. First you run your code AA (as a process, call it Process A). Process A creates three processes a process with code BB (call it Process B), a process with code CC (call it Process C1) and another process with code CC (call it Cla). Then Process A waits one of its children to terminate. 2. Process B creates file "XYZ.txt" and writes the last 200 characters from file test.file (the one from Labl into it, and then it terminates. 3. Process Cl enters infinite loop (include "usleep(100)" in cach loop iteration). 4. Process Cla enters infinite loop. 5. When process A continues, it creates three new processes: a process with code DD, call it Process D, a process with code CC, call it Process C2, and a process with code EE, call it Process E. Then Process A waits for Process D to terminate. 6. Process E reads file XYZ.txt, character by character, and each character is printed as read. Then Process E deletes the file and terminates. 7. Process D creates a process with code CC, call it Process C3, and then Process D waits for 0.5 sec (use system call "usleep) 8. When Process D continues, it creates new process which executes Unix command: ps-u user- name user-name your user name 9. Process D waits for ps process to terminate, then it kills its second child (Process C3) and then t exits. 10. Process A now continues. It kills its remaining three child processes (C, Cla and C2) and sleeps for 0.25 sec. 11. When is awaken, Process A prompts for an arbitrary string of characters and you are to provide it from a keyboard. Then Process A prompts for an arbitrary integer and you are to provide it from a keyboard; For reading a value for an integer above (named say xyzlnteger) use the following C statements: int xyzlnteger scanf("%d", &xyzintegerk. 12. Then, Process A creates new process from code FF (call it Process F). Then Process A terminates

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

12-5 How will MIS help my career?

Answered: 1 week ago