multitreading with asynchronous
TRANSCRIPT
-
7/28/2019 Multitreading with Asynchronous
1/8
-
-
7/28/2019 Multitreading with Asynchronous
2/8
DSMThreads
PthreadsBIP/
TCP
Madeleine
Marcel(shallow binding)
Figure 1. Layering of Software Components
Table 1. Mapping TCP/IP onto Madeleine
-
7/28/2019 Multitreading with Asynchronous
3/8
T0
fctT
fctT
T0
T0
fctT
T0
fctT
T0
T0
node 3
slave 2
node 2slave 1
CS
node 1master
CS
node 1master
CS
node 2slave 1
CS
node 3
slave 2dsm_exit
CS
CS
send a message
rsh $host program ... CS communication server
T main thread0
T thread that performs a user functionfct
program start
pthread_create
(function)
dsm_thread_create
dsm_thread_create
dsm_init dsm_init
dsm_init
dsm_init
dsm_exit
dsm_thread_create
dsm_thread_create
(function)
dsm_exit
dsm_exit
dsm_init
dsm_exit
dsm_init
dsm_exit
(a) Original Model (b) Modified Model
> program > dsmload program
Figure 2. Distributed Execution Models for DSM-Threads
4.1 Direct and Indirect Communication
-
-
-
7/28/2019 Multitreading with Asynchronous
4/8
P1 P2
msg to T2
P1 P2
sending a message reception of a message notification of an user thread P 1/2 processes
T 1/2 user threads
CS communication server observes POC 1/2
POC x port/channel of a process/thread
msg to T1
POC2.1
T1 T2T2T1
POC1.1
POC2.2POC1.2
(a) Direct Reception of Messages on Distinct Ports/Channels (b) Indirect Message Reception via Demultiplexing on a Single Port/Channnel
T2CS
T1 msg to T2
CS T2
T1
msg to T1
POC2POC1
Figure 3. Connection Models for Message Passing
-
4.2 MT-Safe Message Passing
-
7/28/2019 Multitreading with Asynchronous
5/8
registerHandler( ReceiveMessage )
receive( buffer )
Handler
ReceiveMessage
process message basically
return
process message
suspends execution of the thread
msg available on the network
resume waiting thread
copy msg to buffer, etc.
Figure 4. Message Reception after Event Notification
while(!test( handle ))
handle := init( buffer )
sleep( x ms )
process message
wait x milliseconds; blocks thread;
other threads may become active
test != 0 msg available in buffer
Figure 5. Message Reception via Polling
4.3 Partial Message Processing
-
-
7/28/2019 Multitreading with Asynchronous
6/8
CS communication server
receiving a message
actions of the CS
header, fixed size
for a page
temporary buffer
actual page
reads message header
allocates memory formessage body and storesit there
copies body (page) to
actual address
header, fixed size
actual page
reads message header
extracts page address
from header and
directly to actual address
copies body (page)
CS memorymemory
(b) ZeroCopy Overhead(a) Traditional Copy Overhead
CS
worker
Figure 6. Message Unpacking Models
5.1 Replacing Marcel
Table 2. Shallow Binding: Marcel to Pthreads
5.2 Adapting Madeleines BIP-Interface
-
7/28/2019 Multitreading with Asynchronous
7/8
T
T: wait(c)
CSREQUESTCS
CS: signal(c)
T continues
DATA
ACK
sender receiver
ba
REQUEST
ACK
DATA
TCS
sender receiver
Figure 7. Models for Sending Large Messages under BIP
-
-
7/28/2019 Multitreading with Asynchronous
8/8
Bsnd rcv
B
A
3 0
A Asnd rcv
B
3 0
Bsnd rcv
B
A
A Asnd rcv
B
3 30 0
2 03 1
0credits
backtoB
b
Bsnd rcv
B
A
A Asnd rcv
B
3 1 00credit
s
backtoA
2
1 03 2
da
Bsnd rcv
B
A
A Asnd rcv
B
2 30 1
backtoA
023 1
c
1credit
Figure 8. Credit Mechanism
-