CSCI 332 - Spring 2025 - PA1
CSCI 332 - Spring 2025 - PA1
Dimitrios Zorbas
CSCI 332 – Operating Systems Prof. Jurn Gyu Park
Spring 2025 Prof. Zohaib Latif
Prof. Syed Muhammad Umair Arif
Programming Assignment 1
A. (50 pts) After reading the instructions on the next page, develop a C program which can
be used for a simple automatic grading tool (AGT) of submitted C files.
In this task, we assume that the submitted files had been compiled, and the executable
files (e.g., A B C D) were saved to a directory (e.g., exdir). And, when the executable
files are executed, the corresponding output files (e.g., A.txt B.txt C.txt D.txt) are saved
to another directory (e.g., txtdir), and we assume that each .txt file will have only one
integer result, (e.g., 55, if the assignment program is the sum from 1 to 10).
Requirements:
a. Each executable file in the directory (e.g., A B C D in exdir directory) MUST run
on each separate child. (The execution order of the files does not matter)
b. After running the AGT program, the program MUST have the corresponding
result files in a specific directory (e.g., A.txt B.txt C.txt D.txt in txtdir directory)
c. After reading the .txt files (‘where’ is dependent on your design), and grading
(assuming only 100 or 0 pts), save the corresponding file paths and scores to the
name of scores.txt file
b. After executing your AGT program (i.e., each separate child executes each
executable file), the corresponding result files will be saved to a specific
directory, which can be a user input directory or pre-defined directory, and each
file will have the correct value of 55 or other wrong values.
c. Create a final scores.txt file that will have like below (55 will get 100 pts, if not 0
pt , assuming B’s answer is not correct):
cat ./scores.txt (The file path will be different from students’ laptop path)
File path of A.txt 100
File path of B.txt 0
File path of C.txt 100
File path of D.txt 100
B. (50 pts) Write a C program which creates a number of threads equal to the number of
your laptop CPU cores in the system* in order to accelerate the vector add program (C[i]
= A[i] + B[i], assuming the array size is N)**.
a. After creating threads of the number of CPU cores (P), each thread will add
exactly the same number of array indexes. Print out your number of CPU cores.
(The array size of N will be entered by user input).
b. The main process must wait for the threads before it terminates.
e. The results MUST be correct. (e.g., if A[i] = 1 and B[i] = 2, all the C[i] MUST be 3).
In order to verify your array results, add verifyArray() in the main process.
*you can get access to the CPU information by reading the file /proc/cpuinfo
** you must find a way to divide the workload evenly between the threads (i.e., evenly assign
the same number of array indexes to each thread).
Instructions
✔ Submit your assignment to Moodle as two C files (*.c) with name format
YourFirstname_YourSurname_A.c and YourFirstname_YourSurname_B.c respectively.
✔ Your C files must contain detailed comments about the rationale you have followed. Files
without comments will be discarded. Points will be deducted in case of inadequate
explanations.
✔ The final date and time of submission is given on Moodle. No extensions will be given.
✔ Make sure your program runs smoothly on a Linux environment and compiles without errors
using the GNU C compiler (gcc >13).
✔ You can get up to TBD% of your final grade.
✔ Make sure your C code follows a correct indentation style (see
https://en.wikipedia.org/wiki/Indentation_style). Points will be deducted if the indentation is bad.
✗ The assignment is to be done individually. Do not share solutions with your colleagues, do
not ask your colleagues to send you their code, and do not directly copy code from the Internet
especially when you don’t understand it. All potential cases of misconduct will be reported to the
school. Repeated misconduct means failure of the course.
✗ According to the code of conduct, making public this assignment on the Internet (e.g.,
forums, chegg.com, bartleby.com etc.) results in a category C misconduct, automatic fail of the
course, and loss of the stipend.
✗ Do not submit code in any programming language other than C.
✗ Do not use non-POSIX functions.