Semester-Project Multithreading: Instructions
Semester-Project Multithreading: Instructions
Semester-Project
Multithreading
Instructions
• Plagiarism will result to ZERO marks in whole project for both parties.
• All the submissions (code and report) must be submitted on Slate. No submission
outside Slate will be accepted or entertained.
• In case of any query just leave an email at [email protected] and will try my
level best to entertain your query as soon as possible.
• Maximum 2 members in a group are allowed.
• Be Prepared for the individual demo after project submission.
Assigned Date: April 02nd , 2019 Due Date: April 21st , 2019
Marks Distribution
Total Marks – 30
• Demo Individual 5 Marks
• Code Demo 15 Marks Phase 1 (5) Phase 2 (5)
• Runtime Code Modification 5 Marks
• Report 5 Marks
The parent thread will create the worker threads, passing each worker the location that it
must check in the Sudoku grid. This step will require passing several parameters to each
thread. The easiest approach is to create a data structure using a struct. For example, a
structure to pass the row and column where a thread must begin validating would appear
as follows:
/* structure for passing data to threads */ typedef struct
{
int row;
int column;
} parameters;
Pthreads program will create worker threads using a strategy similar to that shown
below:
parameters *data = (parameters *) malloc(sizeof(parameters));
data->row = 1;
data->column = 1;
/* Now create the thread passing it data as a parameter */
The data pointer will be passed to either the pthread create() (Pthreads) function, which in
turn will pass it as a parameter to the function that is to run as a separate thread.
Each worker thread is assigned the task of determining the validity of a particular region
of the Sudoku puzzle. Once a worker has performed this check, it must pass its results back
to the parent. The i th index in this array corresponds to the ith worker thread. If a worker
sets its corresponding value to 1, it is indicating that its region of the Sudoku puzzle is
valid. A value of 0 would indicate otherwise. When all worker threads have completed,
the parent thread checks each entry in the result array to determine if the Sudoku puzzle
is valid.
Conditions:
• Threads are not allowed to update other part of the array. Other threads can only
read the value from the array. (For example, an i thread can only write on ith
location, for other parts it can only read from the array. )
• When thread returns values to Main thread and it is writing on array, no other
thread can read array value.
• Thread will return the value to Main thread.
• Here you must synchronize the task and apply mutex lock.
• Thread can cancel the other thread, if found an invalid entry. But you must set
the criteria for cancelation. ( For which thread you need to set accept cancelation
or not. )
• Storing the invalid entries and their indexes.
NUCES, Islamabad Operating System Fall, 2019
Other Instructions:
Use any appropriate and efficient synchronization technique for this project. The code
must be properly commented and this carries marks too. Group details should appear on
separate page in report and you should also mention the exact contribution of each group
member to the project. Again, all this carries marks.
Do test your program thoroughly and make sure it gives correct output before submitting.
References should be relative and not absolute and to crosscheck you can just copy your
executable to some other machine to see if it works there as well. If your program does not
compile or works, you do not get credit. You will not be allowed to debug your program
during the demo. We will not entertain excuses like “it was working before but we don’t
know what happened to it now!!!”