Single answer: xchgl is a x86 machine instruction that reads a 32bit value from a memory location and sets a new value to the same memory location as a single atomic instruction. The following xchg is the mutual exclusion (mutex) implemented in xv6 os kernel using a xchgl x86 instruction. For your understanding, the machine effects are described in C. static inline int xchg(volatile int *addr, int newval) { uint result; /* atomic read followed by update in a C version */ result = *addr; *addr = new; return result;} Select one that *CORRECTLY* implements a mutual lock to enter a critical section (mutual exclusion) using the xchg above.
Blog
According to your assignment, Sodium Polyacrylate (podcast),…
According to your assignment, Sodium Polyacrylate (podcast), what was an interesting fact?
Compra _______ [CLOZE_01] spinaci.
Compra _______ [CLOZE_01] spinaci.
[Single choice] Using Amdahl’s Law, calculate the speedup ga…
[Single choice] Using Amdahl’s Law, calculate the speedup gain for the application that has 40 percent parallel with eight processing cores.
Copy the program below and revise it to make the program pro…
Copy the program below and revise it to make the program produce the same output every time when it executes #include #include #include int value;typedef struct __myarg_t { int x; int y;} myarg_t;pthread_t t1,t2;pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;void *work(void *arg) { myarg_t *m = (myarg_t *) arg; int local1 = m->x; int count = m->y; for (int i = 0; i < count ; i++) { value = value + local1; } return NULL;}int main(){ value = 0; myarg_t arg1 = {2, 1000}; myarg_t arg2 = {3, 1000}; int rc; value = 0; rc = pthread_create(&t1, NULL, &work, (void*)&arg1); if (rc < 0) { perror("pthread creation error for thread t1\n"); return -1; } rc = pthread_create(&t2, NULL, &work, (void*)&arg2); if (rc < 0) { perror("pthread creation error for thread t2\n"); return -1; } pthread_join(t1, NULL); pthread_join(t2, NULL); printf("%d\n", value); return 0;}
[Single answer] Which of the following components of program…
[Single answer] Which of the following components of program state are shared across threads in a multithreaded process?
Why is alternating current (AC) preferred for power distribu…
Why is alternating current (AC) preferred for power distribution in modern infrastructure?
Che tempo fa oggi? _______________
Che tempo fa oggi? _______________
Tu — giocare a basket?
Tu — giocare a basket?
L’ azione: _______ [CLOZE_01] _______ [CLOZE_02]
L’ azione: _______ [CLOZE_01] _______ [CLOZE_02]