Sale!

Operating Systems Laboratory (CS39002) Assignment 1 solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (10 votes)

1a. Write a program in C/C++ under the Linux environment that would perform the following:
 Create five processes A, B, C, D, and E.
 The processes A, B and C will each generate 50 pseudo-random non zero integers. ‐
The processes A and B will forward the numbers in sorted order to process D
(through pipes). The process C will forward the numbers in sorted order to process E
(through pipes).
 The process D will read the numbers received from the two pipes in sorted order,
merge them, and forward the numbers in sorted order to process E (through pipes).
 The process E will read the numbers received from the two pipes in sorted order,
merge them, and print all the numbers in sorted order.
Use pipes for inter process communication. ‐
1b. Write a program in C/C++ under the Linux environment that would perform the following:
o In a loop, read a character string containing the name of an executable program with
command line arguments, if any. ‐
o Fork a child process, and execute the program.
o The loop will terminate if the command “quit” is entered.
Submission Guidelines:
 Create two separate programs for the two assignments, and name them
Ass1__1a and Ass1__1b (replace by your
group number).
 You must show the running version of the program(s) to your assigned TA during the lab
hours.
Things to study:
 fork() system call
 pipe() system call
 execlp() / execvp() / execve() system call
Evaluation Guidelines:
Total marks for this assignment are 50. While entering marks, the partwise break up
should also be entered according to the marking guidelines given below. There is a
separate component for individual assessment, based on how the student answers
questions.
Sl Items for 1a Marks
(a) Process creation 8
(b) Pseudo random number generation 5
(c) Pipe creation 8
(d) Reading from pipe 5
(e) Writing to pipe 5
(f) Merging of numbers 4
Total 35
Items for 1b Marks
(g) Reading of arguments in a loop 5
(h) Spawning the new processes using fork 5
(i) Passing the command line arguments to the new process 5
Total 15