0% found this document useful (0 votes)
6 views

Spring 2025_CS604P_1 (1)

This document outlines the instructions for Assignment #01 in the Operating Systems (Practical) course, due on May 12, 2025. It details the submission rules, including file format requirements and penalties for late or plagiarized submissions, as well as the objectives and tasks for the assignment, which involve creating a C program with two threads for file operations and string manipulation. Students must follow specific guidelines for naming files and folders, and are encouraged to consult their instructor for any clarifications before the deadline.

Uploaded by

grafixxsea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Spring 2025_CS604P_1 (1)

This document outlines the instructions for Assignment #01 in the Operating Systems (Practical) course, due on May 12, 2025. It details the submission rules, including file format requirements and penalties for late or plagiarized submissions, as well as the objectives and tasks for the assignment, which involve creating a C program with two threads for file operations and string manipulation. Students must follow specific guidelines for naming files and folders, and are encouraged to consult their instructor for any clarifications before the deadline.

Uploaded by

grafixxsea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Operating Systems (Practical) (CS604P) Total marks = 20

Assignment # 01 Deadline Date

Spring 2025 May 12, 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 Labs 1 to Labs 4

OBJECTIVE
The objective of this assignment is to provide hands-on experience in the:
• UNIX/Linux standard files and kernel’s mechanism for file access
• Demonstration of file operations in Linux using system calls.
• Thread creation, synchronization and termination

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

Write a C program that creates two threads (T1 and T2) with the following functionality:

Thread T1:
1. Reads integers from a file named input.txt (create this file with 5 integers, one per line).
2. Calculates the sum of these integers.
3. Writes the sum to a new file output.txt.
4. Prints the sum to the console.

Thread T2:
1. Takes a string input from the user (e.g., "HelloOOS"). [Student needs to input their
Full Name here].
2. Replaces all vowels (a, e, i, o, u) with * (e.g., "H*ll***S").
3. Prints the modified string to the console and appends it to output.txt.

Requirements:
• Use pthread_create() and pthread_join().
• Students Should create a Folder with name as your Student ID and all the files input.txt,
output.txt, program.c and program.o should be placed in that folder. Also, input student
name as modified string input to replace the vowels. For example, input string should
be as “Shakeel” and modified string written in the output file and in program screen
shot should be “Sh*k**l”
• Zero Marks will be awarded for using incorrect Student ID and Student Name in the
Folder name and Program code.

Sample Screenshots for Input/Outputs files and Program Execution:

Sample Screenshot for Input.txt


Sample Screenshot for Output.txt
Now you input the modified string as “HelloOOs” and that is added in the output.txt file as
modified string replacing the vowels with * and also displaying the sum of numbers on the
previous line.

Sample Screenshot for GCC File Execution:

```

How to compile and run:


1. Save this code to a file named `BC02200418.c` using your student ID as file name.
2. Compile with GCC: `gcc BC02200418.c -o BC02200418 -lpthread
3. Run the program: ‘./BC02200418’

Program behavior:
1. The main program creates `input.txt` with numbers 10, 20, 30, 40, 50 (if it doesn't exist)
2. Thread T1:
- Reads numbers from `input.txt`
- Calculates the sum (150)
- Writes the sum to `output.txt`
- Prints the sum to console
3. Thread T2:
- Asks for user input (e.g., "HelloOS") or Student Name
- Replaces vowels with * (e.g., "H*ll**S")
- Prints the modified string to console
- Appends the modified string to `output.txt`

The “output.txt” file will contain both the sum from T1 and the modified string from T2.

Note: If you have installed the Virtual Box, you can take the Screenshot. Go to the view
menu and click on Take Screenshot

See the following link for the installation of Virtual Box and Ubuntu (Linux) on your system.
https://vulms.vu.edu.pk/CourseResources/OpenFile.aspx?File=tutorial_for_installing_virtual
box_and_ubuntu.mp4

See the following link installing gcc and compiling and running your first program in Linux.
https://vulms.vu.edu.pk/CourseResources/OpenFile.aspx?File=How%20to%20install%20gcc
%20on%20Ubuntu%20and%20compile%20a%20C%20program.mp4

You might also like