subject

Write all possible outputs of the following C program. Separate different possibilities clearly. Assume there will be no mutex or semaphore initialization, thread creation or joining failures. If you believe there is only one possible output, you just need to write that output. #include #include char arr [2]={'a','b']; int mark=0, size=0; pthread_mutex_t ml = PTHREAD_MUTEX_INITIALIZER; { void swap (int start, int end) { int i, j; for (i=start, j=mark;i<=end; i++) pthread_mutex_lock (&ml); arr[0]=arr[O] + (j82); arr[1]=arr[1]+(j82); pthread_mutex_unlock (&ml); } } void *fun (void *arg) { swap (mark, mark+size-1); mark=mark+size; } int main(int argc, char *argv[]) { int num_threads=2, i, x; size=14/num_threads; pthread_t thread[num_threads]; for( i = 0; i < num_threads; i++) x = pthread_create(&thread[i], NULL, fun, NULL); for( i = 0; i < num_threads; i++) pthread_join(thread[i], NULL); for(i=0;i<2;i++) printf("%c", arr[i]); return 0;

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:00, bankscorneliuso39
Fast sportcars the top speeds of sportscars, given in miles per hour, are: 155 mph bmw m5 217 mph lamborghini aventador spyder 205 mph ferrari 488 205 mph nissan gtr 197 mph chevrolet corvette stingray zr1 258 mph bugatti veyron supersport 195 mph dodge viper 270 mph hennessey venom 155 mph bmw m3 195 mph mercedes sl given: topspeeds=[155; 217; 205; 205; 197; 258; 195; 270; 155; 195]; carnames=string(["bmw m5" "lamborghini aventador spyder" "ferrari 488" "nissan gtr" "chevrolet corvette stingray zr1" "bugatti veyron supersport" "dodge viper" "hennessey venom" "bmw m3" "mercedes sl"]); the variable is a rectangular array. write a function called selectcars to identify cars with the top speed within a given range, and display the identified names. the selected cars speed will be in a range given by lowerbound < speed < upperbound. inputs to the function selectcars are: a column array os all car top speeds named topspeeds, the corresponding chara
Answers: 2
image
Computers and Technology, 22.06.2019 00:00, amyeileen
11. is the ability to understand how another person is feeling. a. authority b. sympathy c. empathy d. taking a stand
Answers: 1
image
Computers and Technology, 22.06.2019 16:20, mandy9386
Consider the following statements, then select one of the answers below: the signal() function shown below registers "sig_handler()" as the signal handler function for the sigkill signal, without the complexity of using when the sigkill signal is sent to a process running this code, by a user typing "kill -kill ", where the correct process id is used for to target the process, sig_handler() will be executed.
Answers: 1
image
Computers and Technology, 22.06.2019 17:00, smartoa
Annie is creating a corporate report for a company’s annual meeting. in the report, she wants to add the signature of various department heads. which device can annie use to capture signatures to include in the report? a. printer b. monitor c. e-reader d. digitizing tablet
Answers: 1
You know the right answer?
Write all possible outputs of the following C program. Separate different possibilities clearly. Ass...

Questions in other subjects:

Konu
History, 25.06.2019 02:00