Describe how the signal() operation associated with monitors differs from the corresponding operation defined for semaphores. typedef struct node { value_t data; struct node *next; } Node; Node top;...


Describe how the signal() operation associated with monitors differs from the corresponding operation defined for<br>semaphores.<br>typedef struct node {<br>value_t data;<br>struct node *next;<br>} Node;<br>Node top; // top of stack<br>void push(value_t item) {<br>Node *old_node;<br>Node *new_node;<br>new node = malloc(sizeof (Node)):<br>new_node->data = item;<br>do<br>old node = top;<br>new node->next = old_node;<br>while (compare_and swap(top,old_node,new_node) != old node);<br>}<br>value_t pop() {<br>Node *old node;<br>Node *new_node;<br>do {<br>old node = top;<br>if (old_node == NULL)<br>return NULL;<br>new node = old node->next;<br>}<br>while (compare_and_swap(top,old_node,new_node) != old_node);<br>return old. node->data:<br>}<br>Figure 6.18 Lock-free stack for Exercise 6.15.<br>

Extracted text: Describe how the signal() operation associated with monitors differs from the corresponding operation defined for semaphores. typedef struct node { value_t data; struct node *next; } Node; Node top; // top of stack void push(value_t item) { Node *old_node; Node *new_node; new node = malloc(sizeof (Node)): new_node->data = item; do old node = top; new node->next = old_node; while (compare_and swap(top,old_node,new_node) != old node); } value_t pop() { Node *old node; Node *new_node; do { old node = top; if (old_node == NULL) return NULL; new node = old node->next; } while (compare_and_swap(top,old_node,new_node) != old_node); return old. node->data: } Figure 6.18 Lock-free stack for Exercise 6.15.

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here