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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:30
Select the correct answer from each drop-down menu. which types of computer networks are bigger as well as smaller than a man? a man is a network of computers that covers an area bigger than a , but smaller than a .
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
If you add the following to the query grid in an access query, what is it called? salestaxamt: [salestaxrate]*[totalsale] formula calculated field total calculation
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Ais a built in formula in spread spread a is any math process such as addition or subtraction. options are function and operation
Answers: 1
question
Computers and Technology, 24.06.2019 23:30
True or false when a host gets an ip address from a dhcp server it is said to be configured manually
Answers: 1
You know the right answer?
Write all possible outputs of the following C program. Separate different possibilities clearly. Ass...
Questions