Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ubun in or Mac Termina Part one-Threads Programming (0.5% Write a program in C that prompts the user to enter n which represents the number

image text in transcribed
image text in transcribed
Ubun in or Mac Termina Part one-Threads Programming (0.5% Write a program in C that prompts the user to enter n which represents the number of threads, your program should then create n threads and wait for them to finish the execution. Threads from 1. should print the numbes from 1 Whereas threads from+1n should print their unique ids along with an informative message. Part two-Tracing (1.0% Trace the below code and answer the following questions: inc include include include cuntstd.h> estdio otdinc(votd n) rtntf("I'n thread nt main) threadt tid; number %ld and ny value is %d ", pthread-self(),K*2); thread create(&tid, NULL,inc, NULL) thread exit(NULL) 1. 2. How many threads does this process have? What is the value of x variable at the end of the execution? Trace the below code and answer the following questions nclude apthread.h lude cunlstd.h Lntf(* "n thread fuiber %ld and ny values are %4, san.. pthread-self(),a,y); netn) t tldt2] 1).ML,tnc, (vold (int t te2i+) tld),NULL exit(NULL) 1. How many threads does this process have? 2. What is the name of the function that is executed by all threads? 3. What is the parameter that is passed to the thread function? 4. Choose the correct type for the variable x a. x is a global variable shared among al threads b. x is local and not shared among all threads S. Choose the correct type for the variable y a yis a global variable shared among all threads b. y is local and not shared among all threads 6. Complete the table according to the x and y variables values in each thread: Prince Sulkan University 182 C5330 Operating Systems 7. Explain is the effect the second for loop in the main process: 8. What is the effect of putting pthread exit(NULL: statement at the beginning of the function inc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions