Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
fcc23e9
Ensure volatile_mem_stream works with an example
maxwellpirtle Apr 19, 2024
7f12a8a
Remove `mcmini/detail` folder and favor `misc`
maxwellpirtle Apr 19, 2024
45147e6
Ensure `remote_address` is hashable
maxwellpirtle Apr 19, 2024
35bad89
Add working example with dummy wrapper values
maxwellpirtle Apr 20, 2024
3ed051f
Add `runner_mailbox` C struct in preparation for libmcmini
maxwellpirtle Apr 20, 2024
8bd7b2f
Rename `volatile_mem_stream` to `*_streambuf`
maxwellpirtle Apr 20, 2024
23d2f7f
Prepare mailbox storage in local_linux_process
maxwellpirtle Apr 20, 2024
f6ebe78
Add implementation for libmcmini.so for initial setup
maxwellpirtle Apr 20, 2024
41ac667
Add shared memory synchronization between libmcmini + McMini
maxwellpirtle Apr 21, 2024
b0d2a27
Add pipe(2) to process execvp errors in fork_process_source
maxwellpirtle Apr 21, 2024
0117c7a
Prepare to add runner mapping to state
maxwellpirtle Apr 21, 2024
544f86a
Add runner mapping management to state/mutable_state
maxwellpirtle Apr 22, 2024
4c82d9c
Reduce the common code from state_sequence and detached_state
maxwellpirtle Apr 22, 2024
7b53dd8
Add thread transitions modeling
maxwellpirtle Apr 22, 2024
9a66aca
Add dlsym loading of pthread symbols in libmcmini.so
maxwellpirtle Apr 22, 2024
1b94b6c
Add memcpy_v for volatile memory copy
maxwellpirtle Apr 24, 2024
6c90a88
Record the presence of runners in state_sequence for elements
maxwellpirtle Apr 24, 2024
04beb31
Add explicit `type` field to runner_mailbox
maxwellpirtle Apr 25, 2024
2805ac0
Wrap main in try-catch for unhandled exceptions
maxwellpirtle Apr 25, 2024
b4e1fcb
Add signal_tracker for process forking
maxwellpirtle Apr 30, 2024
977b0a8
Implement state regeneration in coordinator
maxwellpirtle May 11, 2024
dd81d9a
Handle main thread exiting the program
maxwellpirtle May 11, 2024
ee142c7
Replace `exit()` with `quick_exit()` after forking
maxwellpirtle May 11, 2024
580c7c1
Ignore SIG_IGN to SIGCHLD in libmcmini
maxwellpirtle May 11, 2024
b37de21
Add multi-threaded `exit(2)` call
maxwellpirtle May 12, 2024
3599152
Add the ability to raise an exception is a signal is captured
maxwellpirtle May 12, 2024
643607b
Fix subtle issue with `kill(2)` delay to grandchild process
maxwellpirtle May 12, 2024
2dbb0b5
Handle `fork(2)` failiing in the template on the model side
maxwellpirtle May 12, 2024
0e1cf71
Remove current `lib` directory
maxwellpirtle May 12, 2024
9766a29
Move `libmcmini` to `lib`
maxwellpirtle May 12, 2024
c45c77b
Begin porting DPOR code from main branch
maxwellpirtle May 13, 2024
f3b4d1c
Add remaining DPOR logic
maxwellpirtle May 14, 2024
541091d
Extract `diff_state` as its own class
maxwellpirtle May 14, 2024
66689b8
Demonstrate callbacks with new DPOR version
maxwellpirtle May 15, 2024
de73142
Add `mcmini_shm_file` to organize shared memory
maxwellpirtle May 15, 2024
01e0508
Add prctl(2) call in the McMini and child processes
maxwellpirtle May 15, 2024
a24e6dd
Add `mc_pthread_create` logic
maxwellpirtle May 15, 2024
3f230b9
Refine DPOR logic minus backtracking
maxwellpirtle May 19, 2024
1219ff4
Add backtracking logic to DPOR
maxwellpirtle May 19, 2024
3b47069
Reduce the use of unique_ptr inside the code base
maxwellpirtle May 20, 2024
f1a6fe8
Reduce the use of `std::unique_ptr` in function signatures
maxwellpirtle May 23, 2024
99ffc10
Remove unusued `volatile_mem_stream`
maxwellpirtle May 23, 2024
964b6c3
Add newline pre-commit check
maxwellpirtle May 23, 2024
c4f5bf0
Incorportate clang-tidy fixes
maxwellpirtle May 24, 2024
e709965
Remove unsued files in include/ dir
maxwellpirtle May 24, 2024
d6ad8d3
Add `runner_state` explicitly for deadlocks
maxwellpirtle May 24, 2024
fb3a0dd
Remove unnecessary std::move in visible_object
maxwellpirtle May 24, 2024
73aba40
Remove operator[] from `injective_function`
maxwellpirtle May 25, 2024
4c75bcd
Add (broken?) DPOR implementation with state slicing
maxwellpirtle May 25, 2024
14e870c
Fix subtle DPOR implementation issues
maxwellpirtle May 25, 2024
229f71e
Handle `sem_wait()` interrupts for threads
maxwellpirtle May 25, 2024
a4e5c50
Add dedicated signal-handling thread in McMini
maxwellpirtle May 25, 2024
5807b83
Add co-enabledness to DPOR
maxwellpirtle May 26, 2024
57b9de6
Move callback functions to separate files
maxwellpirtle May 26, 2024
1ba9b1d
Split template process logic into a separate C file
maxwellpirtle May 26, 2024
19b9527
Resolve clang-tidy warnings
maxwellpirtle May 31, 2024
93b63cd
Apply clang-format fixes to C src
maxwellpirtle May 31, 2024
47ae905
Rearrange C files in libmcmini
maxwellpirtle Jun 4, 2024
fb94aba
Move experimental McMini into `dmtcp` directory
maxwellpirtle Jun 5, 2024
f474fca
Begin accepting command line arguments
maxwellpirtle Jun 8, 2024
b3c8519
Ignore intercepted `sleep(3)` calls
maxwellpirtle Jun 8, 2024
c7a3f69
Add light-weight recording for pthread_mutex*
maxwellpirtle Jun 11, 2024
6c92bb4
Remove `static` from `rec_list_lock`
maxwellpirtle Jun 11, 2024
4a71751
Add `libmcmini_mode`/`dmtcp_launch` with plugin
maxwellpirtle Jun 26, 2024
bc566f5
Extract global resources into `xpc_resources` class
maxwellpirtle Jun 27, 2024
686c96e
Add wrapper around mkfifo(3)
maxwellpirtle Jun 27, 2024
180a0c1
Add DMTCP no-checkpoing critical sections
maxwellpirtle Jun 27, 2024
d1e9eca
Add the INVISIBLE_OPERATION_TYPE
maxwellpirtle Jul 27, 2024
3ff5295
Implement proof-of-concept for pthread_mutex_lock
maxwellpirtle Jul 27, 2024
14d1354
Fill in pthread_mutex_unlock
maxwellpirtle Jul 28, 2024
87b8859
Augment wrapper logic for consistent case template
maxwellpirtle Aug 1, 2024
66892ad
Add pthread_join wrapper logic
maxwellpirtle Aug 6, 2024
a08ef95
Add pthread_create implementation
maxwellpirtle Aug 27, 2024
446cb9e
Fix race condition in pthread_create during RECORD
maxwellpirtle Sep 5, 2024
46660ac
Fix compilation with g++
maxwellpirtle Sep 6, 2024
3d8c9d3
Use a weak symbol to detect if in record mode
gc00 Sep 7, 2024
76299b4
fixup: dlopen
maxwellpirtle Sep 9, 2024
0eedd67
Add PRE_CHECKPOINT_THREAD libmcmini_mode
maxwellpirtle Sep 21, 2024
23b372d
Fix compilation with libdmtcp_pthread_join
maxwellpirtle Sep 21, 2024
8e586b1
testing failure on Gene's machine
gc00 Sep 21, 2024
f067064
Add shared memory alloc on restart
maxwellpirtle Sep 23, 2024
d46ab02
Extract DMTCP_EVENT_INIT into McMini constructor
maxwellpirtle Sep 23, 2024
8f3719f
Translate recorded objects into the McMini model
maxwellpirtle Sep 28, 2024
b5cc4ae
Fix pthread_join recording and buggy shared mem
maxwellpirtle Sep 29, 2024
20654d4
Record runnable objects befor pending operations
maxwellpirtle Sep 29, 2024
a51e7f6
Use MCMINI_MULTIPLE_RESTARTS
maxwellpirtle Oct 3, 2024
e0e2c09
Don't set MCMINI_MULTIPLE_RESTARTS on later forks
maxwellpirtle Oct 3, 2024
896aef1
Call dlopen() for DMTCP only when recording
maxwellpirtle Oct 6, 2024
3b312bc
Fix pthread_mutex_init wrapper bug
maxwellpirtle Oct 6, 2024
70e3e8b
Refactor fork()/exec() in McMini to `target` class
maxwellpirtle Oct 10, 2024
ed933b4
Fix FIFO bkocking bug
maxwellpirtle Oct 10, 2024
5e2b31e
Fix (again) improper FIFO use
maxwellpirtle Oct 14, 2024
8dbfff6
Shutdown dmtcp_coordinator daemon via dmtcp_command
maxwellpirtle Oct 14, 2024
f45eea4
Temporarily disable prctl(2) for child processes
maxwellpirtle Oct 14, 2024
0d33cb9
Fix bug with clock vectors in experimental McMini
maxwellpirtle Nov 18, 2024
7157556
Fix move ctor bug with `local_linux_process`
maxwellpirtle Nov 18, 2024
187ff74
Add temporary fix for `dmtcp_coordinator` race
maxwellpirtle Nov 18, 2024
326de6a
Add convenience print method for visualizing state
maxwellpirtle Nov 18, 2024
43b657d
Add "deadly-embrace" example
maxwellpirtle Nov 18, 2024
125c7c1
Use more readable flags to `mkfifo`
maxwellpirtle Nov 18, 2024
b6ce8d2
Add bare-bones multithreaded_fork_process_source
maxwellpirtle Nov 24, 2024
6cf7dc5
Add distinct restart modes for `libmcmini.so`
maxwellpirtle Nov 24, 2024
7a229de
Fix subtle race between target branch processes
maxwellpirtle Nov 24, 2024
48b1dc9
Use `dmtcp_env.txt` at runtime to influence env vars
maxwellpirtle Nov 25, 2024
3958594
git rebase merging
aayushi363 Feb 8, 2024
f6c45c5
Condition variable wrappers and objects added
aayushi363 Nov 3, 2024
72fc8aa
modelling condition variable transitions
aayushi363 Nov 4, 2024
25233eb
wake up policy for cond. var. added
aayushi363 Dec 9, 2024
7cc4ca1
template thread integration
aayushi363 Jan 19, 2025
13497f5
condition variable waiting queue
aayushi363 Jan 19, 2025
4015336
added undefined status
aayushi363 Mar 15, 2025
8b9253b
serializing and deserializing of recorded info
aayushi363 Mar 15, 2025
3579887
cond_var example code
aayushi363 Mar 15, 2025
5e09f7a
README
aayushi363 Mar 27, 2025
503499b
changes to implement per thread cv state tracking
aayushi363 Mar 31, 2025
cc7b0a7
model side changes for per thread cv state tracking
aayushi363 Mar 31, 2025
cd5d978
cond broadcast and destroy added
aayushi363 Apr 1, 2025
bca660f
lost wakeup detection added
aayushi363 Apr 1, 2025
94bbbda
coding style fix
aayushi363 Apr 1, 2025
0d676d5
cv condition update
aayushi363 Jul 6, 2025
d051fb8
fix for processing all args
aayushi363 Jul 9, 2025
07a070a
Add (small) logging capabilities to libmcmini.so
maxwellpirtle Dec 2, 2024
58ef692
Take into account thread exits in deadlock
maxwellpirtle Dec 5, 2024
311a620
Use ptr to `real_world::target` to avoid object slicing
maxwellpirtle Dec 5, 2024
1e6f45f
Add `volatile` to `libmcmini_mode` to ensure loads
maxwellpirtle Dec 5, 2024
4305213
Add multithreaded_fork implementation
maxwellpirtle Dec 5, 2024
d617ea4
Add working multithreaded_fork() under DMTCP
maxwellpirtle Dec 9, 2024
9f9bccf
Add final impl of multithreaded_fork() with McMini
maxwellpirtle Dec 18, 2024
8acb686
Remove FIXME with sem_post()
maxwellpirtle Jan 30, 2025
077de51
Add semaphore implementation to deep debugging
maxwellpirtle Dec 8, 2024
529a44b
Add model for sem_destroy(3)
maxwellpirtle Feb 11, 2025
030215e
Use explicit call in multithreaded_fork()
maxwellpirtle Feb 11, 2025
a36c338
Add sem_destroy callback/impl
maxwellpirtle Feb 13, 2025
9b29a6c
Add defaults for transitions/dependency relations
maxwellpirtle Feb 13, 2025
1d89d19
Add misc changes to support semaphores
maxwellpirtle Feb 13, 2025
4e7f056
Add small comment cleanups/internal error message
maxwellpirtle Apr 9, 2025
2f63eed
Call `libpthread_condwait/broadcast()` to prevent cycles
maxwellpirtle Apr 10, 2025
5db0e56
Move `mc_template_process_loop_forever()` to loop.c
maxwellpirtle Jul 8, 2025
8166ad0
Add (tentative) support for assertion failiures
maxwellpirtle Jul 8, 2025
cbfc0aa
Add support for abort()/exit() calls (expected aborts/exits)
maxwellpirtle Jul 9, 2025
9bd3e55
Remove stray config files
maxwellpirtle Jul 10, 2025
11b41ac
Add support for varargs with logging
maxwellpirtle Jul 10, 2025
b166bc0
Change modeled semaphore to use int (not unsigned)
maxwellpirtle Jul 10, 2025
c08b9d8
Add explicit support for exit(EXIT_FAILURE)/abort()
maxwellpirtle Jul 10, 2025
7e27a7d
Temporarily remove PR_SETSUBREAPER code (assertions only)
maxwellpirtle Jul 16, 2025
9a77dde
Awake scheduler in the event of an abort
maxwellpirtle Jul 17, 2025
ede8efb
Handle already-exited threads in McMini
maxwellpirtle Jul 17, 2025
41e32c1
Re-add wait(NULL) while we don't have prctl
maxwellpirtle Jul 17, 2025
8684824
Support SIGSEGV inside template and branch processes
maxwellpirtle Jul 22, 2025
1fc9219
Complete support for abnormal termination in branches
maxwellpirtle Jul 23, 2025
799d4c6
Add test directory
maxwellpirtle Jul 24, 2025
b335ed4
Add light logging functionality to McMini
maxwellpirtle Jul 30, 2025
810ff1d
Begin adding fixes to multithreaded fork
maxwellpirtle Jul 30, 2025
b0a0181
Add additional sem_wait/sem_post rendez-vous
maxwellpirtle Jul 30, 2025
0ace4bf
Remove redundant `sem_wait(3)` call from multithreaded_fork()
maxwellpirtle Jul 31, 2025
5eb6b0f
Add logging level flag to `mcmini`
maxwellpirtle Jul 31, 2025
bf4e2af
Fix small bug without deep debugging
maxwellpirtle Jul 31, 2025
ec23183
Add `fast_multithreaded_fork()` impl
maxwellpirtle Jul 31, 2025
9c49b10
Move model checking relations into `config`
maxwellpirtle Jul 31, 2025
7ee3bbf
Record `pthread_t` mapping for pthread_join() for more stability
maxwellpirtle Aug 1, 2025
1a86b9b
Remove handling of SIGTSTOP and prctl subreaper
maxwellpirtle Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
50 changes: 31 additions & 19 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters-misc-non-private-member-variables-in-classes,readability-identifier-naming'
---
Checks: 'clang-diagnostic-*,clang-analyzer-*'
WarningsAsErrors: ''
HeaderFileExtensions:
- ''
- h
- hh
- hpp
- hxx
ImplementationFileExtensions:
- c
- cc
- cpp
- cxx
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.MemberCase
value: camelBack
- key: readability-identifier-naming.ParameterCase
value: camelBack
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.InlineNamespaceCase
value: lower_case
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
google-readability-namespace-comments.ShortNamespaceLines: '10'
cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
llvm-else-after-return.WarnOnUnfixable: 'false'
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
google-readability-namespace-comments.SpacesBeforeComments: '2'
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
google-readability-braces-around-statements.ShortStatementLines: '1'
google-readability-function-size.StatementThreshold: '800'
llvm-qualified-auto.AddConstToQualified: 'false'
llvm-else-after-return.WarnOnConditionVariables: 'false'
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
SystemHeaders: false
...
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-added-large-files
- id: check-case-conflict
- id: end-of-file-fixer
1 change: 0 additions & 1 deletion dmtcp
Submodule dmtcp deleted from 2763a2
7 changes: 7 additions & 0 deletions dmtcp/BUG.README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Sept. 21, 2024

export LD_LIBRARY_PATH=/home/gene/dmtcp.git/lib/dmtcp

~/dmtcp.git/bin/dmtcp_launch -i3 --disable-alloc-plugin --with-plugin ~/mcmini-pirtle/dmtcp/build/libmcmini.so ./src/examples/hello-world &

dmtcp_commnd -c
122 changes: 122 additions & 0 deletions dmtcp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
cmake_minimum_required(VERSION 3.10)
project(McMini-Revamp
VERSION 1.0.0
DESCRIPTION "A bite-sized model checker"
LANGUAGES C CXX)

# Require C11 and C++11
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

# Project configuration
option(BUILD_TESTS OFF)
option(VERBOSE_TESTING OFF)
set(MCMINI_DIR "${CMAKE_SOURCE_DIR}")
set(MCMINI_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
set(MCMINI_CMAKE_MODULE_DIR "${CMAKE_SOURCE_DIR}/cmake")
set(MCMINI_WITH_DMTCP OFF)

# Project source files
set(MCMINI_C_SRC
src/common/exit.c
src/common/mem.c
src/common/runner_mailbox.c
src/common/shm_config.c
)
set(MCMINI_CPP_SRC
src/mcmini/mcmini.cpp
src/mcmini/constants.cpp
src/mcmini/signal.cpp
src/mcmini/visible_object.cpp
src/mcmini/coordinator/coordinator.cpp
src/mcmini/log/filter.cpp
src/mcmini/log/logger.cpp
src/mcmini/model/detached_state.cpp
src/mcmini/model/diff_state.cpp
src/mcmini/model/program.cpp
src/mcmini/model/cond_var_arbitrary_policy.cpp
src/mcmini/model/cond_var_default_policy.cpp
src/mcmini/model/cond_var_single_grp_policy.cpp
src/mcmini/model/cond_var_wakegroup.cpp
src/mcmini/model/state_sequence.cpp
src/mcmini/model/transition_registry.cpp
src/mcmini/model/transition_sequence.cpp
src/mcmini/model/transitions/condition_variables.cpp
src/mcmini/model/transitions/mutex.cpp
src/mcmini/model/transitions/process.cpp
src/mcmini/model/transitions/thread.cpp
src/mcmini/model/transitions/semaphore.cpp
src/mcmini/model_checking/algorithms/classic_dpor.cpp
src/mcmini/model_checking/algorithms/clock_vector.cpp
src/mcmini/real_world/dmtcp_process_source.cpp
src/mcmini/real_world/fifo.cpp
src/mcmini/real_world/fork_process_source.cpp
src/mcmini/real_world/local_linux_process.cpp
src/mcmini/real_world/resources.cpp
src/mcmini/real_world/shm.cpp
src/mcmini/real_world/target.cpp
)
set(LIBMCMINI_C_SRC
src/common/exit.c
src/common/mem.c
src/common/multithreaded_fork.c
src/common/runner_mailbox.c
src/common/shm_config.c
src/lib/dmtcp-callback.c
src/lib/entry.c
src/lib/interception.c
src/lib/log.c
src/lib/main.c
src/lib/record.c
src/lib/sem-wrappers.c
src/lib/template/loop.c
src/lib/template/sig.c
src/lib/wrappers.c
src/mcmini/Thread_queue.c
)

set(MCMINI_EXTRA_COMPILER_FLAGS -Wall -Werror)
set(MCMINI_EXTRA_COMPILER_DEFINITIONS "")
set(MCMINI_EXTRA_LINK_FLAGS -lrt -pthread)

set(LIBMCMINI_EXTRA_COMPILER_FLAGS -Wall -Werror -fPIC)
set(LIBMCMINI_EXTRA_COMPILER_DEFINITIONS MC_SHARED_LIBRARY=1 DMTCP=1 LOGGING_ROOT="${CMAKE_SOURCE_PATH}")

# -lrt -> shared memory
# -pthread -> libpthread.so
# -lm -> math library
# -ldl -> dlsym etc.
set(LIBMCMINI_EXTRA_LINK_FLAGS -lrt -pthread -lm -ldl)

# libmcmini.so -> the dylib which is loaded
add_library(libmcmini SHARED "${LIBMCMINI_C_SRC}")
set_target_properties(libmcmini PROPERTIES OUTPUT_NAME "mcmini")

target_include_directories(libmcmini PUBLIC "${MCMINI_INCLUDE_DIR}")
target_compile_definitions(libmcmini
PUBLIC
"${LIBMCMINI_EXTRA_COMPILER_DEFINITIONS}")
target_compile_options(libmcmini
PRIVATE
"${LIBMCMINI_EXTRA_COMPILER_FLAGS}")
target_link_libraries(libmcmini
PUBLIC
"${LIBMCMINI_EXTRA_LINK_FLAGS}")

add_executable(mcmini "${MCMINI_CPP_SRC}" "${MCMINI_C_SRC}")
target_include_directories(mcmini PUBLIC "${MCMINI_INCLUDE_DIR}")
target_compile_definitions(mcmini
PUBLIC
"${MCMINI_EXTRA_COMPILER_DEFINITIONS}")
target_compile_options(mcmini
PRIVATE
"${MCMINI_EXTRA_COMPILER_FLAGS}")
target_link_libraries(mcmini
PUBLIC
"${MCMINI_EXTRA_LINK_FLAGS}")

add_subdirectory(src/examples)
add_subdirectory(test)
118 changes: 118 additions & 0 deletions dmtcp/Cond_Var_Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
This document provides a detailed explanation of the algorithm used to manage condition variables
to support checkpoint and replay and model checking at restart time.

## Thread State Tracking in Condition Variables
Each condition variable maintains a waiting_threads queue. The queue contains thread_queue_node entries that store:
- The thread's ID (runner_id_t)
- The thread's condition variable state (thread_cv_state)
## Recording Phase
Track condition variable states and thread queus to enable replay at restart time.
Each state in condition_variable_state corresponds to a phase in the lifescycle
of a condition variable. The status of a condition variable can be one of the following:
- CV_UNINITIALIZED: The condition variable has not been initialized yet via mc_pthread_cond_init.
- CV_INITIALIZED: The condition variable has been initialized and ready for use (post mc_pthread_cond_init).
- CV_PREWAITING: A thread is releasing the mutex but hasn't fully entered the wait state yet
(mc_pthread_cond_wait in progress), hence entered outer waiting room. This prevents checkpointing during the
unsafe gap between mutex unlock and wait.
- CV_WAITING: The thread has successfully entered the wait state i.e, consumed the signal or successfully returned
from libpthread_cond_timed_wait. (mc_pthread_cond_wait).
- CV_SIGNALED: A signal/broadcast has been sent; the condition variable resumes operation (mc_pthread_cond_signal/broadcast).
- CV_DESTROYED: The condition variable has been destroyed (post mc_pthread_cond_destroy).
Note that the status of a condition variable can be CV_SIGNALED even when there are no threads waiting on it.
This is because a thread can signal a condition variable even when no threads are waiting on it (spurious wakeup).

## Thread State Transitions

When a thread calls pthread_cond_wait():
- It's added to the waiting queue with state CV_PREWAITING.
- After successfully entering wait, its state changes to CV_WAITING.

When signaled:
- Its state changes to CV_SIGNALED
- The thread eventually dequeues and processes the signal

## Lost Wakeup Tracking

- The system tracks lost wakeups when signals are sent to condition variables with no waiting threads.
- These are recorded to ensure correct reconstruction during restart.

## Serializing Thread-Condition Relationships
The system uses a two-level approach to serialize thread relationships:

### CV_WAITERS_QUEUE Entries

- For each thread in a condition variable's waiting queue, a specialized entry is created.
- Contains: condition variable location, thread ID, and thread's CV state
- This preserves the complete thread queue state including waiting order

### State Preservation

- During serialization, the system traverses each condition variable's waiting queue.
- For each thread, it records its specific relationship with the condition variable.
- This enables accurate reconstruction during deserialization.

## Post-Restart Thread State Reconstruction
During restart, the system reconstructs condition variable states and thread relationships:

### Creating State Map

- CV_WAITERS_QUEUE entries are processed to build a cv_waiting_threads map
- Maps each condition variable address to an ordered list of (thread_id, cv_state) pairs

### Policy-Based Management
- Each condition variable has a policy object (ConditionVariableArbitraryPolicy) that:
- Maintains thread waiting queue order
- Preserves thread-specific state for each queued thread
- Manages signaling and state transitions

### Thread State Re-establishment
- During model object creation, waiting threads are added with their correct states
- The add_waiter_with_state() method ensures each thread's state is preserved

## Post-Restart Handling By Condition Variable State

### Case 1: CV_UNINITIALIZED
- Thread behavior: No special handling required
- System action: Condition variable will be initialized when first accessed

### Case 2: CV_INITIALIZED
- Thread behavior: Thread sends COND_INIT_TYPE message via mailbox
- System action:
- Scheduler initializes condition variable using libpthread_cond_init()
- No thread state tracking needed as no threads are waiting

### Case 3: CV_PREWAITING
- Thread behavior:
- Thread sends COND_ENQUEUE_TYPE message to re-enter waiting queue
- Thread waits for scheduler acknowledgment
- Thread sends COND_WAIT_TYPE to block until signaled
- System action:
- Scheduler adds thread to condition variable's waiting queue with CV_PREWAITING state
- Scheduler ensures mutex is released (critical for preventing deadlocks)
- Maintains pre-checkpoint thread state to ensure correct handling

### Case 4: CV_WAITING
- Thread behavior:
- Thread sends COND_ENQUEUE_TYPE message to re-register in waiting queue
- Thread sends COND_WAIT_TYPE to re-enter wait state
- System action:
- Scheduler adds thread to waiting queue with CV_WAITING state
- Reconstructs exact pre-checkpoint waiting order
- Thread properly blocks waiting for signal

### Case 5: CV_SIGNALED
- Thread behavior:
- If thread was signaled pre-checkpoint, it resumes execution
- If thread was waiting, it follows CV_WAITING behavior
- System action:
- Scheduler identifies which threads were signaled pre-checkpoint
- These threads are added to "wake groups" in the policy
- Ensures signaled threads receive priority for resumption
- Maintains proper FIFO ordering for signal processing

### Case 6: CV_DESTROYED
- Thread behavior: Thread sends COND_DESTROY_TYPE message
- System action:
- Scheduler verifies no threads are waiting (or handles error)
- Resources associated with condition variable are properly released
- No further operations allowed on the condition variable
Loading