nminoru@nminoru.jp http://www.nminoru.jp/~nminoru/ - PowerPoint PPT Presentation

About This Presentation
Title:

nminoru@nminoru.jp http://www.nminoru.jp/~nminoru/

Description:

Title: Author: nminoru Last modified by: NAKAMURA Minoru Created Date: 12/11/2006 8:54:19 AM Document presentation ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 25
Provided by: nmi49
Category:
Tags: http | nminoru | pentium4 | www

less

Transcript and Presenter's Notes

Title: nminoru@nminoru.jp http://www.nminoru.jp/~nminoru/


1
??????????????????????????????
  • ?? ?
  • nminoru_at_nminoru.jp http//www.nminoru.jp/nminoru/

2
????????
  • ??????????????
  • Java VM?????GCJIT??????????
  • Java??????????
  • ???IA-64??????
  • ??? Web ???????????????????
  • ???????? Binary Hacks ????????????

3
Binary Hacks 94??????????????????
  • CPU ? Out-of-order ??
  • ??????? load/store ?????????
  • Load ????? (????)
  • Store ????? (Store buffering)
  • ?????????(memory ordering)
  • CPU ???????????????
  • ???????????????????????(??????)???

4
Binary Hacks 94??????????????????
  • Store Buffer
  • Store ?????????????????

Register
Store Buffer
Store buffer
Store3
Load
Store2
Cache
Store1
Main memory/cache
Main memory
5
Binary Hacks 94??????????????????
  • ???????
  • ??????????????????????????????????????
  • Pthread ? mutex ? IPC ? semaphore ????????
  • Cmpxchg ?????????
  • ????????
  • ?????????????????????????????????? Lock-free
    synchronization ???
  • ???????????????????????????????????? orz

6
???????????
  • ??????????????????
  • ????????? (Web?????)
  • ????????????
  • ???????????/??? ? ????????????????
  • ??????????



?
?????? ??GC??
7
???????????????
  • ??????? mutex ??????????(??)
  • ?????????(conflict)???
  • ???????????????????????

??
?????
CPU
CPU
CPU
CPU
CPU
CPU
Thread
Thread

Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
8
Mutex ? spin lock ?????? ???????????????
??!! Lock-free synchronization
9
Lock-free synchronization
  • ??
  • ???????????????
  • ?????????????????????
  • ????
  • ????????????????
  • CAS (compare and swap) ? x86 ?? cmpxchg??
  • LL/SC (load linked/store conditional)
  • ??????????????
  • Deque, FIFO, LIFO
  • ??????,??????, Set, Hash
  • ??? lock-free ??????????????

10
Sequence lock
  • Optimistic lock (???????)
  • ?????? counter
  • ???????????? lock-free
  • ????????? lock ???
  • Counter ????????????????

????
????
counter
  • Read counter
  • Read data
  • Read counter
  • ?????1?????
  • 1?3?????
  • data ?????????
  1. Counter ????? CAS ??? 1
  2. data ?????
  3. Counter ???? 1

data
11
Read Copy Update (RCU)
  • ??????
  • ??????????
  • ??????????

Reader
Writer
12
Read Copy Update (RCU)
  • ??????
  • ??????????
  • ??????????

Reader
copy
Writer
13
Read Copy Update (RCU)
  • ??????
  • ??????????
  • ??????????

Reader
Writer
14
Read Copy Update (RCU)
  • ??????
  • ??????????
  • ??????????

GC???
Writer
15
Double-ended Queue (Deque)
  • N.Arora et al.,Thread scheduling for
    multiprogrammed multiprocessors,SPAA 1998
  • OS ?????????????????? deque
  • ??????????????????????
  • ????????????? push ???
  • Push?pop?lock-free ?????????????????
  • Sun HotSpot VM ???GC???????????

Other threads
Owner thread
16
???
  • Deque
  • M.Micheal, CAS-based lock-free algorithm for
    shared dequeues, EuroPar 2003
  • ??????
  • H.Sundell, Lock-free and practical doubly
    linked list-based deques using single-word
    compare-and-swap, OPODIS 2004
  • NOBLE - a library of non-blocking synchronization
    protocolshttp//www.cs.chalmers.se/noble/

17
??????????????
  • ???????????!!
  • Lock-free synchronization?????????????????????????
    ??????
  • ?????????
  • Ross Bencina ?????
  • http//www.audiomulch.com/rossb/code/lockfree
  • Lock-free wait-free ????????????????
  • Lock-free library
  • http//www.cl.cam.ac.uk/research/srg/netos/lock-fr
    ee/
  • Alpha, MIPS, IA-64, x86, PPC, SPARC ???
  • GPL ???????
  • ???????
  • ???? wikipedia ???
  • http//en.wikipedia.org/wiki/Lock-free_and_wait-fr
    ee_algorithms

18
??????
  • ??(conflict)????????????mutex ????????
  • ?????????
  • ??????????
  • ????????????????
  • ??????
  • CPU ? out-of-order ?????????????????
  • ???????????????????? (_)/

19
Sequence lock
  • Optimistic lock (???????)
  • ?????? counter
  • ???????????? lock-free
  • ????????? lock ???
  • Counter ????????????????

3?? read ????????????????????? ?????????
????
????
counter
  • Read counter
  • Read data
  • Read counter
  • ?????1?????
  • 1?3?????
  • data ?????????
  1. Counter ????? CAS ??? 1
  2. data ?????
  3. Counter ???? 1

data
20
x86?????????????
21
x86 CPU ??????????
  • X86 ????????????????????? CPU ?????????

RAR WAR WAW RAW
i386
i486,Pentium
P6
Opteron

?A? ? After ?
?????????
22
x86 CPU????????
  • ????????
  • CPUID, Lock ???????
  • ??????Store buffer ????????????????????????????
  • ???
  • ????????
  • SFENCE ?? (Pentium3??)
  • Store ? Store ????
  • LFENCE ?? (Pentium4??)
  • Load ? Load ????
  • MFENCE ?? (Pentium4??)
  • ????????????

23
C/C ?????????????
  • ??????????
  • volatile ??????????? ABI ???
  • ex. IA-64 ABI
  • C0x ??????!

define mb() asm volatile ("mfencememory)
define rmb() asm volatile (lfencememory)
define wmb() asm volatile (sfencememory)
Evolution working group issue list ES066.
Support for parallel programming For example,
locks, threading, memory barrier, static local
initialization.
24
???
  • ?????????
  • Mutex/spin lock ??????? (??????) Lock-free
    synchronization ????
  • Memory ordering
  • ?????????????????????
  • ??????????????????????????

??????????????
Write a Comment
User Comments (0)
About PowerShow.com