struct Node{
valatile int val;
struct Node* valatile next;
struct mutex lock;
}
bool remove(struct Node*head, int val)
{
if (head==NULL)
return false
pre=head;
cur=head.next;
mutex_lock(pre.lock)
mutex_lock(cur.lock)
while (cur && cur.val!=val)
{
mutex_unlock(pre.lock)
pre=cur
cur=cur.next
if (cur!=NULL)
mutex_lock(cur.lock)
}
if (cur==NULL)
mutex_unlock(pre)
else
{
pre.next=cur.next
mutex_unlock(pre)
mutex_unlock(cur)
}
}
bool add(struct Node* head, val)
{
...
}
bool contain(struct Node*head, val)
{
...
}