-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainClass.cs
More file actions
58 lines (54 loc) · 1.98 KB
/
MainClass.cs
File metadata and controls
58 lines (54 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
namespace TestConcurrencyUtilities
{
public class MainClass
{
public static void Main(string[] args) {
// Config:
double sleepTimeSeconds = 1.0;
// int testMagnitude = 10;
int sleepTimeMs = (int)Math.Round(sleepTimeSeconds*1000);
Console.WriteLine("Which test do you want to run?" +
"\n 1. Semaphore" +
"\n 2. Channel" +
"\n 3. Bound Channel" +
"\n 4. Mutex" +
"\n 5. Latch" +
"\n 6. Barrier" +
"\n 7. Light Switch" +
"\n 8. Exchanger" +
"\n 9. Active Object" +
"\n 10. Semaphore FIFO" +
"\n 11. Reader-Writer Lock" +
"\n Q. Quit");
string response = "INVALID_RESPONSE";
// response = "1"; // Can preload with an option to choose automatically
do {
if (response == "INVALID_RESPONSE") {
Console.Write("Enter: ");
response = Console.ReadLine().ToUpper();
}
switch (response) {
case "1" : TestSemaphore.Run(10, sleepTimeMs); break;
case "2" : TestChannel.Run(10, sleepTimeMs); break;
case "3" : TestBoundChannel.Run(10, 3, sleepTimeMs); break;
case "4" : TestMutex.Run(100000); break;
case "5" : TestLatch.Run(4, sleepTimeMs); break;
case "6" : TestBarrier.Run(4, sleepTimeMs); break;
case "7" : TestLightSwitch.Run(5, sleepTimeMs); break;
case "8" : TestExchanger.Run(12, sleepTimeMs); break;
case "9" : TestActiveObjects.Run(); break;
case "10": TestSemaphoreFIFO.Run(10, 300); break;
case "11": TestReaderWriter.Run(); break;
case "Q" : break;
default:
Console.WriteLine("Invalid response");
response = "INVALID_RESPONSE";
break;
}
} while (response == "INVALID_RESPONSE");
if (response != "Q")
TestSupport.Log(ConsoleColor.DarkGreen, "\nAll threads have finished");
}
}
}