diff --git a/src/Test.java b/src/Test.java deleted file mode 100644 index 66d115036e444fe54c6fcb1bf1fc59ae46cb7ac0..0000000000000000000000000000000000000000 --- a/src/Test.java +++ /dev/null @@ -1,104 +0,0 @@ -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import main.Consumer; -import main.Monitor; -import main.Producer; -import main.ProducerConsumer; -import enums.ProducerConsumerType; - -public class Test { - - private static List getAllProducersConsumers(int numberProducers, int numberConsumers, - Monitor monitor) { - List producersConsumers = new ArrayList<>(); - for (int i = 0; i < numberConsumers; i++) { - producersConsumers.add(new Consumer(monitor)); - } - for (int i = 0; i < numberProducers; i++) { - producersConsumers.add(new Producer(monitor)); - } - return producersConsumers; - } - - private static int getOperationsCountSum(List producerConsumers, ProducerConsumerType type) { - int sum = 0; - for (ProducerConsumer producerConsumer : producerConsumers) { - if (producerConsumer.getType() == type) { - sum += producerConsumer.getOperationsCount(); - } - } - return sum; - } - - public static void main(String[] args) { - int listInitialSize = Integer.parseInt(args[0]); - int listMaximumSize = Integer.parseInt(args[1]); - boolean warmUp = args[2].equals("1"); - int producers = Integer.parseInt(args[3]); - int consumers = Integer.parseInt(args[4]); - - System.out.println(); - System.out.println(String.format("Initial list size: %s", listInitialSize)); - System.out.println(String.format("Maximum list size: %s", listMaximumSize)); - System.out.println(String.format("Use warm-up: %s", warmUp)); - System.out.println(String.format("Number of producers: %s", producers)); - System.out.println(String.format("Number of consumers: %s", consumers)); - System.out.println(); - System.out.println("Starting test..."); - - // Start the monitor. - Monitor monitor = new Monitor(listMaximumSize); - for (int i = 0; i < listInitialSize; i++) { - try { - monitor.enq(Math.random()); - } catch (InterruptedException e) { - } - } - - ProducerConsumer.countingOperations = !warmUp; - - System.out.println("Starting producers and consumers..."); - List producersConsumers = getAllProducersConsumers(producers, consumers, monitor); - for (ProducerConsumer producerConsumer : producersConsumers) { - producerConsumer.startThread(); - } - - // Use a period of warm-up. During this period, operations are not counted. - if (warmUp) { - System.out.println("Warming-up..."); - try { - TimeUnit.SECONDS.sleep(15); - } catch (InterruptedException e) { - } - ProducerConsumer.countingOperations = true; - } - - try { - System.out.println("Producing and consuming..."); - TimeUnit.SECONDS.sleep(60); - } catch (InterruptedException e) { - } - - System.out.println("Interrupting threads..."); - System.out.println(); - for (ProducerConsumer producerConsumer : producersConsumers) { - try { - producerConsumer.interrupt(); - producerConsumer.join(); - } catch (InterruptedException e) { - } - } - - int currentMonitorSize = monitor.getCurrentSize(); - int enqOperationsCount = getOperationsCountSum(producersConsumers, ProducerConsumerType.producer); - int deqOperationsCount = getOperationsCountSum(producersConsumers, ProducerConsumerType.consumer); - - System.out.println(String.format("Current monitor size: %s", currentMonitorSize)); - System.out.println(String.format("Number of enqueues: %s", enqOperationsCount)); - System.out.println(String.format("Number of dequeues: %s", deqOperationsCount)); - - System.out.println("Finished."); - } -} diff --git a/src/TestMonitor.java b/src/TestMonitor.java deleted file mode 100644 index 3b97e1b96cd7898cd604f83e06341982851ba8db..0000000000000000000000000000000000000000 --- a/src/TestMonitor.java +++ /dev/null @@ -1,57 +0,0 @@ -import main.Monitor; -import main.MonitorSynchronized; - -public class TestMonitor { - - public static void main(String[] args) { - int maxSize = 100000000; - int operations = 100000000; - - System.out.println("Monitor..."); - Monitor monitor = new Monitor(maxSize); - long startTimeEnq = System.nanoTime(); - for (int i = 0; i < operations; i++) { - try { - monitor.enq(Math.random()); - } catch (InterruptedException e) { - } - } - long endTimeEnq = System.nanoTime(); - double durationEnq = (endTimeEnq - startTimeEnq) / 1_000_000_000d; - System.out.println(String.format("Enqueue: %s", durationEnq)); - long startTimeDeq = System.nanoTime(); - for (int i = 0; i < operations; i++) { - try { - Double d = monitor.deq(); - } catch (InterruptedException e) { - } - } - long endTimeDeq = System.nanoTime(); - double durationDeq = (endTimeDeq - startTimeDeq) / 1_000_000_000d; - System.out.println(String.format("Dequeue: %s", durationDeq)); - - System.out.println(); - System.out.println("MonitorSynchronized..."); - MonitorSynchronized monitorSynchronized = new MonitorSynchronized(maxSize); - long startTimeEnq2 = System.nanoTime(); - for (int i = 0; i < operations; i++) { - try { - monitorSynchronized.enq(Math.random()); - } catch (InterruptedException e) { - } - } - long endTimeEnq2 = System.nanoTime(); - double durationEnq2 = (endTimeEnq2 - startTimeEnq2) / 1_000_000_000d; - System.out.println(String.format("Enqueue: %s", durationEnq2)); - long startTimeDeq2 = System.nanoTime(); - for (int i = 0; i < operations; i++) { - try { - Double d = monitorSynchronized.deq(); - } catch (InterruptedException e) { - } - } - long endTimeDeq2 = System.nanoTime(); - double durationDeq2 = (endTimeDeq2 - startTimeDeq2) / 1_000_000_000d; - System.out.println(String.format("Dequeue: %s", durationDeq2)); - } -} diff --git a/src/enums/ListOperationType.java b/src/enums/ListOperationType.java new file mode 100644 index 0000000000000000000000000000000000000000..f13b2ca0ace3ea950a0e0b63d815e9b7f7cd50d1 --- /dev/null +++ b/src/enums/ListOperationType.java @@ -0,0 +1,5 @@ +package enums; + +public enum ListOperationType { + add, remove, contains, listSize +} \ No newline at end of file diff --git a/src/enums/ProducerConsumerType.java b/src/enums/ProducerConsumerType.java deleted file mode 100644 index 49ce5a38a470bcaf22bf58559a34326ea4d30a59..0000000000000000000000000000000000000000 --- a/src/enums/ProducerConsumerType.java +++ /dev/null @@ -1,5 +0,0 @@ -package enums; - -public enum ProducerConsumerType { - producer, consumer, -} \ No newline at end of file diff --git a/src/interfaces/GenericListInterface.java b/src/interfaces/GenericListInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..162188faeede2aa2584f48351c9b22d0c53f3628 --- /dev/null +++ b/src/interfaces/GenericListInterface.java @@ -0,0 +1,12 @@ +package interfaces; + +public interface GenericListInterface { + + public boolean add(T item); + + public boolean remove(T item); + + public boolean contains(T item); + + public int size(); +} \ No newline at end of file diff --git a/src/lists/CoarseList.java b/src/lists/CoarseList.java new file mode 100644 index 0000000000000000000000000000000000000000..857088b46a51f37b8f446c672e0f023160f060bc --- /dev/null +++ b/src/lists/CoarseList.java @@ -0,0 +1,173 @@ +/* +* CoarseList.java +* +* Created on January 3, 2006, 5:02 PM +* Updated on April 14, 2020, 1:13 PM, by Claudio Scheer +* +* From "Multiprocessor Synchronization and Concurrent Data Structures", by Maurice Herlihy and Nir Shavit. +* Copyright 2006 Elsevier Inc. All rights reserved. +*/ +package lists; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import interfaces.GenericListInterface; + +/** + * List using coarse-grained synchronization. + * + * @param T Item type. + * @author Maurice Herlihy + */ +public class CoarseList implements GenericListInterface { + // First list Node. + private Node head; + // Last list Node. + private Node tail; + // Synchronizes access to list. + private Lock lock = new ReentrantLock(); + + public CoarseList() { + // Add sentinels to start and end. + this.head = new Node(Integer.MIN_VALUE); + this.tail = new Node(Integer.MAX_VALUE); + head.next = this.tail; + } + + /** + * Add an element. + * + * @param item Element to add. + * @return True iff element was not there already. + */ + @Override + public boolean add(T item) { + Node pred, curr; + int key = item.hashCode(); + lock.lock(); + try { + pred = this.head; + curr = pred.next; + while (curr.key < key) { + pred = curr; + curr = curr.next; + } + if (key == curr.key) { + // Element already present. + return false; + } else { + // Add element. + Node node = new Node(item); + node.next = curr; + pred.next = node; + return true; + } + } finally { + lock.unlock(); + } + } + + /** + * Remove an element. + * + * @param item Element to remove. + * @return True iff element was present. + */ + @Override + public boolean remove(T item) { + Node pred, curr; + int key = item.hashCode(); + lock.lock(); + try { + pred = this.head; + curr = pred.next; + while (curr.key < key) { + pred = curr; + curr = curr.next; + } + if (key == curr.key) { + // Element is present. + pred.next = curr.next; + return true; + } else { + // Element is not present. + return false; + } + } finally { + lock.unlock(); + } + } + + /** + * Test whether element is present. + * + * @param item Element to test. + * @return True iff element is present. + */ + @Override + public boolean contains(T item) { + Node pred, curr; + int key = item.hashCode(); + lock.lock(); + try { + pred = this.head; + curr = pred.next; + while (curr.key < key) { + pred = curr; + curr = curr.next; + } + return (key == curr.key); + } finally { + lock.unlock(); + } + } + + @Override + public int size() { + Node pred, curr; + lock.lock(); + try { + int count = 0; + pred = this.head; + curr = pred.next; + while (curr.item != null) { + ++count; + pred = curr; + curr = curr.next; + } + return count; + } finally { + lock.unlock(); + } + } + + private class Node { + // Actual item. + T item; + // Item's hash code. + int key; + // Next Node in list. + Node next; + + /** + * Constructor for usual Node. + * + * @param item Element in list. + */ + Node(T item) { + this.item = item; + this.key = item.hashCode(); + } + + /** + * Constructor for sentinel Node. + * + * @param key Should be min or max int value. + */ + Node(int key) { + this.item = null; + this.key = key; + } + } +} diff --git a/src/lists/FineList.java b/src/lists/FineList.java new file mode 100644 index 0000000000000000000000000000000000000000..ba6c6ea6d8fc239bf6bd6b60c2f5c77c925ff8c3 --- /dev/null +++ b/src/lists/FineList.java @@ -0,0 +1,199 @@ +/* + * FineList.java + * + * Created on January 3, 2006, 6:50 PM + * + * From "Multiprocessor Synchronization and Concurrent Data Structures", + * by Maurice Herlihy and Nir Shavit. + * Copyright 2006 Elsevier Inc. All rights reserved. + */ +package lists; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import interfaces.GenericListInterface; + +/** + * Fine-grained synchronization: lock coupling (hand-over-hand locking). + * + * @param T Item type. + * @author Maurice Herlihy + */ +public class FineList implements GenericListInterface { + /** + * First list entry + */ + private Node head; + private int count; + + /** + * Constructor + */ + public FineList() { + // Add sentinels to start and end + head = new Node(Integer.MIN_VALUE); + head.next = new Node(Integer.MAX_VALUE); + } + + /** + * Add an element. + * + * @param item element to add + * @return true iff element was not there already + */ + @Override + public boolean add(T item) { + int key = item.hashCode(); + head.lock(); + Node pred = head; + try { + Node curr = pred.next; + curr.lock(); + try { + while (curr.key < key) { + pred.unlock(); + pred = curr; + curr = curr.next; + curr.lock(); + } + if (curr.key == key) { + return false; + } + Node newNode = new Node(item); + newNode.next = curr; + pred.next = newNode; + ++this.count; + return true; + } finally { + curr.unlock(); + } + } finally { + pred.unlock(); + } + } + + /** + * Remove an element. + * + * @param item element to remove + * @return true iff element was present + */ + @Override + public boolean remove(T item) { + Node pred = null, curr = null; + int key = item.hashCode(); + head.lock(); + try { + pred = head; + curr = pred.next; + curr.lock(); + try { + while (curr.key < key) { + pred.unlock(); + pred = curr; + curr = curr.next; + curr.lock(); + } + if (curr.key == key) { + pred.next = curr.next; + --this.count; + return true; + } + return false; + } finally { + curr.unlock(); + } + } finally { + pred.unlock(); + } + } + + @Override + public boolean contains(T item) { + Node last = null, pred = null, curr = null; + int key = item.hashCode(); + head.lock(); + try { + pred = head; + curr = pred.next; + curr.lock(); + try { + while (curr.key < key) { + pred.unlock(); + pred = curr; + curr = curr.next; + curr.lock(); + } + return (curr.key == key); + } finally { + curr.unlock(); + } + } finally { + pred.unlock(); + } + } + + @Override + public int size() { + return this.count; + } + + /** + * list Node + */ + private class Node { + /** + * actual item + */ + T item; + /** + * item's hash code + */ + int key; + /** + * next Node in list + */ + Node next; + /** + * synchronizes individual Node + */ + Lock lock; + + /** + * Constructor for usual Node + * + * @param item element in list + */ + Node(T item) { + this.item = item; + this.key = item.hashCode(); + this.lock = new ReentrantLock(); + } + + /** + * Constructor for sentinel Node + * + * @param key should be min or max int value + */ + Node(int key) { + this.item = null; + this.key = key; + this.lock = new ReentrantLock(); + } + + /** + * Lock Node + */ + void lock() { + lock.lock(); + } + + /** + * Unlock Node + */ + void unlock() { + lock.unlock(); + } + } +} diff --git a/src/lists/GenericOperator.java b/src/lists/GenericOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..0f281eab0ff5a373e3aad30f600ea4533ab24112 --- /dev/null +++ b/src/lists/GenericOperator.java @@ -0,0 +1,58 @@ +package lists; + +import java.util.concurrent.ThreadLocalRandom; + +import enums.ListOperationType; + +public abstract class GenericOperator extends Thread { + + protected abstract boolean operateAdd(); + + protected abstract boolean operateRemove(); + + protected abstract boolean operateContains(); + + public volatile static boolean warmingUp = true; + private int[] operationsCount; + + public GenericOperator() { + this.operationsCount = new int[ListOperationType.values().length]; + } + + @Override + public void run() { + while (!this.isInterrupted()) { + ListOperationType operation = this.getRandomOperation(); + this.operate(operation); + } + } + + public void operate(ListOperationType operation) { + switch (operation) { + case add: + this.operateAdd(); + break; + case remove: + this.operateRemove(); + break; + case contains: + this.operateContains(); + break; + case listSize: + return; + } + if (!GenericOperator.warmingUp) { + operationsCount[operation.ordinal()] += 1; + } + } + + protected ListOperationType getRandomOperation() { + // Generate random according to a distribuition frequency. + int index = ThreadLocalRandom.current().nextInt(0, 2); + return ListOperationType.values()[index]; + } + + public int[] getOperationsCount() { + return operationsCount; + } +} \ No newline at end of file diff --git a/src/lists/IntegerListOperator.java b/src/lists/IntegerListOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..e5989bc3c99ee56cc0bba39229fcba7bd0af157f --- /dev/null +++ b/src/lists/IntegerListOperator.java @@ -0,0 +1,28 @@ +package lists; + +import interfaces.GenericListInterface; +import utils.RandomNumbers; + +public class IntegerListOperator extends GenericOperator { + + private final GenericListInterface list; + + public IntegerListOperator(GenericListInterface list) { + this.list = list; + } + + @Override + public boolean operateAdd() { + return this.list.add(RandomNumbers.getRandomInt()); + } + + @Override + public boolean operateRemove() { + return this.list.remove(RandomNumbers.getRandomInt()); + } + + @Override + public boolean operateContains() { + return this.list.contains(RandomNumbers.getRandomInt()); + } +} \ No newline at end of file diff --git a/src/lists/LazyList.java b/src/lists/LazyList.java new file mode 100644 index 0000000000000000000000000000000000000000..075878c9d2e9261f21e09952f4f89652143b185f --- /dev/null +++ b/src/lists/LazyList.java @@ -0,0 +1,178 @@ +/* + * LazyList.java + * + * Created on January 4, 2006, 1:41 PM + * + * From "Multiprocessor Synchronization and Concurrent Data Structures", + * by Maurice Herlihy and Nir Shavit. + * Copyright 2006 Elsevier Inc. All rights reserved. + */ + +package lists; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + * Lazy list implementation: lock-free contains method. + * @param T Item type. + * @author Maurice Herlihy + */ +public class LazyList { + /** + * First list Node + */ + private Node head; + /** + * Constructor + */ + public LazyList() { + // Add sentinels to start and end + this.head = new Node(Integer.MIN_VALUE); + this.head.next = new Node(Integer.MAX_VALUE); + } + + /** + * Check that prev and curr are still in list and adjacent + */ + private boolean validate(Node pred, Node curr) { + return !pred.marked && !curr.marked && pred.next == curr; + } + /** + * Add an element. + * @param item element to add + * @return true iff element was not there already + */ + public boolean add(T item) { + int key = item.hashCode(); + while (true) { + Node pred = this.head; + Node curr = head.next; + while (curr.key < key) { + pred = curr; curr = curr.next; + } + pred.lock(); + try { + curr.lock(); + try { + if (validate(pred, curr)) { + if (curr.key == key) { // present + return false; + } else { // not present + Node Node = new Node(item); + Node.next = curr; + pred.next = Node; + return true; + } + } + } finally { // always unlock + curr.unlock(); + } + } finally { // always unlock + pred.unlock(); + } + } + } + /** + * Remove an element. + * @param item element to remove + * @return true iff element was present + */ + public boolean remove(T item) { + int key = item.hashCode(); + while (true) { + Node pred = this.head; + Node curr = head.next; + while (curr.key < key) { + pred = curr; curr = curr.next; + } + pred.lock(); + try { + curr.lock(); + try { + if (validate(pred, curr)) { + if (curr.key != key) { // present + return false; + } else { // absent + curr.marked = true; // logically remove + pred.next = curr.next; // physically remove + return true; + } + } + } finally { // always unlock curr + curr.unlock(); + } + } finally { // always unlock pred + pred.unlock(); + } + } + } + /** + * Test whether element is present + * @param item element to test + * @return true iff element is present + */ + public boolean contains(T item) { + int key = item.hashCode(); + Node curr = this.head; + while (curr.key < key) + curr = curr.next; + return curr.key == key && !curr.marked; + } + /** + * list Node + */ + private class Node { + /** + * actual item + */ + T item; + /** + * item's hash code + */ + int key; + /** + * next Node in list + */ + Node next; + /** + * If true, Node is logically deleted. + */ + boolean marked; + /** + * Synchronizes Node. + */ + Lock lock; + /** + * Constructor for usual Node + * @param item element in list + */ + Node(T item) { // usual constructor + this.item = item; + this.key = item.hashCode(); + this.next = null; + this.marked = false; + this.lock = new ReentrantLock(); + } + /** + * Constructor for sentinel Node + * @param key should be min or max int value + */ + Node(int key) { // sentinel constructor + this.item = null; + this.key = key; + this.next = null; + this.marked = false; + this.lock = new ReentrantLock(); + } + /** + * Lock Node + */ + void lock() {lock.lock();} + /** + * Unlock Node + */ + void unlock() {lock.unlock();} + } +} + diff --git a/src/lists/LockFreeList.java b/src/lists/LockFreeList.java new file mode 100644 index 0000000000000000000000000000000000000000..88bdc83bec37229bcdb0045d5a1ffa124eb8988b --- /dev/null +++ b/src/lists/LockFreeList.java @@ -0,0 +1,182 @@ +/* + * LockFreeList.java + * + * Created on January 4, 2006, 2:41 PM + * + * From "Multiprocessor Synchronization and Concurrent Data Structures", + * by Maurice Herlihy and Nir Shavit. + * Copyright 2006 Elsevier Inc. All rights reserved. + */ + +package lists; + +import java.util.concurrent.atomic.AtomicMarkableReference; + +/** + * Lock-free List based on M. Michael's algorithm. + * @param T Item type. + * @author Maurice Herlihy + */ +public class LockFreeList { + /** + * First list node + */ + Node head; + /** + * Constructor + */ + public LockFreeList() { + this.head = new Node(Integer.MIN_VALUE); + Node tail = new Node(Integer.MAX_VALUE); + while (!head.next.compareAndSet(null, tail, false, false)); + } + /** + * Add an element. + * @param item element to add + * @return true iff element was not there already + */ + public boolean add(T item) { + int key = item.hashCode(); + boolean splice; + while (true) { + // find predecessor and curren entries + Window window = find(head, key); + Node pred = window.pred, curr = window.curr; + // is the key present? + if (curr.key == key) { + return false; + } else { + // splice in new node + Node node = new Node(item); + node.next = new AtomicMarkableReference(curr, false); + if (pred.next.compareAndSet(curr, node, false, false)) { + return true; + } + } + } + } + /** + * Remove an element. + * @param item element to remove + * @return true iff element was present + */ + public boolean remove(T item) { + int key = item.hashCode(); + boolean snip; + while (true) { + // find predecessor and curren entries + Window window = find(head, key); + Node pred = window.pred, curr = window.curr; + // is the key present? + if (curr.key != key) { + return false; + } else { + // snip out matching node + Node succ = curr.next.getReference(); + snip = curr.next.attemptMark(succ, true); + if (!snip) + continue; + pred.next.compareAndSet(curr, succ, false, false); + return true; + } + } + } + /** + * Test whether element is present + * @param item element to test + * @return true iff element is present + */ + public boolean contains(T item) { + int key = item.hashCode(); + // find predecessor and curren entries + Window window = find(head, key); + Node pred = window.pred, curr = window.curr; + return (curr.key == key); + } + /** + * list node + */ + private class Node { + /** + * actual item + */ + T item; + /** + * item's hash code + */ + int key; + /** + * next node in list + */ + AtomicMarkableReference next; + /** + * Constructor for usual node + * @param item element in list + */ + Node(T item) { // usual constructor + this.item = item; + this.key = item.hashCode(); + this.next = new AtomicMarkableReference(null, false); + } + /** + * Constructor for sentinel node + * @param key should be min or max int value + */ + Node(int key) { // sentinel constructor + this.item = null; + this.key = key; + this.next = new AtomicMarkableReference(null, false); + } + } + + /** + * Pair of adjacent list entries. + */ + class Window { + /** + * Earlier node. + */ + public Node pred; + /** + * Later node. + */ + public Node curr; + /** + * Constructor. + */ + Window(Node pred, Node curr) { + this.pred = pred; this.curr = curr; + } + } + + /** + * If element is present, returns node and predecessor. If absent, returns + * node with least larger key. + * @param head start of list + * @param key key to search for + * @return If element is present, returns node and predecessor. If absent, returns + * node with least larger key. + */ + public Window find(Node head, int key) { + Node pred = null, curr = null, succ = null; + boolean[] marked = {false}; // is curr marked? + boolean snip; + retry: while (true) { + pred = head; + curr = pred.next.getReference(); + while (true) { + succ = curr.next.get(marked); + while (marked[0]) { // replace curr if marked + snip = pred.next.compareAndSet(curr, succ, false, false); + if (!snip) continue retry; + curr = pred.next.getReference(); + succ = curr.next.get(marked); + } + if (curr.key >= key) + return new Window(pred, curr); + pred = curr; + curr = succ; + } + } + } +} diff --git a/src/lists/OptimisticList.java b/src/lists/OptimisticList.java new file mode 100644 index 0000000000000000000000000000000000000000..b898e1d120cf3342b7fa28b6a1b6b93c6203def9 --- /dev/null +++ b/src/lists/OptimisticList.java @@ -0,0 +1,173 @@ +/* + * OptimisticList.java + * + * Created on January 4, 2006, 1:49 PM + * + * From "Multiprocessor Synchronization and Concurrent Data Structures", + * by Maurice Herlihy and Nir Shavit. + * Copyright 2006 Elsevier Inc. All rights reserved. + */ +package lists; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +/** + * Optimistic List implementation. + * @param T Item type. + * @author Maurice Herlihy + */ +public class OptimisticList { + /** + * First list entry + */ + private Entry head; + /** + * Constructor + */ + public OptimisticList() { + this.head = new Entry(Integer.MIN_VALUE); + this.head.next = new Entry(Integer.MAX_VALUE); + } + /** + * Add an element. + * @param item element to add + * @return true iff element was not there already + */ + public boolean add(T item) { + int key = item.hashCode(); + while (true) { + Entry pred = this.head; + Entry curr = pred.next; + while (curr.key <= key) { + pred = curr; curr = curr.next; + } + pred.lock(); curr.lock(); + try { + if (validate(pred, curr)) { + if (curr.key == key) { // present + return false; + } else { // not present + Entry entry = new Entry(item); + entry.next = curr; + pred.next = entry; + return true; + } + } + } finally { // always unlock + pred.unlock(); curr.unlock(); + } + } + } + /** + * Remove an element. + * @param item element to remove + * @return true iff element was present + */ + public boolean remove(T item) { + int key = item.hashCode(); + while (true) { + Entry pred = this.head; + Entry curr = pred.next; + while (curr.key < key) { + pred = curr; curr = curr.next; + } + pred.lock(); curr.lock(); + try { + if (validate(pred, curr)) { + if (curr.key == key) { // present in list + pred.next = curr.next; + return true; + } else { // not present in list + return false; + } + } + } finally { // always unlock + pred.unlock(); curr.unlock(); + } + } + } + /** + * Test whether element is present + * @param item element to test + * @return true iff element is present + */ + public boolean contains(T item) { + int key = item.hashCode(); + while (true) { + Entry pred = this.head; // sentinel node; + Entry curr = pred.next; + while (curr.key < key) { + pred = curr; curr = curr.next; + } + try { + pred.lock(); curr.lock(); + if (validate(pred, curr)) { + return (curr.key == key); + } + } finally { // always unlock + pred.unlock(); curr.unlock(); + } + } + } + /** + * Check that prev and curr are still in list and adjacent + * @param pred predecessor node + * @param curr current node + * @return whther predecessor and current have changed + */ + private boolean validate(Entry pred, Entry curr) { + Entry entry = head; + while (entry.key <= pred.key) { + if (entry == pred) + return pred.next == curr; + entry = entry.next; + } + return false; + } + /** + * list entry + */ + private class Entry { + /** + * actual item + */ + T item; + /** + * item's hash code + */ + int key; + /** + * next entry in list + */ + Entry next; + /** + * Synchronizes entry. + */ + Lock lock; + /** + * Constructor for usual entry + * @param item element in list + */ + Entry(T item) { + this.item = item; + this.key = item.hashCode(); + lock = new ReentrantLock(); + } + /** + * Constructor for sentinel entry + * @param key should be min or max int value + */ + Entry(int key) { + this.key = key; + lock = new ReentrantLock(); + } + /** + * Lock entry + */ + void lock() {lock.lock();} + /** + * Unlock entry + */ + void unlock() {lock.unlock();} + } +} diff --git a/src/main/Consumer.java b/src/main/Consumer.java deleted file mode 100644 index e47eb0c6184a8898529c44149b2d8a43f0f88063..0000000000000000000000000000000000000000 --- a/src/main/Consumer.java +++ /dev/null @@ -1,20 +0,0 @@ -package main; - -import enums.ProducerConsumerType; - -public class Consumer extends ProducerConsumer { - - public Consumer(Monitor monitor) { - super(monitor); - } - - @Override - public void operate() throws InterruptedException { - this.monitor.deq(); - } - - @Override - public ProducerConsumerType getType() { - return ProducerConsumerType.consumer; - } -} \ No newline at end of file diff --git a/src/main/Monitor.java b/src/main/Monitor.java deleted file mode 100644 index 9f0dfae3c8641947290bcb45b18aa2d3906ee3b2..0000000000000000000000000000000000000000 --- a/src/main/Monitor.java +++ /dev/null @@ -1,77 +0,0 @@ -package main; - -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -/* - This monitor implementation follows the book The Art of Multiprocessor Programming, Figure 8.5 (section 8.2.2, chapter 8), and section A.2.2 (Apendix A). -*/ -public class Monitor { - // Only one process can enqueue/dequeue at a time. - private final Lock lock = new ReentrantLock(); - // Wait while the queue is full. - private final Condition notFull = lock.newCondition(); - // Wait while the queue is empty. - private final Condition notEmpty = lock.newCondition(); - private final T[] items; - private int tail, head, count = 0; - - @SuppressWarnings("unchecked") - public Monitor(int maxCapacity) { - items = (T[]) new Object[maxCapacity]; - } - - public int getCurrentSize() { - return count; - } - - public void enq(T x) throws InterruptedException { - lock.lock(); - try { - // Wait while the queue is full. - while (count == items.length) { - notFull.await(); - } - // If the queue is not full, put the item in the tail position. - items[tail] = x; - /* - * It is a circular list. If tail is at the end on the list, it will need to go - * to the first position in the list. - */ - if (++tail == items.length) { - tail = 0; - } - ++count; - // Notifies that the queue is not empty. - notEmpty.signal(); - } finally { - lock.unlock(); - } - } - - public T deq() throws InterruptedException { - lock.lock(); - try { - // Wait while the queue is empty. - while (count == 0) { - notEmpty.await(); - } - // If the list is not empty, get the item in the head position. - T x = items[head]; - /* - * It is a circular list. If head is at the end on the list, it will need to go - * to the first position in the list. - */ - if (++head == items.length) { - head = 0; - } - --count; - // Notifies that the queue is not full. - notFull.signal(); - return x; - } finally { - lock.unlock(); - } - } -} \ No newline at end of file diff --git a/src/main/MonitorSynchronized.java b/src/main/MonitorSynchronized.java deleted file mode 100644 index 46f7341ceaabdb72d2f876758520922e65f9baeb..0000000000000000000000000000000000000000 --- a/src/main/MonitorSynchronized.java +++ /dev/null @@ -1,57 +0,0 @@ -package main; - -/* - This monitor implementation follows the book The Art of Multiprocessor Programming, Figure 8.5 (section 8.2.2, chapter 8), and section A.2.2 (Apendix A). -*/ -public class MonitorSynchronized { - private final T[] items; - private int tail, head, count = 0; - - @SuppressWarnings("unchecked") - public MonitorSynchronized(int maxCapacity) { - items = (T[]) new Object[maxCapacity]; - } - - public int getCurrentSize() { - return count; - } - - public synchronized void enq(T x) throws InterruptedException { - // Wait while the queue is full. - while (count == items.length) { - wait(); - } - // If the queue is not full, put the item in the tail position. - items[tail] = x; - /* - * It is a circular list. If tail is at the end on the list, it will need to go - * to the first position in the list. - */ - if (++tail == items.length) { - tail = 0; - } - ++count; - // Notifies that the queue is not empty. - notifyAll(); - } - - public synchronized T deq() throws InterruptedException { - // Wait while the queue is empty. - while (count == 0) { - wait(); - } - // If the list is not empty, get the item in the head position. - T x = items[head]; - /* - * It is a circular list. If head is at the end on the list, it will need to go - * to the first position in the list. - */ - if (++head == items.length) { - head = 0; - } - --count; - // Notifies that the queue is not full. - notifyAll(); - return x; - } -} \ No newline at end of file diff --git a/src/main/Producer.java b/src/main/Producer.java deleted file mode 100644 index a3c5ba61417c7081cf43fb267f6635aab35a463d..0000000000000000000000000000000000000000 --- a/src/main/Producer.java +++ /dev/null @@ -1,20 +0,0 @@ -package main; - -import enums.ProducerConsumerType; - -public class Producer extends ProducerConsumer { - - public Producer(Monitor monitor) { - super(monitor); - } - - @Override - public void operate() throws InterruptedException { - this.monitor.enq(Math.random()); - } - - @Override - public ProducerConsumerType getType() { - return ProducerConsumerType.producer; - } -} \ No newline at end of file diff --git a/src/main/ProducerConsumer.java b/src/main/ProducerConsumer.java deleted file mode 100644 index e59b25b855f17aeb9b280371e515b9ab913d7cb5..0000000000000000000000000000000000000000 --- a/src/main/ProducerConsumer.java +++ /dev/null @@ -1,40 +0,0 @@ -package main; - -import enums.ProducerConsumerType; - -public abstract class ProducerConsumer extends Thread { - - public abstract void operate() throws InterruptedException; - - public abstract ProducerConsumerType getType(); - - public volatile static boolean countingOperations = true; - protected final Monitor monitor; - private int operationsCount = 0; - - public ProducerConsumer(Monitor monitor) { - this.monitor = monitor; - } - - @Override - public void run() { - while (!this.isInterrupted()) { - try { - this.operate(); - if (ProducerConsumer.countingOperations) { - ++operationsCount; - } - } catch (InterruptedException e) { - break; - } - } - } - - public void startThread() { - this.start(); - } - - public int getOperationsCount() { - return operationsCount; - } -} \ No newline at end of file diff --git a/src/main/Test.java b/src/main/Test.java new file mode 100644 index 0000000000000000000000000000000000000000..a9236528ae12a1f9d609195337597e7a2bd328cd --- /dev/null +++ b/src/main/Test.java @@ -0,0 +1,94 @@ +package main; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import enums.ListOperationType; +import interfaces.GenericListInterface; +import lists.CoarseList; +import lists.IntegerListOperator; +import utils.RandomNumbers; + +public class Test { + + private static List getAllThreads(int numberThreads, GenericListInterface list) { + List threads = new ArrayList<>(); + for (int i = 0; i < numberThreads; i++) { + threads.add(new IntegerListOperator(list)); + } + return threads; + } + + private static int[] getOperationsCountSum(List threads) { + int[] count = new int[ListOperationType.values().length]; + for (IntegerListOperator thread : threads) { + for (int i = 0; i < count.length; i++) { + count[i] += thread.getOperationsCount()[i]; + } + } + return count; + } + + public static void main(String[] args) { + int listInitialSize = 10000;// Integer.parseInt(args[0]); + int listMaximumSize = 300;// Integer.parseInt(args[1]); + int numberThreads = 12;// Integer.parseInt(args[2]); + + System.out.println(); + System.out.println(String.format("Initial list size: %s", listInitialSize)); + System.out.println(String.format("Maximum list size: %s", listMaximumSize)); + System.out.println(String.format("Number of threads: %s", numberThreads)); + System.out.println(); + System.out.println("Starting test..."); + + // It is necessary to limit the size of the list. + GenericListInterface list = new CoarseList(); + for (int i = 0; i < listInitialSize; i++) { + list.add(RandomNumbers.getRandomInt()); + } + + System.out.println("Starting producers and consumers..."); + List threads = getAllThreads(numberThreads, list); + for (IntegerListOperator thread : threads) { + thread.start(); + } + + // Use a period of warm-up. During this period, operations are not counted. + System.out.println("Warming-up..."); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + } + IntegerListOperator.warmingUp = false; + + try { + System.out.println("Producing and consuming..."); + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e) { + } + + System.out.println("Interrupting threads..."); + System.out.println(); + for (IntegerListOperator thread : threads) { + try { + thread.interrupt(); + thread.join(); + } catch (InterruptedException e) { + } + } + + int currentMonitorSize = list.size(); + int[] operationsCount = getOperationsCountSum(threads); + + System.out.println(String.format("Current monitor size: %s", currentMonitorSize)); + System.out.println(String.format("Number of adds: %s", operationsCount[ListOperationType.add.ordinal()])); + System.out.println(String.format("Number of removes: %s", operationsCount[ListOperationType.remove.ordinal()])); + System.out.println( + String.format("Number of contains: %s", operationsCount[ListOperationType.contains.ordinal()])); + System.out + .println(String.format("Number of counts: %s", operationsCount[ListOperationType.listSize.ordinal()])); + + System.out.println("Finished."); + } +} \ No newline at end of file diff --git a/src/main/TestGuided.java b/src/main/TestGuided.java new file mode 100644 index 0000000000000000000000000000000000000000..f0eb40bcd9aa8c588f940c4ea40e5339e550dc76 --- /dev/null +++ b/src/main/TestGuided.java @@ -0,0 +1,21 @@ +package main; + +import interfaces.GenericListInterface; +import lists.CoarseList; +import lists.IntegerListOperator; + +public class TestGuided { + + public static void main(String[] args) { + IntegerListOperator.warmingUp = false; + GenericListInterface list = new CoarseList(); + list.add(Math.random()); + double a = Math.random(); + list.add(a); + list.remove(a); + + int currentMonitorSize = list.size(); + + System.out.println(String.format("Current monitor size: %s", currentMonitorSize)); + } +} diff --git a/src/utils/RandomNumbers.java b/src/utils/RandomNumbers.java new file mode 100644 index 0000000000000000000000000000000000000000..a9efb5c6697f58e2268cd70dda85f4064ef1daec --- /dev/null +++ b/src/utils/RandomNumbers.java @@ -0,0 +1,12 @@ +package utils; + +import java.util.Random; + +public final class RandomNumbers { + public static int getRandomInt() { + int max = Integer.MAX_VALUE; + Random rand = new Random(); + int randomNum = rand.nextInt(max); + return randomNum; + } +} \ No newline at end of file diff --git a/test/no-warm-up.pdf b/test/no-warm-up.pdf deleted file mode 100644 index 71933b1048716b7695aa22596308fb80e98ca54e..0000000000000000000000000000000000000000 Binary files a/test/no-warm-up.pdf and /dev/null differ diff --git a/test/output/100000-1000000-0-1-11.txt b/test/output/100000-1000000-0-1-11.txt deleted file mode 100644 index 0eff8c27eefe84665090347bd0ed3cb8ef666c90..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 148 -Number of enqueues: 72941156 -Number of dequeues: 73041008 -Finished. diff --git a/test/output/100000-1000000-0-11-1.txt b/test/output/100000-1000000-0-11-1.txt deleted file mode 100644 index 493c3eb5fe59e37739caf454000e0b66e9de3eae..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1000000 -Number of enqueues: 181159698 -Number of dequeues: 180259698 -Finished. diff --git a/test/output/100000-1000000-0-4-8.txt b/test/output/100000-1000000-0-4-8.txt deleted file mode 100644 index 278fb2fbd21e1fb7ec1f35ba81d0181bf46aab69..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 524 -Number of enqueues: 265699177 -Number of dequeues: 265798653 -Finished. diff --git a/test/output/100000-1000000-0-8-4.txt b/test/output/100000-1000000-0-8-4.txt deleted file mode 100644 index d78f8f7724e9908595ae0e582c689b47af34972f..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 4721 -Number of enqueues: 251492913 -Number of dequeues: 251588192 -Finished. diff --git a/test/output/100000-1000000-1-1-11.txt b/test/output/100000-1000000-1-1-11.txt deleted file mode 100644 index f54a2952f0efcc04ea516ca7e8e0d9b85becfb6d..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 138 -Number of enqueues: 81331763 -Number of dequeues: 81331649 -Finished. diff --git a/test/output/100000-1000000-1-11-1.txt b/test/output/100000-1000000-1-11-1.txt deleted file mode 100644 index 18ba559a0be0c07d0b7136124d26e47b61841ade..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1000000 -Number of enqueues: 143323457 -Number of dequeues: 143323204 -Finished. diff --git a/test/output/100000-1000000-1-4-8.txt b/test/output/100000-1000000-1-4-8.txt deleted file mode 100644 index c2526b2569aa4a029be06a6a703b3a1c5dcf21c1..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 2550 -Number of enqueues: 341154431 -Number of dequeues: 341152022 -Finished. diff --git a/test/output/100000-1000000-1-8-4.txt b/test/output/100000-1000000-1-8-4.txt deleted file mode 100644 index ac900b00550da0a9acb71a7d64380d0415f97eeb..0000000000000000000000000000000000000000 --- a/test/output/100000-1000000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1000000 -Number of enqueues: 425357393 -Number of dequeues: 425357393 -Finished. diff --git a/test/output/100000-300000-0-1-11.txt b/test/output/100000-300000-0-1-11.txt deleted file mode 100644 index 43fdd820228d23558e061b26dafbddc7944737bd..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 110 -Number of enqueues: 64816594 -Number of dequeues: 64916484 -Finished. diff --git a/test/output/100000-300000-0-11-1.txt b/test/output/100000-300000-0-11-1.txt deleted file mode 100644 index 26f6b66a9045764ebf39ff422756a14868f574bc..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 121890104 -Number of dequeues: 121690104 -Finished. diff --git a/test/output/100000-300000-0-4-8.txt b/test/output/100000-300000-0-4-8.txt deleted file mode 100644 index 4bf14631bf9e3ddf1161b4f45cdb10494b6cbef3..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 2800 -Number of enqueues: 306236045 -Number of dequeues: 306333245 -Finished. diff --git a/test/output/100000-300000-0-8-4.txt b/test/output/100000-300000-0-8-4.txt deleted file mode 100644 index 15b29507d76865aca14c2e9a56b4e34122f0110f..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 352858350 -Number of dequeues: 352658350 -Finished. diff --git a/test/output/100000-300000-1-1-11.txt b/test/output/100000-300000-1-1-11.txt deleted file mode 100644 index ce30f5c14608ba16823b81ea08d91e26fd4e3eb7..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 191 -Number of enqueues: 76947340 -Number of dequeues: 76947149 -Finished. diff --git a/test/output/100000-300000-1-11-1.txt b/test/output/100000-300000-1-11-1.txt deleted file mode 100644 index 4f1ca5d00cdbd797f018ba791a21cfeec8353b34..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 151617549 -Number of dequeues: 151463388 -Finished. diff --git a/test/output/100000-300000-1-4-8.txt b/test/output/100000-300000-1-4-8.txt deleted file mode 100644 index bf31432177edbd0829c10e355a8a7db59d9a2982..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 2291 -Number of enqueues: 329332600 -Number of dequeues: 329330498 -Finished. diff --git a/test/output/100000-300000-1-8-4.txt b/test/output/100000-300000-1-8-4.txt deleted file mode 100644 index 436b25d11c06fbfdb9df1e39347a08f1fdba1d06..0000000000000000000000000000000000000000 --- a/test/output/100000-300000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 440146190 -Number of dequeues: 440145219 -Finished. diff --git a/test/output/100000-500000-0-1-11.txt b/test/output/100000-500000-0-1-11.txt deleted file mode 100644 index eaf6e1cf2cd316f1ed18a2bc8f9f23aef719166b..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 188 -Number of enqueues: 70931942 -Number of dequeues: 71031754 -Finished. diff --git a/test/output/100000-500000-0-11-1.txt b/test/output/100000-500000-0-11-1.txt deleted file mode 100644 index d13cad15548b14b6c7bb96d54580cf8fbaae0edc..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 110077668 -Number of dequeues: 109677668 -Finished. diff --git a/test/output/100000-500000-0-4-8.txt b/test/output/100000-500000-0-4-8.txt deleted file mode 100644 index 2aa0a2dc2c079240f680e72bc223e45fc5da7029..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1075 -Number of enqueues: 270526490 -Number of dequeues: 270625415 -Finished. diff --git a/test/output/100000-500000-0-8-4.txt b/test/output/100000-500000-0-8-4.txt deleted file mode 100644 index 26f1c6c63c86d52289cbcfed9755f19fa7e402ff..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 494950 -Number of enqueues: 407199696 -Number of dequeues: 406804746 -Finished. diff --git a/test/output/100000-500000-1-1-11.txt b/test/output/100000-500000-1-1-11.txt deleted file mode 100644 index 48c238414bb205d7a53dfa85ffa0e278c9086196..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 147 -Number of enqueues: 76653780 -Number of dequeues: 76653633 -Finished. diff --git a/test/output/100000-500000-1-11-1.txt b/test/output/100000-500000-1-11-1.txt deleted file mode 100644 index 001a10a48c687205feb0155d352ac31eb7935394..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 153373529 -Number of dequeues: 153373529 -Finished. diff --git a/test/output/100000-500000-1-4-8.txt b/test/output/100000-500000-1-4-8.txt deleted file mode 100644 index 28afd708d57c8e90482b0e3139f32f3883c974dc..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1881 -Number of enqueues: 298009337 -Number of dequeues: 298007850 -Finished. diff --git a/test/output/100000-500000-1-8-4.txt b/test/output/100000-500000-1-8-4.txt deleted file mode 100644 index feba52c02deb8be6030fac150c3ca0affa6191c9..0000000000000000000000000000000000000000 --- a/test/output/100000-500000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 100000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 408916 -Number of enqueues: 417188563 -Number of dequeues: 417213375 -Finished. diff --git a/test/output/200000-1000000-0-1-11.txt b/test/output/200000-1000000-0-1-11.txt deleted file mode 100644 index bbfc2c5c5f6c0cb98a334bf4af452af28d2ca83e..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 135 -Number of enqueues: 82466878 -Number of dequeues: 82666743 -Finished. diff --git a/test/output/200000-1000000-0-11-1.txt b/test/output/200000-1000000-0-11-1.txt deleted file mode 100644 index c0d0caa56f534cfcd98b36d1f429ec63f5a0fe37..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1000000 -Number of enqueues: 135033414 -Number of dequeues: 134233414 -Finished. diff --git a/test/output/200000-1000000-0-4-8.txt b/test/output/200000-1000000-0-4-8.txt deleted file mode 100644 index fb83f521a970a0d74071a7dde095821e4af05750..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 3034 -Number of enqueues: 301689364 -Number of dequeues: 301886330 -Finished. diff --git a/test/output/200000-1000000-0-8-4.txt b/test/output/200000-1000000-0-8-4.txt deleted file mode 100644 index d5ee5db65bffd5a199539763688995bab8630043..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 757190 -Number of enqueues: 439862696 -Number of dequeues: 439305506 -Finished. diff --git a/test/output/200000-1000000-1-1-11.txt b/test/output/200000-1000000-1-1-11.txt deleted file mode 100644 index 1b88987c7781adde27051d18241c12f0b488e5e5..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 172 -Number of enqueues: 90308121 -Number of dequeues: 90307949 -Finished. diff --git a/test/output/200000-1000000-1-11-1.txt b/test/output/200000-1000000-1-11-1.txt deleted file mode 100644 index bd5d64817f02a8e2b144f134bfbf6877f58824b2..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1000000 -Number of enqueues: 154007797 -Number of dequeues: 154007797 -Finished. diff --git a/test/output/200000-1000000-1-4-8.txt b/test/output/200000-1000000-1-4-8.txt deleted file mode 100644 index 9f83212b13669de6071f4f24552876ca87f843aa..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1332 -Number of enqueues: 275991096 -Number of dequeues: 275990191 -Finished. diff --git a/test/output/200000-1000000-1-8-4.txt b/test/output/200000-1000000-1-8-4.txt deleted file mode 100644 index 538fdc06bf3a93bdf38ac04c6dd02131a7406129..0000000000000000000000000000000000000000 --- a/test/output/200000-1000000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 15369 -Number of enqueues: 437818907 -Number of dequeues: 438440197 -Finished. diff --git a/test/output/200000-300000-0-1-11.txt b/test/output/200000-300000-0-1-11.txt deleted file mode 100644 index ffb1ca4fd5ea9f463e4ae27954987480ee0ccd61..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 147 -Number of enqueues: 70179384 -Number of dequeues: 70379237 -Finished. diff --git a/test/output/200000-300000-0-11-1.txt b/test/output/200000-300000-0-11-1.txt deleted file mode 100644 index 3c781e98d17b6c73ac7219cb5c8323a1f62a4b7b..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 168095942 -Number of dequeues: 167995942 -Finished. diff --git a/test/output/200000-300000-0-4-8.txt b/test/output/200000-300000-0-4-8.txt deleted file mode 100644 index 3eb3a60cb8a71c6422aef2508ebddc42f349b35b..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 3156 -Number of enqueues: 340421480 -Number of dequeues: 340618324 -Finished. diff --git a/test/output/200000-300000-0-8-4.txt b/test/output/200000-300000-0-8-4.txt deleted file mode 100644 index b7424cbde747921aaae2bbfd75e5b398a5329916..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 404208720 -Number of dequeues: 404108720 -Finished. diff --git a/test/output/200000-300000-1-1-11.txt b/test/output/200000-300000-1-1-11.txt deleted file mode 100644 index 3a096a427c2b14e2843725e0c7acc7ece3ab901e..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 102 -Number of enqueues: 74589093 -Number of dequeues: 74588991 -Finished. diff --git a/test/output/200000-300000-1-11-1.txt b/test/output/200000-300000-1-11-1.txt deleted file mode 100644 index b62506b0ecb14a55ab07cb46e15b08c72a979fb3..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 164297660 -Number of dequeues: 164297082 -Finished. diff --git a/test/output/200000-300000-1-4-8.txt b/test/output/200000-300000-1-4-8.txt deleted file mode 100644 index ba860533c7aac61d33fa9dece9045a1517b4c41b..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 2395 -Number of enqueues: 331151194 -Number of dequeues: 331148840 -Finished. diff --git a/test/output/200000-300000-1-8-4.txt b/test/output/200000-300000-1-8-4.txt deleted file mode 100644 index 587e19e49f442548be0a4d9b94ac04903dd7382a..0000000000000000000000000000000000000000 --- a/test/output/200000-300000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 293416 -Number of enqueues: 498774854 -Number of dequeues: 498781196 -Finished. diff --git a/test/output/200000-500000-0-1-11.txt b/test/output/200000-500000-0-1-11.txt deleted file mode 100644 index bdc5556d07b71cb61eb310b3b4c33fcf81ec0c82..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 60 -Number of enqueues: 78532509 -Number of dequeues: 78732449 -Finished. diff --git a/test/output/200000-500000-0-11-1.txt b/test/output/200000-500000-0-11-1.txt deleted file mode 100644 index 4269d1d6d6b874d50cd3e0384629ea9eafc8575a..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 136868390 -Number of dequeues: 136568390 -Finished. diff --git a/test/output/200000-500000-0-4-8.txt b/test/output/200000-500000-0-4-8.txt deleted file mode 100644 index 6273a2633babb770456389aee9dde150d2eb11c5..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 2147 -Number of enqueues: 279794570 -Number of dequeues: 279992423 -Finished. diff --git a/test/output/200000-500000-0-8-4.txt b/test/output/200000-500000-0-8-4.txt deleted file mode 100644 index d68b6f13db8110333cfd7d0c6e375fcc5d43db06..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 396758052 -Number of dequeues: 396458052 -Finished. diff --git a/test/output/200000-500000-1-1-11.txt b/test/output/200000-500000-1-1-11.txt deleted file mode 100644 index 8a19b8effe38dea77da24dcb7a68611f09dc4c5b..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 72 -Number of enqueues: 76081425 -Number of dequeues: 76081353 -Finished. diff --git a/test/output/200000-500000-1-11-1.txt b/test/output/200000-500000-1-11-1.txt deleted file mode 100644 index be348d10f0486a8daf5892f26e0aad9ff6fef0c1..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 169051512 -Number of dequeues: 169051512 -Finished. diff --git a/test/output/200000-500000-1-4-8.txt b/test/output/200000-500000-1-4-8.txt deleted file mode 100644 index 01f6f31b538b06fc69e7a85c23b23ec0ec8c7d3c..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 3661 -Number of enqueues: 329321679 -Number of dequeues: 329318052 -Finished. diff --git a/test/output/200000-500000-1-8-4.txt b/test/output/200000-500000-1-8-4.txt deleted file mode 100644 index f2d95059e08e94b77cab2cd3e985953e2268d30c..0000000000000000000000000000000000000000 --- a/test/output/200000-500000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 200000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 31080 -Number of enqueues: 466082624 -Number of dequeues: 466051544 -Finished. diff --git a/test/output/300000-1000000-0-1-11.txt b/test/output/300000-1000000-0-1-11.txt deleted file mode 100644 index aeecf4c3ccdf857c5b6c8a2f0976090e71c19e15..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 119 -Number of enqueues: 68198713 -Number of dequeues: 68498594 -Finished. diff --git a/test/output/300000-1000000-0-11-1.txt b/test/output/300000-1000000-0-11-1.txt deleted file mode 100644 index 15589390440cb0587e6f058096395f847c62ac80..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1000000 -Number of enqueues: 164304782 -Number of dequeues: 163604782 -Finished. diff --git a/test/output/300000-1000000-0-4-8.txt b/test/output/300000-1000000-0-4-8.txt deleted file mode 100644 index 52e838fcba45b674982711907f3a2e33b1cfd1e4..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 982 -Number of enqueues: 267390758 -Number of dequeues: 267689776 -Finished. diff --git a/test/output/300000-1000000-0-8-4.txt b/test/output/300000-1000000-0-8-4.txt deleted file mode 100644 index 368f8325b94f121a939372a11ef6faf8d2fcbba4..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 998862 -Number of enqueues: 395303669 -Number of dequeues: 394604807 -Finished. diff --git a/test/output/300000-1000000-1-1-11.txt b/test/output/300000-1000000-1-1-11.txt deleted file mode 100644 index 3808a6f9070889e2c49cb9961292683abef5a2cb..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 240 -Number of enqueues: 81364006 -Number of dequeues: 81364012 -Finished. diff --git a/test/output/300000-1000000-1-11-1.txt b/test/output/300000-1000000-1-11-1.txt deleted file mode 100644 index 4608e44ecf06a3400d613a8d339007866110e2cd..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1000000 -Number of enqueues: 195998471 -Number of dequeues: 195993548 -Finished. diff --git a/test/output/300000-1000000-1-4-8.txt b/test/output/300000-1000000-1-4-8.txt deleted file mode 100644 index f8d33c9ae7fb30cb20849dfe36874f641336e2d3..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 1160 -Number of enqueues: 289882115 -Number of dequeues: 289880955 -Finished. diff --git a/test/output/300000-1000000-1-8-4.txt b/test/output/300000-1000000-1-8-4.txt deleted file mode 100644 index dc9db60c0a3c6a550fc37877cbd06cf26e5a29f4..0000000000000000000000000000000000000000 --- a/test/output/300000-1000000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 1000000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 115706 -Number of enqueues: 460563031 -Number of dequeues: 461437179 -Finished. diff --git a/test/output/300000-300000-0-1-11.txt b/test/output/300000-300000-0-1-11.txt deleted file mode 100644 index 194b50a671f7918a8f9fb8bf6feb0313d5c7e369..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 84 -Number of enqueues: 75037704 -Number of dequeues: 75337620 -Finished. diff --git a/test/output/300000-300000-0-11-1.txt b/test/output/300000-300000-0-11-1.txt deleted file mode 100644 index 8911511552a80ded458b119c1600359029275251..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 155069063 -Number of dequeues: 155069063 -Finished. diff --git a/test/output/300000-300000-0-4-8.txt b/test/output/300000-300000-0-4-8.txt deleted file mode 100644 index 3e1ca3e655e646b6dcd7b4c619c8bb3a8bd66ece..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 3149 -Number of enqueues: 292287060 -Number of dequeues: 292583911 -Finished. diff --git a/test/output/300000-300000-0-8-4.txt b/test/output/300000-300000-0-8-4.txt deleted file mode 100644 index 80cb8f3beb40da8876e5d9654a32caee67e52b07..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 300000 -Number of enqueues: 461306944 -Number of dequeues: 461306944 -Finished. diff --git a/test/output/300000-300000-1-1-11.txt b/test/output/300000-300000-1-1-11.txt deleted file mode 100644 index 25f13f150c8cc425f87f5abedecb5b174b56bf55..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 93 -Number of enqueues: 72542949 -Number of dequeues: 72542856 -Finished. diff --git a/test/output/300000-300000-1-11-1.txt b/test/output/300000-300000-1-11-1.txt deleted file mode 100644 index 1f694b7d0172c525ad3dd09978dfa1ccba5ee20c..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 298481 -Number of enqueues: 180593799 -Number of dequeues: 180595318 -Finished. diff --git a/test/output/300000-300000-1-4-8.txt b/test/output/300000-300000-1-4-8.txt deleted file mode 100644 index 00a0f6275dd8d2052418c35784d17b1f29da3f3b..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 2739 -Number of enqueues: 347239706 -Number of dequeues: 347236967 -Finished. diff --git a/test/output/300000-300000-1-8-4.txt b/test/output/300000-300000-1-8-4.txt deleted file mode 100644 index 0f87417977804b75b26dd6bfdd0a026f6fa42a07..0000000000000000000000000000000000000000 --- a/test/output/300000-300000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 300000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 280749 -Number of enqueues: 469839568 -Number of dequeues: 469837617 -Finished. diff --git a/test/output/300000-500000-0-1-11.txt b/test/output/300000-500000-0-1-11.txt deleted file mode 100644 index 117d2a96c8ee137fd2f06389ff44bf6f7c97753e..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-0-1-11.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 33 -Number of enqueues: 56419284 -Number of dequeues: 56719251 -Finished. diff --git a/test/output/300000-500000-0-11-1.txt b/test/output/300000-500000-0-11-1.txt deleted file mode 100644 index 20df7ea4d7724181f22eca18f9b732475ac89987..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-0-11-1.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 137925406 -Number of dequeues: 137725406 -Finished. diff --git a/test/output/300000-500000-0-4-8.txt b/test/output/300000-500000-0-4-8.txt deleted file mode 100644 index 8c48872a21331d91dcd247c43c1dbdca58f62b04..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-0-4-8.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 3197 -Number of enqueues: 308868356 -Number of dequeues: 309165159 -Finished. diff --git a/test/output/300000-500000-0-8-4.txt b/test/output/300000-500000-0-8-4.txt deleted file mode 100644 index 96e02a895bcbe74b7106020aa828e102bc00652e..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-0-8-4.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: false -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 393870087 -Number of dequeues: 393670087 -Finished. diff --git a/test/output/300000-500000-1-1-11.txt b/test/output/300000-500000-1-1-11.txt deleted file mode 100644 index 76f80b4dc735631848cf144a9a6efd3b13cc02d1..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-1-1-11.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 1 -Number of consumers: 11 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 44 -Number of enqueues: 78451839 -Number of dequeues: 78451795 -Finished. diff --git a/test/output/300000-500000-1-11-1.txt b/test/output/300000-500000-1-11-1.txt deleted file mode 100644 index 6f5ca5c9983ac49b60a10f39f5579c965e2d74c4..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-1-11-1.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 11 -Number of consumers: 1 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 500000 -Number of enqueues: 137730695 -Number of dequeues: 137730695 -Finished. diff --git a/test/output/300000-500000-1-4-8.txt b/test/output/300000-500000-1-4-8.txt deleted file mode 100644 index a80a17f8d2bdf9d38698301c17b52b669598dbbb..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-1-4-8.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 4 -Number of consumers: 8 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 103741 -Number of enqueues: 317856929 -Number of dequeues: 317753196 -Finished. diff --git a/test/output/300000-500000-1-8-4.txt b/test/output/300000-500000-1-8-4.txt deleted file mode 100644 index 5bf5ec3a4a90d020c7bfbf9f5f284e15c6cd907b..0000000000000000000000000000000000000000 --- a/test/output/300000-500000-1-8-4.txt +++ /dev/null @@ -1,17 +0,0 @@ - -Initial list size: 300000 -Maximum list size: 500000 -Use warm-up: true -Number of producers: 8 -Number of consumers: 4 - -Starting test... -Starting producers and consumers... -Warming-up... -Producing and consuming... -Interrupting threads... - -Current monitor size: 499459 -Number of enqueues: 416224010 -Number of dequeues: 416224256 -Finished. diff --git a/test/run-tests.sh b/test/run-tests.sh index 3bd70d55a6d5c2880e2c896fc50aaff61fda9a18..1f953a8c46f45ffcc4f1b13b9abd424262f7b3cd 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -6,17 +6,13 @@ ant cd - mkdir output -warm_up=(0 1) initial_sizes=(100000 200000 300000) maximum_sizes=(300000 500000 1000000) -producers=(1 4 8 11) # the sum of producers and consumers must be 12 -for w in "${warm_up[@]}"; do - for i in "${initial_sizes[@]}"; do - for m in "${maximum_sizes[@]}"; do - for p in "${producers[@]}"; do - c=$((12 - p)) - java -cp ../bin Test $i $m $w $p $c > output/$i-$m-$w-$p-$c.txt - done - done +threads=(6 12) +for ((i = 0; i < 3; i++)); do + for t in "${threads[@]}"; do + initial_size=${initial_sizes[i]} + maximum_size=${maximum_sizes[i]} + java -cp ../bin main/Test $initial_size $maximum_size $t > output/$initial_size-$maximum_size-$t.txt done done \ No newline at end of file diff --git a/test/warm-up.pdf b/test/warm-up.pdf deleted file mode 100644 index 283af251f99fc49e3fb26ba0fe1d2474f6f85081..0000000000000000000000000000000000000000 Binary files a/test/warm-up.pdf and /dev/null differ