subject

Please use thread to complete the following program: one process opens a file data. txt, then creates a thread my_thread. The job of the thread my_thread is to count how many lines exist in the file data. txt, and return the number of lines to the calling process. The process then prints this number to the screen. Basically, you need to implement main_process. c and thread_function. c.
Basic structure of main_process. c:
int main ()
{
Open the file data. txt and obtain the file handler fh;
Create a thread my_thread using pthread_create; pass fh to my_thread;
Wait until my_thread terminates, using pthread_join;
Print out how many lines exist in data. txt.}
Basic structure of thread_function. c:
void *count_lines(void *arg)
{
Obtain fh from arg;
Count how many lines num_lines exist in fh;
Close fh;
Return num_lines
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
An english teacher would like to divide 8 boys and 10 girls into groups, each with the same combination of boys and girls and nobody left out. what is the greatest number of groups that can be formed?
Answers: 2
question
Computers and Technology, 24.06.2019 19:20
Which command suppresses the visibility of a particular row or column in a worksheet?
Answers: 1
question
Computers and Technology, 25.06.2019 00:40
Roger ginde is developing a program in supply chain management certification for managers. ginde has listed a number of activities that must be completed before a training program of this nature could be conducted. the activities, immediate predecessors, and times appear in the accompanying table: activity immediate predecessor(s) time (days) a -− 44b -− 55 c -− 11 d b 1010 e a, d 55 f c 55 g e, f 1010 calculate the slack time. show the details.
Answers: 2
You know the right answer?
Please use thread to complete the following program: one process opens a file data. txt, then create...
Questions
question
Health, 15.01.2021 01:10
question
Mathematics, 15.01.2021 01:10
question
Mathematics, 15.01.2021 01:10
question
English, 15.01.2021 01:10
question
English, 15.01.2021 01:10
Questions on the website: 13722361