Computers and Technology

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
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, adam4449
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
image
Computers and Technology, 22.06.2019 15:00, miracle9704
Atool that matches persoal skills qualities interests and talets to a career is called a
Answers: 1
image
Computers and Technology, 23.06.2019 15:30, Dweath50
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
image
Computers and Technology, 24.06.2019 14:30, SmartScholar4094
Two students are discussing electricity that has a frequency of 60 hz. student a says that this type of electricity is referred to as ac. student b says that in this type of electricity, the electrons flow in only one direction. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
Do you know the correct answer?
Please use thread to complete the following program: one process opens a file data. txt, then create...

Questions in other subjects:

Konu
Mathematics, 13.09.2020 23:01
Konu
Mathematics, 13.09.2020 23:01
Konu
History, 13.09.2020 23:01
Konu
English, 13.09.2020 23:01
Konu
Mathematics, 13.09.2020 23:01
Konu
Mathematics, 13.09.2020 23:01
Konu
Mathematics, 13.09.2020 23:01
Konu
Health, 13.09.2020 23:01
Konu
Mathematics, 13.09.2020 23:01
Konu
Mathematics, 13.09.2020 23:01