0% found this document useful (0 votes)
10 views2 pages

Spring 2025 - CS604 - 1

Uploaded by

ibrar
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)
10 views2 pages

Spring 2025 - CS604 - 1

Uploaded by

ibrar
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/ 2

Operating Systems (CS604) Total marks = 20

Assignment # 01 Deadline Date

Spring 2025 May 14, 2025

Please carefully read the following instructions before attempting the


assignment.

RULES FOR MARKING


It should be clear that your assignment would not get any credit if:
 The assignment is submitted after the due date.
 The submitted assignment does not open, or the file is corrupted.
 Strict action will be taken if the submitted solution is copied from any other student or
the internet.

You should consult the recommended books to clarify your concepts, as handouts are
insufficient.

ASSIGNMENT SUBMISSION
You are supposed to submit your assignment in Doc or Docx format only.
Any other formats, such as scanned images, PDF, zip, rar, ppt, and BMP, will not be accepted.
You are required to send the Screenshot and C code of Question No. 1 in the same Word file.

ASSIGNMENT NO. 1 COVERS LECTURE # 1-10

OBJECTIVE
The objective of this assignment is to provide hands-on experience in the:

 Understanding fork() system call for creating new processes.


 Learning how the wait() system call allows process synchronization.
 Exploring the use of execlp() to replace a process image.
 Observing zombie processes and understand how process termination is handled by
the parent.

NOTE
No assignment will be accepted after the due date via email in any case (whether it is due to load
shedding or internet malfunctioning, etc.). Hence, refrain from uploading assignments within
the last hour of the deadline. It is recommended that the solution file be uploaded at least two
days before its closing date.

Please consult your instructor before the deadline if you find any mistake or confusion in the
assignment (Question statement). After the deadline, no queries will be entertained in this
regard.

For any query, feel free to email me at:


[email protected]
Question No 01 20 marks
Part a)

Write a program for ubuntu and compile it in GNU Compiler which creates 3 child processes
from a parent process using fork(). Each child process should:
 Print its process ID (PID) and parent process ID (PPID)
 Execute a simple calculation (e.g., factorial of a small number)
 Print your Student ID and Student Name in a line.
 Print the result of factorial before exiting
The parent process should wait for all children to complete and print a summary message.

Part b)

Write a C/C++ program where:


 The parent process creates two child processes using fork().
 Each child process prints its PID and PPID.
 Each child calls exit(0) after printing a message.
 The parent process uses wait() to wait for both children.
 Print a confirmation from the parent after both children terminate.

Now Modify the above program so that:


 One of the children (e.g., the first one) uses execlp() to execute the ls command.
 Handle failure of execlp() using appropriate error messages.
 Remove wait() from the parent process and use a sleep delay to inspect zombie
behavior using commands like ps.

Note: Add all the code and output screenshot in the word file only. No other file will be
accepted.

You might also like