atomic operation
once it starts, it will finish without being interrupted
in database, this is called transaction processing (concurrency control)


ATM1 ATM2
balance=1000
1 read balance 5 read balance
2 balance-=100 6 balance-=100
3 give cash 7 give cash
4 update balance 8 update balance
write to db write to db

1
1000
5
1000
2
900

3
get $

6
900

7
get $
4
db=900

8
900

class MyThread extends Thread
{
private int[] a;
private int[] b;
private int[] c;
private int first;
private int last;
public MyThread (int[] x, int[] y, int[] z, int f int l)
{
a=x;
b=y;
c=z;
first=f;
last=l;
}
public void run()
{
for (int i=first;i<=last;i++)
{
c[i]=a[i]+b[i];
}
}
}

int[] a=new int[100];
int[] b=new int[100];
int[] c=new int[100];
initialize a,b,c
MyThread t1=new MyThread(a,b,c,0,24);
MyThread t2=new MyThread(a,b,c,25,49);
MyThread t3=new MyThread(a,b,c,50,74);
MyThread t4=new MyThread(a,b,c,75,99);
t1.start();
t2.start();
t3.start();
t4.start();
t1.join();
t2.join();
t3.join();
t4.join();

1. do they share data?
false

SIMD S=Single
MIMD M=Multiple
SISD I=Instruction
MISD D=Data


}

int[] a=new int[100]; int[] b=new int[100]; int[] c=new int[100]; initialize a,b,c MyThread t1=new MyThread(a,b,c,0,24); MyThread t2=new MyThread(a,b,c,25,49); MyThread t3=new MyThread(a,b,c,50,74); MyThread t4=new MyThread(a,b,c,75,99); t1.start(); t2.start(); t3.start(); t4.start(); t1.join(); t2.join(); t3.join(); t4.join();

1. do they share data?

   false

SIMD S=Single MIMD M=Multiple SISD I=Instruction MISD D=Data

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood