Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t3rmin4t0r> assume I'm setting p->next = NULL
- 03:03 < YuviPanda> ok?
- 03:03 < YuviPanda> and?
- 03:03 < t3rmin4t0r> this one will need for(i = 0; i < tries; i++) cas(p->next, p->next, NULL));
- 03:03 < t3rmin4t0r> eeks, I meant
- 03:03 < t3rmin4t0r> for(i = 0; i < tries && cas(p->next, p->next, NULL); i++);
- 03:04 < t3rmin4t0r> so that ensure I do not overwrite the write someone else did
- 03:05 < t3rmin4t0r> but a singly linked list is so uber complicated & painful
- 03:05 < t3rmin4t0r> insertions are damn easy to do without issues
- 03:06 < t3rmin4t0r> i = 0; do { newp->next = p->next; i++; ) while(!cas(p->next, p->next, newp->next))
- 03:06 < t3rmin4t0r> yeah, I meant !cas() earlier as well
- 03:06 < t3rmin4t0r> but deletions are a pain in the ass
- 03:07 < t3rmin4t0r> insertions are neat because nobody but the writing thread can write to newp->next
- 03:07 < t3rmin4t0r> so we never need to worry about have sync issues
- 03:07 < t3rmin4t0r> deletions are painful because both pointers need to be swapped at the *same* time
- 03:08 < t3rmin4t0r> anyway, night night
- 03:08 < YuviPanda> ah, so that's kinda like two atomic ones - which really should be one
- 03:08 < YuviPanda> t3rmin4t0r, where does this code go to?
- 03:08 < t3rmin4t0r> I've got a local svn for this kind of work
- 03:08 < t3rmin4t0r> but eventually, it becomes part of php-apc
- 03:08 < YuviPanda> t3rmin4t0r, no, i mean - PHP Interpreter, APC, etc?
- 03:08 < YuviPanda> ah
- 03:08 < YuviPanda> right
- 03:09 < YuviPanda> t3rmin4t0r, gnite, i'lll send you a dm reminding you of that sponsorship thingy
- 03:09 < iwikiwi> t3rmin4t0r: (might sound dumb but) why cant you use two operations? (and not same time)
- 03:09 < t3rmin4t0r> yeah, alright
- 03:10 < t3rmin4t0r> iwikiwi: assume the list looks like 1 -> 2 -> 3 -> 4
- 03:10 < iwikiwi> okay, go on
- 03:10 < t3rmin4t0r> thread #1 tries to delete 2, thread #2 tries to delete 3
- 03:10 < t3rmin4t0r> 1->next = 3; #thread 1
- 03:10 < t3rmin4t0r> 2->next = 4; #thread 2
- 03:10 < iwikiwi> ah
- 03:11 < iwikiwi> when it should be
- 03:11 < iwikiwi> 3->4
- 03:11 < t3rmin4t0r> 1->4;
- <t3rmin4t0r> eventually
- 03:11 < iwikiwi> right
- 03:11 < t3rmin4t0r> if I can get it work for a linked list, it automatically applies to a tree
- 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
- crude way of saying things)
- 03:12 < t3rmin4t0r> yup, I put a lock around *all* ops on the linked list, not just adjacent ones
- 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.
- 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
- 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
- 03:13 < YuviPanda> ah!
- 03:13 < nikkar> ooh yeah baby give it to me~~~
- 03:14 < t3rmin4t0r> anyway, tomorrow's friday!!
- 03:14 -!- t3rmin4t0r [~gopalv@122.178.221.31] has quit [Quit: TGIF!]
Add Comment
Please, Sign In to add comment