Skip to content
Snippets Groups Projects
Commit 2d474942 authored by Ghofrane Amaimi's avatar Ghofrane Amaimi
Browse files

add SpawnThreads: not safe

parent 3020bee9
No related branches found
No related tags found
1 merge request!6Feature/ufscc emptiness check
Pipeline #4948 passed
...@@ -68,6 +68,8 @@ target_include_directories(cli11 INTERFACE "${THIRD_PARTY_INCLUDE_DIR}/cli11") ...@@ -68,6 +68,8 @@ target_include_directories(cli11 INTERFACE "${THIRD_PARTY_INCLUDE_DIR}/cli11")
include_directories(src) include_directories(src)
add_subdirectory(src) add_subdirectory(src)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# add tests # add tests
# enable_testing() # enable_testing()
# add_subdirectory(tests) # add_subdirectory(tests)
...@@ -4,13 +4,31 @@ ...@@ -4,13 +4,31 @@
#include "CNDFS.h" #include "CNDFS.h"
#include "ModelCheckBaseMT.h" #include "ModelCheckBaseMT.h"
#include <iostream> #include <iostream>
#include <spot/tl/apcollect.hh>
#include <spot/twa/twagraph.hh> #include <spot/twa/twagraph.hh>
#include <thread>
#include <vector>
using namespace std; using namespace std;
bool red=false;
bool blue=false;
thread_local bool cyan = false;
CNDFS::~CNDFS()=default; CNDFS::~CNDFS()=default;
void CNDFS::DfsBlue( ModelCheckBaseMT &mcl, shared_ptr<spot::twa_graph> af) { void CNDFS::DfsBlue(ModelCheckBaseMT &m,shared_ptr<spot::twa_graph> a) {
cout << "First state SOG from CNDFS " << mcl.getInitialMetaState() << endl; cout << "First state SOG from CNDFS " << m.getInitialMetaState() << endl;
cout << "First state BA from CNDFS " << af->acc() <<endl; cout << "First state BA from CNDFS " << a->get_init_state()<<endl;
}
void CNDFS::spawnThreads(int n, ModelCheckBaseMT &mcl, shared_ptr<spot::twa_graph> af )
{
std::vector<thread> threads(n);
// spawn n threads:
for (int i = 0; i < n; i++) {
threads.push_back(thread(DfsBlue,ref(mcl),af));
}
for (auto& th : threads) {
th.join();
}
} }
\ No newline at end of file
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
class CNDFS { class CNDFS {
public: public:
virtual ~CNDFS(); virtual ~CNDFS();
void DfsBlue(ModelCheckBaseMT &mcl, shared_ptr<spot::twa_graph> af); static void DfsBlue(ModelCheckBaseMT &mcl, shared_ptr<spot::twa_graph> af);
static void spawnThreads(int n, ModelCheckBaseMT &mcl, shared_ptr<spot::twa_graph> af);
}; };
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "Hybrid/MCHybridPOR/MCHybridSOGPOR.h" #include "Hybrid/MCHybridPOR/MCHybridSOGPOR.h"
#include "algorithm/CNDFS.h" #include "algorithm/CNDFS.h"
#include <typeinfo> #include <typeinfo>
#include <atomic>
using namespace std; using namespace std;
...@@ -509,6 +510,7 @@ int main(int argc, char **argv) ...@@ -509,6 +510,7 @@ int main(int argc, char **argv)
// build automata of the negation of the formula // build automata of the negation of the formula
auto d = spot::make_bdd_dict(); auto d = spot::make_bdd_dict();
spot::twa_graph_ptr af = formula2Automaton(negate_formula.f, d, dot_formula); spot::twa_graph_ptr af = formula2Automaton(negate_formula.f, d, dot_formula);
// twa_graph class
shared_ptr<spot::twa_graph> aa = formula2Automaton(negate_formula.f, d, dot_formula); shared_ptr<spot::twa_graph> aa = formula2Automaton(negate_formula.f, d, dot_formula);
// create the SOG // create the SOG
...@@ -519,14 +521,14 @@ int main(int argc, char **argv) ...@@ -519,14 +521,14 @@ int main(int argc, char **argv)
if (algorithm == "UFSCC" || algorithm == "CNDFS") if (algorithm == "UFSCC" || algorithm == "CNDFS")
{ {
cout<<"pointeur sur le sog "<< typeid(mcl).name() <<endl; cout<<"pointeur sur le sog "<< typeid(mcl).name() <<endl;
//cout << "pointeur sur le BA "<< typeid(af).name() <<endl; cout <<"pointeur sur le BA "<< typeid(aa).name() <<endl;
cout << "pointeur sur le BA "<< typeid(aa).name() <<endl;
//atomic<ModelCheckBaseMT> (*mcl);
//shared_ptr< atomic<spot::twa_graph>> aa;
CNDFS n; CNDFS n;
//n.DfsBlue(); //n.DfsBlue(*mcl, aa);
n.DfsBlue(*mcl, aa); n.spawnThreads(4,*mcl,aa);
return(0); return(0);
//exit(0);
} }
else // run on the fly sequential model-checking else // run on the fly sequential model-checking
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment