ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 06 Jun 2017 My Price 9.00

SFWRENG 3SH3: Operating SystemsLab 3

I need help reading files into a square matrix in array format from a txt file. Please reference the pdf file attached for more information. 

 

SFWRENG 3SH3: Operating SystemsLab 3: POSIX ThreadsDr. Borzoo Bonarkdarpour1 Overall ObjectiveYou are to write a C or C++ concurrentShearsortprogram using POSIX PTHREADSlibrary and semaphore operations. You are NOT to usefork()calls, pipes, or messagequeues in this exercise.TheShearsortis a simple mesh-sorting algorithm that consists of nothing more thanalternately sorting rows and columns of the mesh. In particular, it sorts all therowsinPhases 1, 3, .. . , log2√N+ 1, and all thecolumnsin Phases 2, 4, .. . , log2√N, whereNis the total number of elements. Thecolumnsare sorted so that smaller numbers moveupward. Theodd rows(1, 3, .. . ,√N-1) are sorted so that smaller numbers move leftward,and theeven rows(2, 4, .. . ,√N) are sorted in reverse order (i.e., so that smaller numbersmove rightward). The numbers will appear in a snakelike order after 2 log2√N+ 1 =log2N+ 1 phases. An example is given in Figure 1. (A proof that the Shearsort algorithmworks can be found inIntroduction to Parallel Algorithms and Architectures: Arrays, Trees,Hypercubesby F. Thomson Leighton. However, the information about Shearsort in thishandout should be sufficient for you to complete the exercise.)2 AssignmentIn this lab assignment you will use shared memory to store ONE copy of the whole 2-dimensional array. Also, you will be required to create a limited number of threads for thesort. For a square array ofn×nelements, ONLYnTHREADS are to be created. Each threadis to alternate between row (odd) and column (even) phases. To synchronize the phasesproperly, you will need to use semaphores. You are to use at most ONE SEMAPHOREPER THREAD.Your program should implement the Shearsort algorithm to handle 16 integers as follows.1. Read the integers into a 2-dimensionaln×narray in global memory from the file”input.txt”. This can be done by the main program.2. Print the integers in the order entered tostdout.1

Attachments:

Answers

(11)
Status NEW Posted 06 Jun 2017 03:06 AM My Price 9.00

-----------

Not Rated(0)