Operating Systems Laboratory (CS39002) Assignment 1 Solved

30.00 $

Category:

Description

5/5 - (1 vote)

Assignment 1: Familiarization with Unix system calls on process creation and management

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:

  • In a loop, read a character string containing the name of an executable program with command line arguments, if any. ‐
  • 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_<groupno>_1a and Ass1_<groupno>_1b (replace <groupno> 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 25. While entering marks, the partwise break up should also be entered according to the marking guidelines given below.

 

Items for 1a Marks
Process creation 8
Pseudo random number generation 5
Pipe creation 8
Reading from pipe 5
Writing to pipe 5
Merging of numbers 4
Total 20
Items for 1b Marks
Reading of arguments in a loop 5
Spawning the new processes using fork 5
Passing the command line arguments to the new process 5
Total 15

 

  • Assignment-4.zip