Java Developer Needed
- or -
Post a project like this1507
$20
- Posted:
- Proposals: 3
- Remote
- #2726785
- Awarded
Description
Experience Level: Entry
For this project we are looking for java developer, who will be able to do array sorting using multiple threads and taskPOOl
Part 1—Problem to Parallelize
A better approach would be to have all the tasks be placed into a single pool. When a thread
finishes its current task, it can take another task from this pool to compute. By doing this, the
workload is more evenly spread out across the threads without the need to know how long each task
will take ahead of time.
For this project, you will be implementing a version of this structure where a shared resource
contains a pool of all the tasks to be completed. Threads are able to both take tasks from the pool
as well as add new tasks to it. Once a thread has taken a task, no other thread should be able to take that task.
Quicksort – Sort a given array of integers. Works by choosing a pivot value and partitioning
the array in two where all the points smaller then the pivot value are moved to one side and
all the points greater then the pivot value are moved to the other. Quicksort is then applied
to each sub-array seperetly based on the indexes of where each sub-array begin and ends.
For the Quicksort problem, each Quicksort task will generate two smaller QuickSort tasks. Each of these tasks will then generate two more Quicksort tasks and so on.
So 1 task will become 2 tasks which become 4 tasks which become 8 tasks and so on.
With 3 threads for example, the task pool starts out with a task to perform Quicksort on the entire array. One of the threads will claim this task and the other 2 will wait since there are no tasks remaining. This one thread will then generate two smaller Quicksort tasks based on where you are partitioning the array and add them to the task pool. It should then notify the remaining threads that new tasks have been added which will then claim them and do the same process of partitioning the array and adding new tasks to the task pool.
Because the different threads are accessing the same task pool and the same variables, you will
have to make sure that you implement it in a way that is thread safe. For example, you don’t want
to have the situation occur where two threads access the pool at the same time, claim the same
task, and both perform it.
If a thread checks the shared resource and there are no available tasks, the thread should wait
until all other threads have finished in case more work comes along. Only once all the threads have
finished and there is no work left should all the threads quit. To do this, use the wait/notify/notifyAll
features provided by Java.
The structure of your main thread should look something like:
1. Ask the user if they want to auto-generate the data or read in data from a file.
2. Either generate test data or read data in from file
3. Create task pool.
4. Add the initial tasks to the pool (There may initially be only a single task like in quicksort
where you start with a single array
5. Create the threads.(ask user through input how many threads, he wanna create)
6. Start timer.
7. Wait for all threads to finish.
8. Stop timer and calculate runtime.
9. Print Results to console.
Part 2—Experiment & Write-up
run your program using 1, 2, 3, 5, and 7 threads. Make sure you choose
test data of a reasonable size that showcases the effect for the different number of threads. Plot the
results in a graph where the x-axis is the number of threads and the y-axis is the time it took to
run. Is the data what you were expecting? Why or why not?
In your Job Resume, explain the job description to make sure that you have understood the job.
Time Limit: Project Should be done before 21 Feb
Thanks, Prabh.
Part 1—Problem to Parallelize
A better approach would be to have all the tasks be placed into a single pool. When a thread
finishes its current task, it can take another task from this pool to compute. By doing this, the
workload is more evenly spread out across the threads without the need to know how long each task
will take ahead of time.
For this project, you will be implementing a version of this structure where a shared resource
contains a pool of all the tasks to be completed. Threads are able to both take tasks from the pool
as well as add new tasks to it. Once a thread has taken a task, no other thread should be able to take that task.
Quicksort – Sort a given array of integers. Works by choosing a pivot value and partitioning
the array in two where all the points smaller then the pivot value are moved to one side and
all the points greater then the pivot value are moved to the other. Quicksort is then applied
to each sub-array seperetly based on the indexes of where each sub-array begin and ends.
For the Quicksort problem, each Quicksort task will generate two smaller QuickSort tasks. Each of these tasks will then generate two more Quicksort tasks and so on.
So 1 task will become 2 tasks which become 4 tasks which become 8 tasks and so on.
With 3 threads for example, the task pool starts out with a task to perform Quicksort on the entire array. One of the threads will claim this task and the other 2 will wait since there are no tasks remaining. This one thread will then generate two smaller Quicksort tasks based on where you are partitioning the array and add them to the task pool. It should then notify the remaining threads that new tasks have been added which will then claim them and do the same process of partitioning the array and adding new tasks to the task pool.
Because the different threads are accessing the same task pool and the same variables, you will
have to make sure that you implement it in a way that is thread safe. For example, you don’t want
to have the situation occur where two threads access the pool at the same time, claim the same
task, and both perform it.
If a thread checks the shared resource and there are no available tasks, the thread should wait
until all other threads have finished in case more work comes along. Only once all the threads have
finished and there is no work left should all the threads quit. To do this, use the wait/notify/notifyAll
features provided by Java.
The structure of your main thread should look something like:
1. Ask the user if they want to auto-generate the data or read in data from a file.
2. Either generate test data or read data in from file
3. Create task pool.
4. Add the initial tasks to the pool (There may initially be only a single task like in quicksort
where you start with a single array
5. Create the threads.(ask user through input how many threads, he wanna create)
6. Start timer.
7. Wait for all threads to finish.
8. Stop timer and calculate runtime.
9. Print Results to console.
Part 2—Experiment & Write-up
run your program using 1, 2, 3, 5, and 7 threads. Make sure you choose
test data of a reasonable size that showcases the effect for the different number of threads. Plot the
results in a graph where the x-axis is the number of threads and the y-axis is the time it took to
run. Is the data what you were expecting? Why or why not?
In your Job Resume, explain the job description to make sure that you have understood the job.
Time Limit: Project Should be done before 21 Feb
Thanks, Prabh.
Prabhjot S.
100% (5)Projects Completed
5
Freelancers worked with
5
Projects awarded
40%
Last project
16 Apr 2024
Canada
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies