-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for progress models (#731)
Co-authored-by: Hernan Ponce de Leon <[email protected]>
- Loading branch information
1 parent
22d8a02
commit cdc9529
Showing
42 changed files
with
3,341 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <assert.h> | ||
#include <stdatomic.h> | ||
|
||
// Required progress: fair | ||
|
||
atomic_int x = 0; | ||
|
||
void *thread_1(void *unused) | ||
{ | ||
while (x != 1); | ||
return 0; | ||
} | ||
|
||
void *thread_2(void *unused) | ||
{ | ||
x = 1; // May not get scheduled under any weak progress model | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t t1, t2; | ||
pthread_create(&t1, NULL, thread_1, NULL); | ||
pthread_create(&t2, NULL, thread_2, NULL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <assert.h> | ||
#include <stdatomic.h> | ||
|
||
// Required progress: HSA | ||
|
||
atomic_int x = 0; | ||
|
||
void *thread_1(void *unused) | ||
{ | ||
x = 1; // OBE might not schedule this thread | ||
} | ||
|
||
void *thread_2(void *unused) | ||
{ | ||
while (x != 1); | ||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t t1, t2; | ||
pthread_create(&t1, NULL, thread_1, NULL); | ||
pthread_create(&t2, NULL, thread_2, NULL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <assert.h> | ||
#include <stdatomic.h> | ||
|
||
// Required progress: HSA or OBE (stronger than unfair) | ||
|
||
atomic_int x = 0; | ||
|
||
void *thread_1(void *unused) | ||
{ | ||
while (x != 0); | ||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t t1, t2; | ||
pthread_create(&t1, NULL, thread_1, NULL); | ||
x = 1; | ||
// Under totally unfair scheduling, we can stop here so that T1 spins forever | ||
x = 0; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <assert.h> | ||
#include <stdatomic.h> | ||
|
||
// Required progress: OBE | ||
|
||
atomic_int x = 0; | ||
|
||
void *thread_1(void *unused) | ||
{ | ||
while (x != 0); | ||
return 0; | ||
} | ||
|
||
void *thread_2(void *unused) | ||
{ | ||
x = 1; | ||
// HSA may stop here causing a liveness issue (OBE cannot do this) | ||
x = 0; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t t1, t2; | ||
pthread_create(&t1, NULL, thread_1, NULL); | ||
pthread_create(&t2, NULL, thread_2, NULL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <assert.h> | ||
#include <stdatomic.h> | ||
|
||
atomic_int x = 0; | ||
|
||
// Required progress: Unfair (terminates under all progress models) | ||
|
||
void *thread_1(void *unused) | ||
{ | ||
while (x != 1); | ||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t t1, t2; | ||
x = 1; | ||
pthread_create(&t1, NULL, thread_1, NULL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
dartagnan/src/main/java/com/dat3m/dartagnan/configuration/ProgressModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.dat3m.dartagnan.configuration; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum ProgressModel { | ||
FAIR, // All threads are fairly scheduled | ||
HSA, // Lowest id thread gets fairly scheduled. | ||
OBE, // Threads that made at least one step get fairly scheduled. | ||
UNFAIR; // No fair scheduling | ||
|
||
public static ProgressModel getDefault() { | ||
return FAIR; | ||
} | ||
|
||
// Used to decide the order shown by the selector in the UI | ||
public static ProgressModel[] orderedValues() { | ||
ProgressModel[] order = {FAIR, HSA, OBE, UNFAIR}; | ||
// Be sure no element is missing | ||
assert (Arrays.asList(order).containsAll(Arrays.asList(values()))); | ||
return order; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.