0% found this document useful (0 votes)
11 views5 pages

OS LAB MidTerm V6 Question Paper

The document is a mid-term exam paper for the Operating Systems Lab at the University of Management and Technology. It includes instructions for candidates, a list of questions covering Linux commands, process management, syntax error correction, and programming tasks related to child processes and Bash scripting. The exam is scheduled for December 11, 2024, and consists of five questions with a total of 40 marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

OS LAB MidTerm V6 Question Paper

The document is a mid-term exam paper for the Operating Systems Lab at the University of Management and Technology. It includes instructions for candidates, a list of questions covering Linux commands, process management, syntax error correction, and programming tasks related to child processes and Bash scripting. The exam is scheduled for December 11, 2024, and consists of five questions with a total of 40 marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

UNIVERSITY OF MANAGEMENT AND TECHNOLOGY

MID Term Exam

Student Name: ___________________ Student ID: _______________________

Paper: Operating Systems Lab Student Signature: _______________________

Instructor’s Name: M. Rizwan___________ Section: _V6___________________

Date: _11 – Dec - 2024____ Time Allowed: 60 minutes____________

Instructions for Candidates:


1) Mention your Name and ID.
2) Just focus on your own paper, discussion is strictly prohibited.
3) Read questions carefully before solving.
4) Solve all the questions on the provided space in your question paper.
5) Understanding of the questions is part of examination. So, none of your queries will be entertained in
the examinations hall.
6) If there is any ambiguity in the paper, benefit will be given to the students.

Question Q1 Q2 Q3 Q4 Q5 Total
Marks 5 10 5 10 10 40
Obtained

DO NOT OPEN UNTIL YOU ARE TOLD TO DO SO

1
Question No. 01: Write Linux basic commands to fulfill following operations.

[5 marks] CLO 1, CLO 2

1. List the content of the current directory or a specified directory.

2. Display the information about the system.

3. Create a new directory ‘MID’ in ‘/home/sysadmin/Desktop’.

4. Force to remove the directory dir which you have created with a name of
MID.

5. Move OSV2.cpp to root directory and make it executable.

Question No. 02: What will be the output of the following code and give its

reason.

[10 marks] CLO 2, CLO 3

2
1 int main ()
2 {
3 int pid1 = fork ();
4 int pid2 = fork();
5 int pid3 = fork();
6 if (pid1 < 0 | | pid2 < 0 | | pid3 < 0)
7 {
8 cout << “FORK FAILED… ” << endl;
9 }
10 cout << “Hello, From Process” << getpid() << endl;
11 return 0;
12 }

1. Write the output of the given code, and also explain the reason of the output as well.
2. Draw the process tree for the above code and provide the values of pid1 and pid2.

3. How many at max orphan children will be present in the system mentioned above? How
can we avoid their existence.

Question No. 03: There are exactly 6 syntax errors present in the following
code. Find them and provide the correct syntax in the table below.
[5 marks] CLO 2

1 int main (){


2 char buffer [100];
3 int fd = open (O_CREAT|O_RDWR, 0777);
4 int n =read(buffer[fd]);
5 int pid = fork(-1);
6 if(fork(pid) > 0){
7 cout << "Hello, I am parent process and my id : "<<getpid()<<endl;
8 cout << "Let's show the text from the file on screen."<<endl;
9 write(buffer);

3
10 int cpid = wait(pid,NULL,0);
11 cout << "\nMy Child has completed his execution and his id is: "<< cpid << endl;
12 }
13 if(pid == 0){
14 execl(NULL ,"cal");
15 }
16 return 0;
17 }

Error Line no. Correction


no.

Question 04: Write the following programs [5 + 5 marks] CLO 2, CLO 3

A. Write a program to demonstrate how a child process become orphaned. Display the
process Id’s of both parent and child.

B. Write a program to create three child processes, where the first child terminates early
(demonstrating a zombie process), the second child runs independently, and the third
child waits for a specific event. Display the process IDs of all processes, and identify
which process becomes a zombie.

4
A: B:

Question 05: Write a Bash Script: [10 marks] CLO 1, CLO 2


Write a Bash script to generate the Fibonacci series up to a given number. The script should
take input from the user (the number of terms to generate) and display the Fibonacci series.

You might also like