Question: CENG328 Operating Systems - Spring 2017 Labwork 3 Mar 06 08, 2017 Question 1 A Write a C program which takes two arguments from command

CENG328 Operating Systems - Spring 2017 Labwork 3 Mar 06 08, 2017 Question 1

A Write a C program which takes two arguments from command line: one filename and one number of items. Your program must check if correct number of arguments are supplied and terminate if not. Your program must create three child processes in the following order: first child process creates the mentioned file and fills it with the specified number of random integers (0-1000), one number per line. The second child process executes sort command to sort the numbers in this file on screen. The third child process must find the minimum and maximum numbers in this file. Between each child process, parent must wait for termination of former process to create the new process. Sample Run $ ./question1 nums.txt 15 [PARENT] Creating first process... [CHILD1] Creating nums.txt with 15 integers... [PARENT] Creating second process... [CHILD2] Executing sort command... 56 133 147 . . . [PARENT] Executing third process... [CHILD3] Min: 56, max: 839 [PARENT] Done. B Write a C program which takes two arguments from command line: one filename and one number of items. Your program must check if correct number of arguments are supplied and terminate if not. Your program must create three child processes in the following order: first child process creates the mentioned file and fills it with the specified number of random characters (a-z). The second child process executes zip command to make a compressed copy of your file. The third child process must execute ls command to display both files. Between each child process, parent must wait for termination of former process to create the new process. Sample Run $ ./question1 chars 40000 [PARENT] Creating first process... [CHILD1] Writing 40000 random chars to chars.txt... [PARENT] Creating second process... [CHILD2] Executing zip command... adding: chars.txt (deflated 37%) [PARENT] Creating third process... [CHILD3] Executing ls command... 40000 chars.txt 25492 chars.zip [PARENT] Done.

C Write a C program which takes four command line arguments: two file names and two number of elements. Your program must check if correct number of arguments are supplied and terminate if not. Your main process must create three processes: The first and second processes must open / create files by the given names and fill them with the given number of random integers (one integer per line) and terminate. The third process must execute sort command with necessary arguments so that it numerically sorts both files and display the combined result on screen. Before creating the third child process, main process must wait for the other two child processes to end. Sample Run $ ./question1 randfile1.txt randfile2.txt 40 70 [PARENT] Creating first process... [PARENT] Creating second process... [CHILD1] Writing 40 random integers to randfile1.txt... (78 32 56...) [CHILD2] Writing 70 random integers to randfile2.txt... (46 88 45...) [PARENT] Creating third process... [CHILD3] Sorting both files: 32 45 46 56 78 88 ... [PARENT] Done.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!