SP - Lab 3 Worksheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Department of Computer Science and Information Technology

Systems Programming: SSWT ZC327


Lab Work Sheet Assignment 3
1. Objective:
At the end of this lab session students will be:
a) Understand and Implement Process Creation
b) Change File Permissions Programmatically
c) Replace a Process Image
d) Combine System Calls in a Practical Program
e) Understand Process Synchronization
f) Develop Problem-Solving Skills
2. Pre-requisite:
a) Basic Understanding of C Programming
b) System Call Concepts
3. Important Instructions:
a. Experiment should be conducted on the BITS Nuvepro Cloud Lab only.
Experiments conducted outside this lab platform will not be evaluated.
b. Instructions on how to access and use the Nuvepro Cloud lab platform is
available in the document “Steps to access cloud based CS/IS virtual lab.pdf”.
c. While using the Nuvepro Cloud, save all your work in Persistent folder which
is available on the desktop.
d. The completed worksheet should be uploaded in Taxila (elearn) portal only.
Last date for uploading the document is <date>.
e. This worksheet/lab activity carries < weightage in percentage> of weightage
f. Refrain from copying or sharing documents with others. Any evidence of such
practice will attract severe penalty.
g. Any queries related to LAB Activities should be sent to <lead instructor email
id > and [email protected]
4. Lab Exercise:
Problem Statement:
Write a C program that demonstrates the use of the fork, chmod, exec, and wait
system calls to perform a series of operations involving process creation, file
permission modification, executing a new program, and process synchronization. The

1
new program (.out file) to be executed and the file whose permissions are to be
changed must be specified as a command line arguments.

Steps to be followed:

File Creation: Open a text editor and create a new file, for example, Lab3_BITS_ID.c.

Include Necessary Headers: Add the required header files for system calls and standard
functions.

Write the Main Function: Start by defining the main function using command line arguments.

Process Creation: Use the fork system call to create a child process.

Change File Permissions: In the child process, use the chmod system call to change the
permissions of a file.

Executing a New Program in the Child Process: Use an exec family function (e.g., execl)
to run a new program.

Process Synchronization: Wait for the Child Process in the Parent Process using the wait
system call to wait for the child process to complete.

Error Handling: Do the necessary validations like command line argument


specification and system calls error handling.

Task to be performed:

Task 1: Source File Creation in vi or vim editor.

Task 2: Develop C program using the steps mentioned above.

Task 3: Save the program and quit from the vi or vim editor.

Task 4: Compile the program using

cc -o <Obj_Filename> <Src_Filename>

Task 5: Run the program using the command

./<Obj_Filename> <filename whose permissions are to be changed > <Pathname of the file to be executed>

Task 6: Test the program for user executables and system command executables.

2
Submission guidelines:

The student should be instructed to take a snapshot of the screen to showcase their usage
of the Nuvepro lab portal along with the required codebase and other needed information.
A sample is shown below:
Table of Inspection Report:

Set of Tasks Inspection Report


Task 1
Task 2 Screenshot of the source file created
Task 3
Task 4 Screenshot of the compilation report
Task 5 Screenshot of the execution report
Task 6 Screenshot of the test for user executables and system command

******

You might also like