subject

ONLY using POSIX calls read(), write(), open(), close(), and pthreads library (no c++ I/O library or cin/cout), Make a program that takes an input file from user input, opens it, and does the following: 1) Use the main thread to read the input file of 10,000 unsorted integers (1 line per integer in character format) from the beginning of the file to the end of file. While reading the input file you collect the start and end offsets of each of the 10 input file chunks of 1,000 lines each. Each file chunk obviously has 1,000 numbers.
The main thread writes 10 lines of file chunk information in the following format for each line:
Main Output: \t logical thread number \t start offset \t end offset \n
2) The main thread creates 10 worker pthreads (one pthread per file chunk as in (a)). Each pthread runs a function called computeMin (which you will also write) to take the start and end offsets and a file chunk number (0,1,2,...,9), read the input file, and determine the minimum integer of the file chunk. Each worker pthread saves this minimum in the chunk to a global array of 10 integers at the element number given by the file chunk number.
Each worker pthread itself writes one line of output in the following format for each line:
Worker Output: \t logical thread number \t start offset \t end offset \t minimum integer \n
3) The main thread will determine the global minimum (that is, the minimum of the global array of 10 integers).
The main thread writes one line of final output in the following format:
Main Output: The global minimum = \t PLACE THE ACTUAL GLOBAL MINIMUM HERE \n
This is how I'm opening file from user
int main(int argc, char *argv[]){
char buffer[64];
const char *filename;
if(argc != 2){
pprintf("Enter input file: ");
ssize_t l = read(STDIN_FILENO, buffer, 64);
buffer[l-1] = '\0';
filename = &buffer[0];
}
else{
filename = argv[1];
}
int inFile = open(filename, O_RDONLY);
and I got a function to help me print without using printf
unsigned int pstrlen(const char *s)
{
unsigned long length = 0;
while('\0' != s[length] && UINT_MAX != length)
length++;
return length;}
void pprintf(const char *s)
{
write(STDOUT_FILENO, s, pstrlen(s));
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:30
Stops: using the information learned in this course, explain three things you will not do when driving. a. b. c. explain why you will not do these things when driving. starts: using the information learned in this course, explain three things you will do when driving. a. b. c. explain why you will do these particular things when driving. explain one thing you will stop doing as a passenger. explain one thing you will start doing as a passenger.
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
You are most likely to automatically encode information about
Answers: 1
question
Computers and Technology, 24.06.2019 17:00
What are some examples of what can be changed through options available in the font dialog box? check all that apply. font family italicizing bolding pasting drop shadow cutting character spacing special symbols
Answers: 2
question
Computers and Technology, 24.06.2019 17:50
You work in the accounting department and have been using a network drive to post excel workbook files to your file server as you complete them. when you attempt to save a workbook file to the drive, you see the error message: “you do not have access to the folder ‘j: \’. see your administrator for access to this folder.” what should you do first
Answers: 2
You know the right answer?
ONLY using POSIX calls read(), write(), open(), close(), and pthreads library (no c++ I/O library or...
Questions
question
Medicine, 13.12.2020 20:10
question
Advanced Placement (AP), 13.12.2020 20:10
question
Mathematics, 13.12.2020 20:10