Guest User

Untitled

a guest
Aug 21st, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. t3rmin4t0r> assume I'm setting p->next = NULL
  2. 03:03 < YuviPanda> ok?
  3. 03:03 < YuviPanda> and?
  4. 03:03 < t3rmin4t0r> this one will need for(i = 0; i < tries; i++) cas(p->next, p->next, NULL));
  5. 03:03 < t3rmin4t0r> eeks, I meant
  6. 03:03 < t3rmin4t0r> for(i = 0; i < tries && cas(p->next, p->next, NULL); i++);
  7. 03:04 < t3rmin4t0r> so that ensure I do not overwrite the write someone else did
  8. 03:05 < t3rmin4t0r> but a singly linked list is so uber complicated & painful
  9. 03:05 < t3rmin4t0r> insertions are damn easy to do without issues
  10. 03:06 < t3rmin4t0r> i = 0; do { newp->next = p->next; i++; ) while(!cas(p->next, p->next, newp->next))
  11. 03:06 < t3rmin4t0r> yeah, I meant !cas() earlier as well
  12. 03:06 < t3rmin4t0r> but deletions are a pain in the ass
  13. 03:07 < t3rmin4t0r> insertions are neat because nobody but the writing thread can write to newp->next
  14. 03:07 < t3rmin4t0r> so we never need to worry about have sync issues
  15. 03:07 < t3rmin4t0r> deletions are painful because both pointers need to be swapped at the *same* time
  16. 03:08 < t3rmin4t0r> anyway, night night
  17. 03:08 < YuviPanda> ah, so that's kinda like two atomic ones - which really should be one
  18. 03:08 < YuviPanda> t3rmin4t0r, where does this code go to?
  19. 03:08 < t3rmin4t0r> I've got a local svn for this kind of work
  20. 03:08 < t3rmin4t0r> but eventually, it becomes part of php-apc
  21. 03:08 < YuviPanda> t3rmin4t0r, no, i mean - PHP Interpreter, APC, etc?
  22. 03:08 < YuviPanda> ah
  23. 03:08 < YuviPanda> right
  24. 03:09 < YuviPanda> t3rmin4t0r, gnite, i'lll send you a dm reminding you of that sponsorship thingy
  25. 03:09 < iwikiwi> t3rmin4t0r: (might sound dumb but) why cant you use two operations? (and not same time)
  26. 03:09 < t3rmin4t0r> yeah, alright
  27. 03:10 < t3rmin4t0r> iwikiwi: assume the list looks like 1 -> 2 -> 3 -> 4
  28. 03:10 < iwikiwi> okay, go on
  29. 03:10 < t3rmin4t0r> thread #1 tries to delete 2, thread #2 tries to delete 3
  30. 03:10 < t3rmin4t0r> 1->next = 3; #thread 1
  31. 03:10 < t3rmin4t0r> 2->next = 4; #thread 2
  32. 03:10 < iwikiwi> ah
  33. 03:11 < iwikiwi> when it should be
  34. 03:11 < iwikiwi> 3->4
  35. 03:11 < t3rmin4t0r> 1->4;
  36. <t3rmin4t0r> eventually
  37. 03:11 < iwikiwi> right
  38. 03:11 < t3rmin4t0r> if I can get it work for a linked list, it automatically applies to a tree
  39. 03:12 < YuviPanda> so right now, you put a lock around the entire thing you're changing so those two separate atomic ops become one atomic op (to use a
  40. crude way of saying things)
  41. 03:12 < t3rmin4t0r> yup, I put a lock around *all* ops on the linked list, not just adjacent ones
  42. 03:12 < YuviPanda> while you're looking for a way to get rid of that lock and make it a singl cpu level atmic op.
  43. 03:13 < t3rmin4t0r> not really *single*, but I'd rather not prevent changes in one end of the list from slowing down changes at the other end
  44. 03:13 < t3rmin4t0r> I have a 16 cpu box here which is just wasting time on 15 cpus while one cpu is doing an operation
  45. 03:13 < YuviPanda> ah!
  46. 03:13 < nikkar> ooh yeah baby give it to me~~~
  47. 03:14 < t3rmin4t0r> anyway, tomorrow's friday!!
  48. 03:14 -!- t3rmin4t0r [~gopalv@122.178.221.31] has quit [Quit: TGIF!]
Add Comment
Please, Sign In to add comment