+/EE360P

distributed systems

git clone https://git.julia.blue/+/EE360P

vijaygarg1init7910ba6

master
820 B27 linesraw
1package mutex;
2import dist.*;
3public class LockTester {
4	public static void main(String[] args) throws Exception {
5		Linker comm = new Linker(args);
6		Lock lock = null;
7		if (args[3].equals("Lamport"))
8			lock = new LamportMutex(comm);
9		else if (args[3].equals("RicartAgrawala"))
10			lock = new RAMutex(comm);
11		else if (args[3].equals("Dining"))
12			lock = new DinMutex(comm);
13		else if (args[3].equals("Central"))
14			lock = new CentMutex(comm);
15		else if (args[3].equals("CircToken"))
16			lock = new CircToken(comm);
17		lock.init(null);
18		for (int i = 0; i < 5; i++) {
19			System.out.println(comm.getMyId() + " is requesting CS ");
20			lock.requestCS();
21			System.out.println(comm.getMyId() + " is in CS ******");
22			Util.mySleep(200);
23			lock.releaseCS();
24			System.out.println(comm.getMyId() + " is not in CS");
25		}
26	}
27}