Suppose threads A and B are attempting to lock at the same time. Assume that there is a single shared variable. Let the value of 0 mean that no object is in the CS. Assume that a value of 1 in this variable indicates that A is entering/is in the CS and a value of 2 in the same register indicates that B is entering/is in the CS. Assume that A and B both read the register, initially 0, and are about to update them. Suppose A updates the register to 1. What would be the result? Select all that apply.
A and B both read the register, initially 0, and are about to
update them. Suppose A updates the register to 1.
(1)A will enter the CS.
(2)B will eventually obliterate the value written by A.
(3)Both A and B could be in the CS at the same time.
Suppose threads A and B are attempting to lock at the same time. Assume that there...
Assume that we desire to have deadlock-free mutual exclusion using locks on a shared object implemented via a set of shared registers. Suppose we allow threads to go through the lock method without writing to any of the shared registers? In general, it will be impossible to tell if a thread is in the critical section by examining the shared object. It will result in deadlocks. Both (a) and (b) Neither (a) nor (b) Suppose a thread attempts to lock...
Suppose there are three threads P, Q and R, each has some sequential code sections and then updates a shared variable count, as shown in the below table. Define and initialize semaphores to solve the synchronization and the critical section problems (use acquire/release or wait/signal). Assume that QS1 needs to be executed after PS1 and RS1, and PS2 needs to be executed after QS1 RS2 needs to be executed after QS2 which needs to be executed after PS2
(b) Consider the following two programs. They both access a shared variable count and increment it. One is lock-based using spin-lock, and the other is lock-free. They both use C11 CAS(compare and swap) function and eventually get the sane result, ie., cunt 10.000.000. Please fill in the blanks to complete the lock-free version. Each blank contains at most one statement. (5 marks) lock-based #include <8tdío.h> 2 #include <stdatomic.h> 3 | # include <pthread.h> 5 int count 0; 6 int lock...
Help with a Parallel and Distributed Programming assignment. In this assignment, you will be exploring different methods of counting the prime numbers between 1 and N. You will use 8 threads, and each will be given a range in which to count primes. The question is: where do you store your counter? Do you use a local variable? Do you use a global variable? Please use the following function to determine whether an integer number is a prime. // Return...
resource instances of the same type, being shared by processes maz, is maximum resource needs of Pi, where 2 mar, S m n. Assume that a process can request one resource at a time during execution. Answer 7. (20 pts) Consider a system of m P, P Pa where m 22. Suppose the following questions about deadlock among the various processes A: Suppose m 5 printers and n 2 processes in a system, with mazi 3 and mar2 4. Identify...
Suppose nodes A and B are on the same 10 Mbps broadcast channel, and the propagation delay between the two nodes is 245 bit times. Suppose A and B send Ethernet frames at the same time, the frames collide, and then A and B choose different values of K in the CSMA/CD algorithm. Assuming no other nodes are active, can the retransmissions from A and B collide? For our purposes, it suffices to work out the following example. Suppose A...
ment "The breaking strength of Brand A cotton threads is larger than the Brand B" is true. These students randomly selected 10 Brand A cotton threads and 10 Brand B cotton threads. Assume that population distributions for both Brands A and B are approximately independent normal. The breaking strength of each brand is indicated in following table. The data and relevant R commands and outputs are given below. Answer the following questions from 1 though 5. Brand A 208.5, 187.6,...
3. Let th e random variable Ti denote the time you must wait to place your order in a fast-food restaurant, let Tz denote the time that it takes to place your order after you reach the counter, let s denote the time that it takes to receive vour food after you've placed your order, and let T enote the time that it takes to east vour food after you've received it. Assume that all of these random variables are...
please urgent help needed lakt time measure which b. I Discussion Questions ( Why Is It portant to look a formance, as measured by average Inventory avera e gate flow pe flow time, and average throughput? 3.2 Discuss why it is often easier to measure average inventory and average throughput rather than aver- age flow time How can a manager determine the minimal set of operational measures that should be tracked on a daily basis to predict the financial performances...
1) Present value calculations: A) are appropriate for investments in the same time period B) are accurate only in a low-rate environment C) provide comparisons for investments when inflation is known D) provide a common reference for measuring investments at different maturities 2) Compounding refers to: A) the calculation of interest rates after allowing for the effect of taxes B) the process of earning interest on interest of an investment C) the repayment of both interest and principal at the...