[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi libCERTI/CMakeLists.txt libCERTI/SocketSH... [br_CERTI
From: |
certi-cvs |
Subject: |
[certi-cvs] certi libCERTI/CMakeLists.txt libCERTI/SocketSH... [br_CERTI_SHM_NEWGEN_dev] |
Date: |
Fri, 04 Sep 2009 08:53:25 +0000 |
CVSROOT: /sources/certi
Module name: certi
Branch: br_CERTI_SHM_NEWGEN_dev
Changes by: jbchaudron <jbchaudron> 09/09/04 08:53:24
Modified files:
libCERTI : CMakeLists.txt SocketSHM.cc SocketSHM.hh
SocketSHMPosix.cc SocketSHMPosix.hh
SocketSHMSysV.cc
test/utility : CMakeLists.txt
Added files:
test/utility : Main_SocketSHM.cc
Removed files:
test/utility : Main_SocketSHM_A.cc Main_SocketSHM_B.cc
Log message:
Refactoring Socket SHM
Remplace "Main_SocketSHM_A.cc" and "Main_SocketSHM_B.cc" by only one
"Main_SocketSHM.cc"
SocketSHMSysV OK!
SocketSHMPosix KO (Bug in Data Exchange)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/CMakeLists.txt?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.25.4.3&r2=1.25.4.4
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHM.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.4.2&r2=1.1.4.3
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHM.hh?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.4.2&r2=1.1.4.3
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHMPosix.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.2&r2=1.1.2.3
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHMPosix.hh?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.2&r2=1.1.2.3
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHMSysV.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/CMakeLists.txt?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.4.8.1&r2=1.4.8.2
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/Main_SocketSHM.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/Main_SocketSHM_A.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/Main_SocketSHM_B.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.2&r2=0
Patches:
Index: libCERTI/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/libCERTI/CMakeLists.txt,v
retrieving revision 1.25.4.3
retrieving revision 1.25.4.4
diff -u -b -r1.25.4.3 -r1.25.4.4
--- libCERTI/CMakeLists.txt 4 Sep 2009 08:00:19 -0000 1.25.4.3
+++ libCERTI/CMakeLists.txt 4 Sep 2009 08:53:23 -0000 1.25.4.4
@@ -123,6 +123,9 @@
message(STATUS "Shared Memory communication is currently unsupported on
Windows")
else(WIN32)
include_directories(${CERTI_SOURCE_DIR}/libHLA)
+
+ADD_DEFINITIONS(-DDEBUG)
+
SET(CERTI_SHM_SRCS
SHM.hh
SHMPosix.cc SHMPosix.hh
@@ -139,6 +142,7 @@
SocketSHMPosix.cc SocketSHMPosix.hh
SocketSHMSysV.cc SocketSHMSysV.hh
)
+
LIST(APPEND CERTI_SOCKET_SRCS ${CERTI_SHM_SRCS} ${CERTI_SEMAPHORE_SRCS}
${CERTI_SOCKET_SHM_SRC})
endif(WIN32)
Index: libCERTI/SocketSHM.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SocketSHM.cc,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -b -r1.1.4.2 -r1.1.4.3
--- libCERTI/SocketSHM.cc 4 Sep 2009 08:00:19 -0000 1.1.4.2
+++ libCERTI/SocketSHM.cc 4 Sep 2009 08:53:23 -0000 1.1.4.3
@@ -6,6 +6,22 @@
SocketSHM ::~SocketSHM (){}
// ************************************************
+// Method : SocketSHM::Connect()
+// ************************************************
+void SocketSHM::Connect() {
+
+if(_Side == SHM_CS){
+ _Sem_full_SC->Attach(Semaphore::buildSemName(_Name+"_FULL_SC")) ;
+ _Sem_empty_SC->Attach(Semaphore::buildSemName(_Name+"_EMPTY_SC")) ;
+ }
+else{
+ _Sem_full_CS->Attach(Semaphore::buildSemName(_Name+"_FULL_CS")) ;
+ _Sem_empty_CS->Attach(Semaphore::buildSemName(_Name+"_EMPTY_CS")) ;
+ }
+
+}
+
+// ************************************************
// Method : SocketSHM::Send(...)
// ************************************************
void SocketSHM::Send(void *Buffer) {
Index: libCERTI/SocketSHM.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SocketSHM.hh,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -b -r1.1.4.2 -r1.1.4.3
--- libCERTI/SocketSHM.hh 4 Sep 2009 08:00:19 -0000 1.1.4.2
+++ libCERTI/SocketSHM.hh 4 Sep 2009 08:53:23 -0000 1.1.4.3
@@ -19,6 +19,8 @@
// Destructor
virtual ~SocketSHM ();
+ virtual void Connect() ;
+
virtual void Send(void *Buffer) ; // To send Data on a memory segment
virtual void Receive(void *Buffer) ; // To receive Data on a memory
segment
Index: libCERTI/SocketSHMPosix.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SocketSHMPosix.cc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- libCERTI/SocketSHMPosix.cc 4 Sep 2009 08:00:19 -0000 1.1.2.2
+++ libCERTI/SocketSHMPosix.cc 4 Sep 2009 08:53:23 -0000 1.1.2.3
@@ -33,15 +33,6 @@
_Sem_full_CS->Create_Init(init_full,
Semaphore::buildSemName(Socket_Name+"_FULL_CS")) ;
_Sem_empty_CS->Create_Init(init_empty,
Semaphore::buildSemName(Socket_Name+"_EMPTY_CS")) ;
}
-if(_Side == SHM_CS){
- _Sem_full_SC->Attach(Semaphore::buildSemName(Socket_Name+"_FULL_SC")) ;
- _Sem_empty_SC->Attach(Semaphore::buildSemName(Socket_Name+"_EMPTY_SC")) ;
- }
-else{
- _Sem_full_CS->Attach(Semaphore::buildSemName(Socket_Name+"_FULL_CS")) ;
- _Sem_empty_CS->Attach(Semaphore::buildSemName(Socket_Name+"_EMPTY_CS")) ;
- }
-
}
// ************************************************
// Destructor
Index: libCERTI/SocketSHMPosix.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SocketSHMPosix.hh,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- libCERTI/SocketSHMPosix.hh 4 Sep 2009 08:00:19 -0000 1.1.2.2
+++ libCERTI/SocketSHMPosix.hh 4 Sep 2009 08:53:24 -0000 1.1.2.3
@@ -21,6 +21,7 @@
void Open();
+
}; // End of --> class SocketSHM
#endif
Index: libCERTI/SocketSHMSysV.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SocketSHMSysV.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- libCERTI/SocketSHMSysV.cc 4 Sep 2009 08:00:19 -0000 1.1.2.3
+++ libCERTI/SocketSHMSysV.cc 4 Sep 2009 08:53:24 -0000 1.1.2.4
@@ -32,14 +32,6 @@
_Sem_full_CS->Create_Init(init_full,
Semaphore::buildSemName(Socket_Name+"_FULL_CS")) ;
_Sem_empty_CS->Create_Init(init_empty,
Semaphore::buildSemName(Socket_Name+"_EMPTY_CS")) ;
}
-if(_Side == SHM_CS){
- _Sem_full_SC->Attach(Semaphore::buildSemName(Socket_Name+"_FULL_SC")) ;
- _Sem_empty_SC->Attach(Semaphore::buildSemName(Socket_Name+"_EMPTY_SC")) ;
- }
-else{
- _Sem_full_CS->Attach(Semaphore::buildSemName(Socket_Name+"_FULL_CS")) ;
- _Sem_empty_CS->Attach(Semaphore::buildSemName(Socket_Name+"_EMPTY_CS")) ;
- }
}
Index: test/utility/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/test/utility/CMakeLists.txt,v
retrieving revision 1.4.8.1
retrieving revision 1.4.8.2
diff -u -b -r1.4.8.1 -r1.4.8.2
--- test/utility/CMakeLists.txt 1 Sep 2009 11:09:22 -0000 1.4.8.1
+++ test/utility/CMakeLists.txt 4 Sep 2009 08:53:24 -0000 1.4.8.2
@@ -17,10 +17,11 @@
ADD_TEST(CertiUtilTests CertiUtilTests)
-ADD_EXECUTABLE(CertiProcessus_A Main_SocketSHM_A.cc SharedStruct.hh)
+ADD_EXECUTABLE(CertiProcessus_A Main_SocketSHM.cc SharedStruct.hh)
TARGET_LINK_LIBRARIES(CertiProcessus_A CERTI rt)
+SET_TARGET_PROPERTIES(CertiProcessus_A PROPERTIES COMPILE_FLAGS -DSIDE_SC)
-ADD_EXECUTABLE(CertiProcessus_B Main_SocketSHM_B.cc SharedStruct.hh)
+ADD_EXECUTABLE(CertiProcessus_B Main_SocketSHM.cc SharedStruct.hh)
TARGET_LINK_LIBRARIES(CertiProcessus_B CERTI rt)
INSTALL(TARGETS CertiProcessus_A CertiProcessus_B
Index: test/utility/Main_SocketSHM.cc
===================================================================
RCS file: test/utility/Main_SocketSHM.cc
diff -N test/utility/Main_SocketSHM.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/utility/Main_SocketSHM.cc 4 Sep 2009 08:53:24 -0000 1.1.2.1
@@ -0,0 +1,159 @@
+//
*****************************************************************************
+// To Compile without cmake :
+// g++ Main_SocketSHM_A.cc SocketSHMPosix.cc SemaphorePosix.cc
SocketSHMSysV.cc SHMSysV.cc SemaphoreSysV.cc -o Processus_A -lrt
+//
*****************************************************************************
+// For SysV use :
+// Before Use : --> #ipcs
+// You can see all the semaphore and the shared memory in use
+// --> #ipcrm -m id_memory to erase a memory segment
+// --> #ipcrm -s id_semaphore to erase a semaphore
+
+// Systems includes
+#include <limits>
+
+// Specifics includes
+#include "SocketSHMPosix.hh"
+#include "SocketSHMSysV.hh"
+#include "SharedStruct.hh"
+
+
+#define NAME_AB "SocketAB" // Socket Name
+
+
+/****************************************/
+/*********** MAIN PROGRAM ***************/
+/****************************************/
+
+int main(){
+
+// ************
+// DECLARATIONS
+// ************
+int i = 1 ; // Count for while
+shared_struct Data_Read ; // Data read in the Socket
+shared_struct Data_Write ; // Data write in the Socket
+
+#ifdef SIDE_SC
+SocketSHM::SHM_SIDE_t Socket_Side = SocketSHM::SHM_SC ; // which side am I?
+#else
+SocketSHM::SHM_SIDE_t Socket_Side = SocketSHM::SHM_CS ; // which side am I?
+#endif
+
+std::string command;
+
+
+int size ;
+size = (int) sizeof(shared_struct) ;
+
+// Initialize Datas
+Data_Read.Header = 0 ; Data_Read.Body =0.0 ;
+Data_Write.Header = 0 ; Data_Write.Body =0.0 ;
+
+// ************
+// CODE
+// ************
+
+// Posix Socket SHM
+SocketSHMPosix Socket_Posix_AB(NAME_AB,
+ Socket_Side,
+ size) ;
+
+// SystemV Socket SHM
+SocketSHMSysV Socket_SysV_AB(NAME_AB,
+ Socket_Side,
+ size) ;
+
+
+// Wainting for User Command n1
+
+std::cout << "************************************************************" <<
std::endl ;
+std::cout << "******* END OF INITIALIZATION PHASE 1 : ********************" <<
std::endl ;
+#ifdef SIDE_SC
+std::cout << "*************** Wait for Processus B ***********************" <<
std::endl ;
+#else
+std::cout << "*************** Wait for Processus A ***********************" <<
std::endl ;
+#endif
+std::cout << "************************************************************" <<
std::endl ;
+std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
+
+Socket_Posix_AB.Connect() ; // Connect to created Semaphores
+Socket_SysV_AB.Connect() ; // Connect to created Semaphores
+
+
+// Wainting for User Command n2
+std::cout << "*******************************************************" <<
std::endl ;
+std::cout << "*********** END OF INITIALIZATION PHASE 2 : ***********" <<
std::endl ;
+std::cout << "*** Click \"Posix\" to Open Posix Socket SHM **********" <<
std::endl ;
+std::cout << "*** Click \"SysV\" to Open Systeme V Socket SHM *******" <<
std::endl ;
+std::cout << "*******************************************************" <<
std::endl ;
+std::cin >> command;
+std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
+
+// Open the Socket
+if (command=="Posix") Socket_Posix_AB.Open() ;
+if (command=="SysV") Socket_SysV_AB.Open() ;
+
+// Wainting for User Command n3
+std::cout << "************************************************************" <<
std::endl ;
+std::cout << "******* END OF INITIALIZATION PHASE 3 : ********************" <<
std::endl ;
+std::cout << "****** Click \"ENTER\" to RunInter Process Exchange... *****" <<
std::endl ;
+std::cout << "************************************************************" <<
std::endl ;
+std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
+
+
+#ifdef SIDE_SC
+// Send to B For the First Time (INITIALIZE)
+// Send to B
+if (command=="Posix") Socket_Posix_AB.Send(&Data_Write) ;
+if (command=="SysV") Socket_SysV_AB.Send(&Data_Write) ;
+#endif
+
+ while(i<1000) {
+ std::cout << " *********** COMPUTING PHASE n°= " << i << "*************"
<< std ::endl ;
+
+ /**************************************/
+ /************* RECEIVING **************/
+ /**************************************/
+ // Read from B
+ if (command=="Posix") Socket_Posix_AB.Receive(&Data_Read) ;
+ if (command=="SysV") Socket_SysV_AB.Receive(&Data_Read) ;
+
+ /**************************************/
+ /************* COMPUTE ****************/
+ /**************************************/
+ // Print Receiving Data
+ std::cout << " ****** RECEIVE ******" << std ::endl ;
+ std::cout << "Processus A ||Â DataRead.Header = " << Data_Read.Header <<
std ::endl ;
+ std::cout << " Processus A || DataRead.Body = " << Data_Read.Body << std
::endl ;
+ std::cout << " ************************** " << std::endl ;
+
+ // Product a new Data
+ Data_Write.Header = Data_Read.Header + 1 ;
+ Data_Write.Body = Data_Read.Body + 0.1 ;
+
+ // Print Sending Data
+ std::cout << " ******** SEND ********" << std ::endl ;
+ std::cout << "Processus A ||Â DataWrite.Header = " << Data_Write.Header <<
std ::endl ;
+ std::cout << " Processus A || DataWrite.Body = " << Data_Write.Body << std
::endl ;
+ std::cout << " ************************ " << std ::endl ;
+
+ /**************************************/
+ /************* SENDING ****************/
+ /**************************************/
+ // Send to B
+ if (command=="Posix") Socket_Posix_AB.Send(&Data_Write) ;
+ if (command=="SysV") Socket_SysV_AB.Send(&Data_Write) ;
+
+ // On incremente le compteur
+ i++ ;
+
+ } // End of while (i<1000)
+
+// Waiting the two process are out of while boucle
+sleep(1) ;
+
+// Close the socket
+if (command=="Posix") Socket_Posix_AB.Close() ;
+if (command=="SysV") Socket_SysV_AB.Close() ;
+
+} // End of Main Program
Index: test/utility/Main_SocketSHM_A.cc
===================================================================
RCS file: test/utility/Main_SocketSHM_A.cc
diff -N test/utility/Main_SocketSHM_A.cc
--- test/utility/Main_SocketSHM_A.cc 1 Sep 2009 11:14:44 -0000 1.1.2.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,167 +0,0 @@
-//
*****************************************************************************
-// To Compile without cmake :
-// g++ Main_SocketSHM_A.cc SocketSHMPosix.cc SemaphorePosix.cc
SocketSHMSysV.cc SHMSysV.cc SemaphoreSysV.cc -o Processus_A -lrt
-//
*****************************************************************************
-// For SysV use :
-// Before Use : --> #ipcs
-// You can see all the semaphore and the shared memory in use
-// --> #ipcrm -m id_memory to erase a memory segment
-// --> #ipcrm -s id_semaphore to erase a semaphore
-
-// Systems includes
-#include <limits>
-
-// Specifics includes
-#include "SocketSHMPosix.hh"
-#include "SocketSHMSysV.hh"
-#include "SharedStruct.hh"
-
-
-#define NAME_A_TO_B "/foo1234" // Name SHM to broadcast from A to B
-#define NAME_B_TO_A "/foo5678" // Name SHM to broadcast from B to A
-
-#define KEY_A_TO_B 0x12345 // Key SHM to broadcast from A to B
-#define KEY_B_TO_A 0x6789 // Key SHM to broadcast from B to A
-
-#define NAME_FULL_AB "/Sem_full_AB" // Name Full Semaphore to synchronise
broadcast from A to B (Useful for Posix Semaphore)
-#define NAME_EMPTY_AB "/Sem_empty_AB" // Name Empty Semaphore to synchronise
broadcast from A to B (Useful for Posix Semaphore)
-#define NAME_FULL_BA "/Sem_full_BA" // Name Full Semaphore to synchronise
broadcast from B to A (Useful for Posix Semaphore)
-#define NAME_EMPTY_BA "/Sem_empty_BA" // Name Empty Semaphore to synchronise
broadcast from B to A (Useful for Posix Semaphore)
-
-#define KEY_FULL_AB 0x12 // // Key Full Semaphore to synchronise broadcast
from A to B (Useful for SysV Semaphore)
-#define KEY_EMPTY_AB 0x34 // Key Empty Semaphore to synchronise broadcast from
A to B (Useful for SysV Semaphore)
-#define KEY_FULL_BA 0x56 // Key Full Semaphore to synchronise broadcast from B
to A (Useful for SysV Semaphore)
-#define KEY_EMPTY_BA 0x78 // Key Empty Semaphore to synchronise broadcast from
B to A (Useful for SysV Semaphore)
-
-
-
-/****************************************/
-/*********** MAIN PROGRAM ***************/
-/****************************************/
-
-int main(){
-
-// ************
-// DECLARATIONS
-// ************
-int i = 1 ; // variable quelconque qui me sers pour un compteur plus bas...
-shared_struct Data_Read_A ; // Data lue dans la socketSHM.
-shared_struct Data_Write_A ; // Data ecrite dans la socketSHM.
-std::string command;
-
-
-int size ;
-size = (int) sizeof(shared_struct) ;
-
-// Initialisation des variables Data pour aucun soucis
-Data_Read_A.Header = 0 ; Data_Read_A.Body =0.0 ;
-Data_Write_A.Header = 0 ; Data_Write_A.Body =0.0 ;
-
-// ************
-// CODE
-// ************
-
-// Posix Socket SHM
-SocketSHMPosix Socket_Posix_AB(NAME_A_TO_B,
- NAME_B_TO_A,
- true,
- false,
- size,
- size,
- NAME_FULL_AB,
- NAME_EMPTY_AB,
- NAME_FULL_BA,
- NAME_EMPTY_BA) ;
-
-// SystemV Socket SHM
-SocketSHMSysV Socket_SysV_AB(NAME_A_TO_B,
- NAME_B_TO_A,
- KEY_A_TO_B,
- KEY_B_TO_A,
- true,
- false,
- size,
- size,
- KEY_FULL_AB,
- KEY_EMPTY_AB,
- KEY_FULL_BA,
- KEY_EMPTY_BA) ;
-
-
-// Wainting for User Command n1
-std::cout << "*******************************************************" <<
std::endl ;
-std::cout << "*********** END OF INITIALIZATION PHASE 1 : ***********" <<
std::endl ;
-std::cout << "*** Click \"Posix\" to Open Posix Socket SHM **********" <<
std::endl ;
-std::cout << "*** Click \"SysV\" to Open Systeme V Socket SHM *******" <<
std::endl ;
-std::cout << "*******************************************************" <<
std::endl ;
-std::cin >> command;
-std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
-
-// Open the Socket
-if (command=="Posix") Socket_Posix_AB.Open() ;
-if (command=="SysV") Socket_SysV_AB.Open() ;
-
-// Wainting for User Command n2
-std::cout << "************************************************************" <<
std::endl ;
-std::cout << "******* END OF INITIALIZATION PHASE 2 : ********************" <<
std::endl ;
-std::cout << "****** Click \"ENTER\" to RunInter Process Exchange... *****" <<
std::endl ;
-std::cout << "************************************************************" <<
std::endl ;
-std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
-
-
-
-// Send to B For the First Time (INITIALIZE)
-// Send to B
-if (command=="Posix") Socket_Posix_AB.Send(&Data_Write_A) ;
-if (command=="SysV") Socket_SysV_AB.Send(&Data_Write_A) ;
-
-
- while(i<1000) {
- std::cout << " *********** COMPUTING PHASE n°= " << i << "*************"
<< std ::endl ;
-
- /**************************************/
- /************* RECEIVING **************/
- /**************************************/
- // Read from B
- if (command=="Posix") Socket_Posix_AB.Receive(&Data_Read_A) ;
- if (command=="SysV") Socket_SysV_AB.Receive(&Data_Read_A) ;
-
- /**************************************/
- /************* COMPUTE ****************/
- /**************************************/
- // Print Receiving Data
- std::cout << " ****** RECEIVE ******" << std ::endl ;
- std::cout << "Processus A ||Â DataRead.Header = " << Data_Read_A.Header <<
std ::endl ;
- std::cout << " Processus A || DataRead.Body = " << Data_Read_A.Body << std
::endl ;
- std::cout << " ************************** " << std::endl ;
-
- // Product a new Data
- Data_Write_A.Header = Data_Read_A.Header + 1 ;
- Data_Write_A.Body = Data_Read_A.Body + 0.1 ;
-
- // Print Sending Data
- std::cout << " ******** SEND ********" << std ::endl ;
- std::cout << "Processus A ||Â DataWrite.Header = " << Data_Write_A.Header
<< std ::endl ;
- std::cout << " Processus A || DataWrite.Body = " << Data_Write_A.Body <<
std ::endl ;
- std::cout << " ************************ " << std ::endl ;
-
- /**************************************/
- /************* SENDING ****************/
- /**************************************/
- // Send to B
- if (command=="Posix") Socket_Posix_AB.Send(&Data_Write_A) ;
- if (command=="SysV") Socket_SysV_AB.Send(&Data_Write_A) ;
-
- // On incremente le compteur
- i++ ;
-
- } // End of while (i<1000)
-
-// Waiting the two process are out of while boucle
-sleep(1) ;
-
-// Close the socket
-if (command=="Posix") Socket_Posix_AB.Close() ;
-if (command=="SysV") Socket_SysV_AB.Close() ;
-
-} // End of Main Program
Index: test/utility/Main_SocketSHM_B.cc
===================================================================
RCS file: test/utility/Main_SocketSHM_B.cc
diff -N test/utility/Main_SocketSHM_B.cc
--- test/utility/Main_SocketSHM_B.cc 1 Sep 2009 11:14:44 -0000 1.1.2.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,153 +0,0 @@
-//
*****************************************************************************
-// To Compile without cmake :
-// g++ Main_SocketSHM_B.cc SocketSHMPosix.cc SemaphorePosix.cc
SocketSHMSysV.cc SHMSysV.cc SemaphoreSysV.cc -o Processus_B -lrt
-//
*****************************************************************************
-// For SysV use :
-// Before Use : --> #ipcs
-// You can see all the semaphore and the shared memory in use
-// --> #ipcrm -m id_memory to erase a memory segment
-// --> #ipcrm -s id_semaphore to erase a semaphore
-
-// Systems includes
-#include <limits>
-
-// Specifics includes
-#include "SocketSHMPosix.hh"
-#include "SocketSHMSysV.hh"
-#include "SharedStruct.hh"
-
-#define NAME_A_TO_B "/foo1234" // Name SHM to broadcast from A to B
-#define NAME_B_TO_A "/foo5678" // Name SHM to broadcast from B to A
-
-#define KEY_A_TO_B 0x12345 // Key SHM to broadcast from A to B
-#define KEY_B_TO_A 0x6789 // Key SHM to broadcast from B to A
-
-#define NAME_FULL_AB "/Sem_full_AB" // Name Full Semaphore to synchronise
broadcast from A to B (Useful for Posix Semaphore)
-#define NAME_EMPTY_AB "/Sem_empty_AB" // Name Empty Semaphore to synchronise
broadcast from A to B (Useful for Posix Semaphore)
-#define NAME_FULL_BA "/Sem_full_BA" // Name Full Semaphore to synchronise
broadcast from B to A (Useful for Posix Semaphore)
-#define NAME_EMPTY_BA "/Sem_empty_BA" // Name Empty Semaphore to synchronise
broadcast from B to A (Useful for Posix Semaphore)
-
-#define KEY_FULL_AB 0x12 // // Key Full Semaphore to synchronise broadcast
from A to B (Useful for SysV Semaphore)
-#define KEY_EMPTY_AB 0x34 // Key Empty Semaphore to synchronise broadcast from
A to B (Useful for SysV Semaphore)
-#define KEY_FULL_BA 0x56 // Key Full Semaphore to synchronise broadcast from B
to A (Useful for SysV Semaphore)
-#define KEY_EMPTY_BA 0x78 // Key Empty Semaphore to synchronise broadcast from
B to A (Useful for SysV Semaphore)
-
-
-/****************************************/
-/******** PROGRAMME PRINCIPAL ***********/
-/****************************************/
-
-int main(){
-
-// ************
-// DECLARATIONS
-// ************
-
-int i = 1 ; // variable quelconque qui me sers pour un compteur plus bas...
-shared_struct Data_Read_B ; // Data lue dans la socketSHM.
-shared_struct Data_Write_B ; // Data ecrite dans la socketSHM.
-std::string command;
-
-int size ;
-size = (int) sizeof(shared_struct) ;
-
-// ************
-// CODE
-// ************
-
-// Posix Socket SHM
-SocketSHMPosix Socket_Posix_AB(NAME_A_TO_B,
- NAME_B_TO_A,
- false,
- true,
- size,
- size,
- NAME_FULL_AB,
- NAME_EMPTY_AB,
- NAME_FULL_BA,
- NAME_EMPTY_BA) ;
-
-// SystemV Socket SHM
-SocketSHMSysV Socket_SysV_AB(NAME_A_TO_B,
- NAME_B_TO_A,
- KEY_A_TO_B,
- KEY_B_TO_A,
- false,
- true,
- size,
- size,
- KEY_FULL_AB,
- KEY_EMPTY_AB,
- KEY_FULL_BA,
- KEY_EMPTY_BA) ;
-
-// Wainting for User Command n1
-std::cout << "*******************************************************" <<
std::endl ;
-std::cout << "*********** END OF INITIALIZATION PHASE 1 : ***********" <<
std::endl ;
-std::cout << "*** Click \"Posix\" to Open Posix Socket SHM **********" <<
std::endl ;
-std::cout << "*** Click \"SysV\" to Open Systeme V Socket SHM *******" <<
std::endl ;
-std::cout << "*******************************************************" <<
std::endl ;
-std::cin >> command;
-std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
-
-// Open the Socket
-if (command=="Posix") Socket_Posix_AB.Open() ;
-if (command=="SysV") Socket_SysV_AB.Open() ;
-
-// Wainting for User Command n2
-std::cout << "******************************************************" <<
std::endl ;
-std::cout << "******* END OF INITIALIZATION PHASE 2 : **************" <<
std::endl ;
-std::cout << "*** Click \"ENTER\" to Run Inter Process Exchange ****" <<
std::endl ;
-std::cout << "******************************************************" <<
std::endl ;
-std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
-
- while(i<1000) {
- std::cout << " " << std
::endl ;
- std::cout << " *********** COMPUTING PHASE n°= " << i << "*************"
<< std ::endl ;
-
- /**************************************/
- /************* RECEIVING **************/
- /**************************************/
- // Receive from A
- if (command=="Posix") Socket_Posix_AB.Receive(&Data_Read_B) ;
- if (command=="SysV") Socket_SysV_AB.Receive(&Data_Read_B) ;
-
- /**************************************/
- /************* COMPUTE ****************/
- /**************************************/
- // Print Receiving Data
- std::cout << " ****** RECEIVE ******" << std ::endl ;
- std::cout << "Processus B ||Â DataRead.Header = " << Data_Read_B.Header <<
std ::endl ;
- std::cout << " Processus B || DataRead.Body = " << Data_Read_B.Body << std
::endl ;
- std::cout << " ************************** " << std ::endl ;
-
- // Product a new Data
- Data_Write_B.Header = Data_Read_B.Header + 1 ;
- Data_Write_B.Body = Data_Read_B.Body + 0.1 ;
-
- // Print Sending Data
- std::cout << " ******** SEND ********" << std ::endl ;
- std::cout << "Processus B ||Â DataWrite.Header = " << Data_Write_B.Header
<< std ::endl ;
- std::cout << " Processus B || DataWrite.Body = " << Data_Write_B.Body <<
std ::endl ;
- std::cout << " ************************ " << std ::endl ;
-
- /**************************************/
- /************* SENDING ****************/
- /**************************************/
- // Send to A
- if (command=="Posix") Socket_Posix_AB.Send(&Data_Write_B) ;
- if (command=="SysV") Socket_SysV_AB.Send(&Data_Write_B) ;
-
- // On incremente le compteur
- i++ ;
-
- } // Fin de la boucle while
-
-// Waiting the two process are out of while boucle
-sleep(1) ;
-
-// Close the socket
-if (command=="Posix") Socket_Posix_AB.Close() ;
-if (command=="SysV") Socket_SysV_AB.Close() ;
-
-} // Fin Programme Principal
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] certi libCERTI/CMakeLists.txt libCERTI/SocketSH... [br_CERTI_SHM_NEWGEN_dev],
certi-cvs <=