Skip to content

A lock-free software-only runtime system for C++ that eliminates concurrency errors for fork-join parallel programs

Notifications You must be signed in to change notification settings

wyk9787/G-Thread

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

G-Thread

G-Thread is a lock-free software-only runtime system for C++ that eliminates concurrency errors for fork-join parallel programs. G-Thread reimplements a subset of the system called Grace.

By including the header file and linking against the G-Thread library, your pthread programs are easily free of concurrency errors such as atomicity violation, order violation, race conditions, etc.

Proposal and final report of this project can be found in misc directory.

Usage

To adapt your pthread program to use G-Thread is simple:

  1. Include the library #include "libgthread.hh"

  2. Copy over your program into src directory and run make

  3. Inside src directory, run ./gtest

test.cc is an example program that illustrates the elimination of race condition using G-Thread. Other examples can be found in example directory or you can easily adapt problematic programs in pthread directory to use gthread by including libgthread.hh.

To run this test:

cd src/
cp ../example/test.cc ./
make clean all
./src/gtest

To print out the logging information while G-Thread is running, uncomment this line to define LOGPRINT macro and recompile the program.

Limitations

Those are some of the limitations that G-Thread currently has:

  1. G-Thread only supports fork-join parallelism and does not support programs with concurrency control through synchronization primitives such as condition variables.

  2. Although stack and heap memory will work without any concurrency issues, the global variable still need to be protected by locks or other synchronization control to avoid concurrency bugs.

  3. I/O (e.g. printing to the console or writing to a file) within each thread can happen multiple times if that particular thread is rolled back due to a conflict with other thread.

  4. No memory used by user's program or G-Thread will ever be reclaimed by OS even if user explicitly called free.

  5. Return value from the thread isn't supported yet.

  6. Only heap-allocated memory can be passed into threads without concurrency issues. Stack-allocated variables passed into threads are not supported at this moment.

Order violation

G-Thread is able to sacrifice some performance to guarantee sequential semantics of the program. You can comment out this line to not define NO_ORDER macro and recompile the program to let the program be free of order violation. See order_violation.cc for illustration of order violation.

About

A lock-free software-only runtime system for C++ that eliminates concurrency errors for fork-join parallel programs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published