summaryrefslogtreecommitdiff
path: root/quellcode/versuch4/multithreading
diff options
context:
space:
mode:
Diffstat (limited to 'quellcode/versuch4/multithreading')
-rwxr-xr-xquellcode/versuch4/multithreading/ReceiverDual.cpp123
-rwxr-xr-xquellcode/versuch4/multithreading/SupplierHigh.cpp126
-rwxr-xr-xquellcode/versuch4/multithreading/SupplierLow.cpp126
-rwxr-xr-xquellcode/versuch4/multithreading/benchDual.mpc35
-rwxr-xr-xquellcode/versuch4/multithreading/benchI.cpp137
-rwxr-xr-xquellcode/versuch4/multithreading/benchI.h130
-rwxr-xr-xquellcode/versuch4/multithreading/cpx.cpp85
-rwxr-xr-xquellcode/versuch4/multithreading/cpx.h73
8 files changed, 835 insertions, 0 deletions
diff --git a/quellcode/versuch4/multithreading/ReceiverDual.cpp b/quellcode/versuch4/multithreading/ReceiverDual.cpp
new file mode 100755
index 0000000..91f02f2
--- /dev/null
+++ b/quellcode/versuch4/multithreading/ReceiverDual.cpp
@@ -0,0 +1,123 @@
+#include <iostream>
+#include <stdio.h>
+
+
+//#include <asm/irq.h>
+
+#include "benchI.h"
+
+#include "orbsvcs/CosNamingC.h"
+#include <tao/RTCORBA/RTCORBA.h>
+
+COBA::ULong static_threads = 2;
+long nap_time = 1000;
+
+int registerServant(CORBA::Policy_ptr threadpoolPolicy, const char* poaName, PortableServer::POAManager_ptr poaManager, PortableServer::POA_ptr rootPOA, CORBA::ORB_ptr orb, RTCORBA::RTORB rtORB) {
+ return 0;
+}
+
+int main(int argc, char* argv[]){
+
+ struct sched_param schedparam;
+ schedparam.sched_priority = 99;
+
+ if (sched_setscheduler(0, SCHED_FIFO, &schedparam) != 0) {
+ fprintf(stderr, "%s: PID %d: sched_setscheduler() failed errno = %d\n", __FUNCTION__, getpid(), errno);
+ }
+
+ try{
+ // initialize ORB
+ CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "ServerORB");
+ std::cout<<"ORB initialized"<<std::endl;
+
+ // access RT Extensions
+ CORBA::Object_var rtorb = orb->resolve_initial_references("RTORB");
+ RTCORBA::RTORB_var rtORB = RTCORBA::RTORB::_narrow(rtorb);
+ std::cout<<"RT Extensions OK"<<std::endl;
+
+ // Network Settings
+ CORBA::Long sendBufferSize = 0;
+ CORBA::Long recvBufferSize = 0;
+ CORBA::Boolean keepAlive = 1;
+ CORBA::Boolean dontRoute = 1;
+ CORBA::Boolean noDelay = 1;
+
+ RTCORBA::TCPProtocolProperties_var tcpProperties = rtORB->create_tcp_protocol_properties(
+ sendBufferSize, recvBufferSize, keepAlive, dontRoute, noDelay, 1 /*network priority*/);
+
+ tcpProperties->enable_network_priority(1);
+
+ RTCORBA::ProtocolList protocols;
+ protocols.length(1);
+ protocols[0].protocol_type = 0; //TAO_TAG_IIOP_PROFILE;
+ protocols[0].transport_protocol_properties = RTCORBA::ProtocolProperties::_duplicate(tcpProperties.in());
+
+ // obtain rootPOA
+ CORBA::Object_var poa = orb->resolve_initial_references("RootPOA");
+ PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poa.in());
+
+ // activate POA Manager
+ PortableServer::POAManager_var poaManager = rootPOA->the_POAManager();
+ poaManager->activate();
+ std::cout<<"rootPOA OK"<<std::endl;
+
+ // create high Priority Policy
+ CORBA::PolicyList benchPolicy(2);
+ benchPolicy.length(2);
+ benchPolicy[0] = rtORB->create_priority_model_policy(RTCORBA::CLIENT_PROPAGATED, RTCORBA::maxPriority);
+ benchPolicy[1] = rtORB->create_server_protocol_policy(protocols);
+
+ //// create low Priority Policy
+ CORBA::PolicyList benchLowPolicy(2);
+ benchLowPolicy.length(2);
+ benchLowPolicy[0] = rtORB->create_priority_model_policy(RTCORBA::CLIENT_PROPAGATED, RTCORBA::minPriority);
+ benchLowPolicy[1] = rtORB->create_server_protocol_policy(protocols);
+
+ // create ObjectAdapter, assign Policy
+ PortableServer::POA_var benchPOA = rootPOA->create_POA("benchPOA", poaManager.in(), benchPolicy);
+ std::cout<<"Policy assigned"<<std::endl;
+
+ // create 2nd ObjectAdapter, assign low priority Policy
+ PortableServer::POA_var benchLowPOA = rootPOA->create_POA("benchLowPOA", poaManager.in(), benchLowPolicy);
+
+ // create the servant
+ benchmark_PutHigh_i bench_i;
+ benchmark_PutLow_i lowBench_i;
+
+ // activate servant
+ PortableServer::ObjectId_var objectID = benchPOA->activate_object(&bench_i);
+ CORBA::Object_var benchObj = benchPOA->id_to_reference(objectID.in());
+ CORBA::String_var ior = orb->object_to_string(benchObj.in());
+
+ PortableServer::ObjectId_var objectLowID = benchLowPOA->activate_object(&lowBench_i);
+ CORBA::Object_var lowBenchObj = benchLowPOA->id_to_reference(objectLowID.in());
+ CORBA::String_var ior2 = orb->object_to_string(lowBenchObj.in());
+ std::cout<<"Servant activated"<<std::endl;
+
+ // NameService
+ CORBA::Object_var namingObject = orb->resolve_initial_references("NameService");
+ CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(namingObject.in());
+ CosNaming::Name name(1);
+ name.length(1);
+ name[0].id = CORBA::string_dup("HighReceiver");
+ namingContext->bind(name, benchObj.in());
+ std::cout<<"Bound Receiver to NameService"<<std::endl;
+ name[0].id = CORBA::string_dup("LowReceiver");
+ namingContext->bind(name, lowBenchObj.in());
+ std::cout<<"Bound LowReceiver to NameService"<<std::endl;
+
+ // start ORB
+ orb->run();
+ std::cout<<"ORB ready"<<std::endl;
+
+ //destroy
+ rootPOA->destroy(1,1);
+ orb->destroy();
+ //enable_irq(18);
+ }catch(CORBA::Exception &any){
+ std::cout<<"Exception: "<<any<<std::endl;
+ //enable_irq(18);
+ }
+ return 0;
+}
+
diff --git a/quellcode/versuch4/multithreading/SupplierHigh.cpp b/quellcode/versuch4/multithreading/SupplierHigh.cpp
new file mode 100755
index 0000000..f159173
--- /dev/null
+++ b/quellcode/versuch4/multithreading/SupplierHigh.cpp
@@ -0,0 +1,126 @@
+#include <iostream>
+#include "benchC.h"
+#include "orbsvcs/CosNamingC.h"
+#include <tao/RTCORBA/RTCORBA.h>
+#include <unistd.h>
+
+#include "cpx.h"
+
+//benchmark::Put_var put;
+benchmark::PutHigh_var highPut;
+CPX cpx;
+
+void sigproc(int signo)
+{ signal(SIGRTMIN+29, sigproc);
+// int i1 = cpx.get(1);
+// int i2 /*= cpx.get(2)*/;
+// int i3 /*= cpx.get(3)*/;
+// put->allPorts(i1, i2, i3);
+ highPut->onePort(1, cpx.get(1));
+// put->allPorts(cpx.get(1), -1, -1);
+// put->onePort(3, cpx.get(3));
+}
+
+
+int main(int argc, char* argv[]){
+
+ struct sched_param schedparam;
+ schedparam.sched_priority = 99;
+
+ if (sched_setscheduler(0, SCHED_FIFO, &schedparam) != 0) {
+ fprintf(stderr, "%s: PID %d: sched_setscheduler() failed errno = %d\n", __FUNCTION__, getpid(), errno);
+ }
+
+ try{
+ // initialize ORB
+ CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "Client2ORB");
+ std::cout<<"ORB ok"<<std::endl;
+
+ // get RTORB
+ CORBA::Object_var rtorb = orb->resolve_initial_references("RTORB");
+ RTCORBA::RTORB_var rtORB = RTCORBA::RTORB::_narrow(rtorb.in());
+ std::cout<<"RTORB ok"<<std::endl;
+
+ // Network Settings
+ CORBA::Long sendBufferSize = 0;
+ CORBA::Long recvBufferSize = 0;
+ CORBA::Boolean keepAlive = 1;
+ CORBA::Boolean dontRoute = 1;
+ CORBA::Boolean noDelay = 1;
+
+ RTCORBA::TCPProtocolProperties_var tcpProperties = rtORB->create_tcp_protocol_properties(
+ sendBufferSize, recvBufferSize, keepAlive, dontRoute, noDelay, RTCORBA::maxPriority /*network priority*/);
+
+ tcpProperties->enable_network_priority(1);
+
+ RTCORBA::ProtocolList protocols;
+ protocols.length(1);
+ protocols[0].protocol_type = 0; //TAO_TAG_IIOP_PROFILE;
+ protocols[0].transport_protocol_properties = RTCORBA::ProtocolProperties::_duplicate(tcpProperties.in());
+
+ // NamingService
+ CORBA::Object_var namingObject = orb->resolve_initial_references("NameService");
+ CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(namingObject.in());
+ std::cout<<"NamingService ok"<<std::endl;
+
+ // receive Objects
+ CosNaming::Name name(1);
+ name.length(1);
+
+// name[0].id = CORBA::string_dup("Receiver");
+// CORBA::Object_var benchObj = namingContext->resolve(name);
+// put = benchmark::Put::_narrow(benchObj.in());
+
+ name[0].id = CORBA::string_dup("HighReceiver");
+ CORBA::Object_var lowBenchObj = namingContext->resolve(name);
+ highPut = benchmark::PutHigh::_narrow(lowBenchObj.in());
+
+ std::cout<<"TransferOjekt ok"<<std::endl;
+
+ // Private Connection Policy
+ CORBA::PolicyList pcPolicy(2);
+ pcPolicy.length(2);
+ pcPolicy[0] = rtORB->create_private_connection_policy();
+ pcPolicy[1] = rtORB->create_client_protocol_policy(protocols);
+
+ CORBA::Object_var newTran = highPut->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE);
+ highPut = benchmark::PutHigh::_narrow(newTran.in());
+ highPut = benchmark::PutHigh::_narrow(newTran.in());
+ std::cout<<"PrivateConnection, RTProtocol ok"<<std::endl;
+
+ // rtCurrent set priority
+ //CORBA::Object_var rtCurrentObj = orb->resolve_initial_references("RTCurrent");
+ //RTCORBA::Current_var rtCurrent = RTCORBA::Current::_narrow(rtCurrentObj.in());
+ //rtCurrent->the_priority(RTCORBA::maxPriority);
+ //std::cout<<"PriorityChange ok"<<std::endl;
+
+ // explicitly bind connection to server
+ //CORBA::PolicyList_var inconsistentPolicies;
+ //CORBA::Boolean status = transfer->_validate_connection(inconsistentPolicies.out());
+ //std::cout<<"explicit bind ok"<<std::endl;
+
+ // Input auf Interface schreiben
+ // ...
+ highPut->connect();
+ //lowPut->connect();
+ highPut->allPorts(0, 0, 0);
+ sleep(1);
+ highPut->onePort(1, 255);
+ sleep(1);
+ highPut->allPorts(0, 0, 0);
+
+ // signal handling
+ signal(SIGRTMIN+29, sigproc);
+
+ while(true){
+ pause();
+ }
+
+ // destroy ORB
+ orb->destroy();
+
+ }catch(CORBA::Exception &any){
+ std::cout<<"Exception occured: "<<any<<std::endl;
+ }
+ return 0;
+}
diff --git a/quellcode/versuch4/multithreading/SupplierLow.cpp b/quellcode/versuch4/multithreading/SupplierLow.cpp
new file mode 100755
index 0000000..47ae343
--- /dev/null
+++ b/quellcode/versuch4/multithreading/SupplierLow.cpp
@@ -0,0 +1,126 @@
+#include <iostream>
+#include "benchC.h"
+#include "orbsvcs/CosNamingC.h"
+#include <tao/RTCORBA/RTCORBA.h>
+#include <unistd.h>
+
+#include "cpx.h"
+
+//benchmark::Put_var put;
+benchmark::PutLow_var lowPut;
+CPX cpx;
+
+void sigproc(int signo)
+{ signal(SIGRTMIN+29, sigproc);
+// int i1 = cpx.get(1);
+// int i2 /*= cpx.get(2)*/;
+// int i3 /*= cpx.get(3)*/;
+// put->allPorts(i1, i2, i3);
+ lowPut->onePort(3, cpx.get(1));
+// put->allPorts(cpx.get(1), -1, -1);
+// put->onePort(3, cpx.get(3));
+}
+
+
+int main(int argc, char* argv[]){
+
+ struct sched_param schedparam;
+ schedparam.sched_priority = 99;
+
+ if (sched_setscheduler(0, SCHED_FIFO, &schedparam) != 0) {
+ fprintf(stderr, "%s: PID %d: sched_setscheduler() failed errno = %d\n", __FUNCTION__, getpid(), errno);
+ }
+
+ try{
+ // initialize ORB
+ CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "ClientORB");
+ std::cout<<"ORB ok"<<std::endl;
+
+ // get RTORB
+ CORBA::Object_var rtorb = orb->resolve_initial_references("RTORB");
+ RTCORBA::RTORB_var rtORB = RTCORBA::RTORB::_narrow(rtorb.in());
+ std::cout<<"RTORB ok"<<std::endl;
+
+ // Network Settings
+ CORBA::Long sendBufferSize = 0;
+ CORBA::Long recvBufferSize = 0;
+ CORBA::Boolean keepAlive = 1;
+ CORBA::Boolean dontRoute = 1;
+ CORBA::Boolean noDelay = 1;
+
+ RTCORBA::TCPProtocolProperties_var tcpProperties = rtORB->create_tcp_protocol_properties(
+ sendBufferSize, recvBufferSize, keepAlive, dontRoute, noDelay, RTCORBA::maxPriority /*network priority*/);
+
+ tcpProperties->enable_network_priority(1);
+
+ RTCORBA::ProtocolList protocols;
+ protocols.length(1);
+ protocols[0].protocol_type = 0; //TAO_TAG_IIOP_PROFILE;
+ protocols[0].transport_protocol_properties = RTCORBA::ProtocolProperties::_duplicate(tcpProperties.in());
+
+ // NamingService
+ CORBA::Object_var namingObject = orb->resolve_initial_references("NameService");
+ CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(namingObject.in());
+ std::cout<<"NamingService ok"<<std::endl;
+
+ // receive Objects
+ CosNaming::Name name(1);
+ name.length(1);
+
+// name[0].id = CORBA::string_dup("Receiver");
+// CORBA::Object_var benchObj = namingContext->resolve(name);
+// put = benchmark::Put::_narrow(benchObj.in());
+
+ name[0].id = CORBA::string_dup("LowReceiver");
+ CORBA::Object_var lowBenchObj = namingContext->resolve(name);
+ lowPut = benchmark::PutLow::_narrow(lowBenchObj.in());
+
+ std::cout<<"TransferOjekt ok"<<std::endl;
+
+ // Private Connection Policy
+ CORBA::PolicyList pcPolicy(2);
+ pcPolicy.length(2);
+ pcPolicy[0] = rtORB->create_private_connection_policy();
+ pcPolicy[1] = rtORB->create_client_protocol_policy(protocols);
+
+ CORBA::Object_var newTran = lowPut->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE);
+ lowPut = benchmark::PutLow::_narrow(newTran.in());
+ lowPut = benchmark::PutLow::_narrow(newTran.in());
+ std::cout<<"PrivateConnection, RTProtocol ok"<<std::endl;
+
+ // rtCurrent set priority
+ //CORBA::Object_var rtCurrentObj = orb->resolve_initial_references("RTCurrent");
+ //RTCORBA::Current_var rtCurrent = RTCORBA::Current::_narrow(rtCurrentObj.in());
+ //rtCurrent->the_priority(RTCORBA::maxPriority);
+ //std::cout<<"PriorityChange ok"<<std::endl;
+
+ // explicitly bind connection to server
+ //CORBA::PolicyList_var inconsistentPolicies;
+ //CORBA::Boolean status = transfer->_validate_connection(inconsistentPolicies.out());
+ //std::cout<<"explicit bind ok"<<std::endl;
+
+ // Input auf Interface schreiben
+ // ...
+ lowPut->connect();
+ //lowPut->connect();
+ lowPut->allPorts(0, 0, 0);
+ sleep(1);
+ lowPut->onePort(1, 255);
+ sleep(1);
+ lowPut->allPorts(0, 0, 0);
+
+ // signal handling
+ signal(SIGRTMIN+29, sigproc);
+
+ while(true){
+ pause();
+ }
+
+ // destroy ORB
+ orb->destroy();
+
+ }catch(CORBA::Exception &any){
+ std::cout<<"Exception occured: "<<any<<std::endl;
+ }
+ return 0;
+}
diff --git a/quellcode/versuch4/multithreading/benchDual.mpc b/quellcode/versuch4/multithreading/benchDual.mpc
new file mode 100755
index 0000000..44c2102
--- /dev/null
+++ b/quellcode/versuch4/multithreading/benchDual.mpc
@@ -0,0 +1,35 @@
+project(*ReceiverDual): strategies, rt_server, naming {
+ requires += exceptions
+ Source_Files {
+ cpx.cpp
+ benchI.cpp
+ ReceiverDual.cpp
+ }
+ Header_Files {
+ cpx.h
+ }
+}
+
+project(*SupplierLow): strategies, rt_client, naming {
+ requires += exceptions
+ Source_Files {
+ cpx.cpp
+ benchC.cpp
+ SupplierLow.cpp
+ }
+ Header_Files {
+ cpx.h
+ }
+}
+
+project(*SupplierHigh): strategies, rt_client, naming {
+ requires += exceptions
+ Source_Files {
+ cpx.cpp
+ benchC.cpp
+ SupplierHigh.cpp
+ }
+ Header_Files {
+ cpx.h
+ }
+} \ No newline at end of file
diff --git a/quellcode/versuch4/multithreading/benchI.cpp b/quellcode/versuch4/multithreading/benchI.cpp
new file mode 100755
index 0000000..cd185c0
--- /dev/null
+++ b/quellcode/versuch4/multithreading/benchI.cpp
@@ -0,0 +1,137 @@
+// -*- C++ -*-
+//
+// $Id$
+
+// **** Code generated by the The ACE ORB (TAO) IDL Compiler ****
+// TAO and the TAO IDL Compiler have been developed by:
+// Center for Distributed Object Computing
+// Washington University
+// St. Louis, MO
+// USA
+// http://www.cs.wustl.edu/~schmidt/doc-center.html
+// and
+// Distributed Object Computing Laboratory
+// University of California at Irvine
+// Irvine, CA
+// USA
+// http://doc.ece.uci.edu/
+// and
+// Institute for Software Integrated Systems
+// Vanderbilt University
+// Nashville, TN
+// USA
+// http://www.isis.vanderbilt.edu/
+//
+// Information about TAO is available at:
+// http://www.cs.wustl.edu/~schmidt/TAO.html
+
+// TAO_IDL - Generated from
+// be/be_codegen.cpp:1063
+
+#include "benchI.h"
+
+// Implementation skeleton constructor
+benchmark_PutLow_i::benchmark_PutLow_i (void)
+{
+}
+
+// Implementation skeleton destructor
+benchmark_PutLow_i::~benchmark_PutLow_i (void)
+{
+}
+
+void benchmark_PutLow_i::connect (
+
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ))
+{
+ // Add your implementation here
+ cpx = new CPX();
+}
+
+void benchmark_PutLow_i::onePort (
+ ::CORBA::Short portNo,
+ ::CORBA::Short value
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ))
+{
+ // Add your implementation here
+ std::string huhu = "";
+ for(int i=0; i<65000; i++) for(int i=0; i<5000; i++) if(i%2) huhu += "a";
+ cpx->set(portNo, value);
+}
+
+void benchmark_PutLow_i::allPorts (
+ ::CORBA::Short valPort1,
+ ::CORBA::Short valPort2,
+ ::CORBA::Short valPort3
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ))
+{
+ // Add your implementation here
+ if(valPort1>=0) cpx->set(1, valPort1);
+ if(valPort2>=0) cpx->set(2, valPort2);
+ if(valPort3>=0) cpx->set(3, valPort3);
+}
+
+// Implementation skeleton constructor
+benchmark_PutHigh_i::benchmark_PutHigh_i (void)
+{
+}
+
+// Implementation skeleton destructor
+benchmark_PutHigh_i::~benchmark_PutHigh_i (void)
+{
+}
+
+void benchmark_PutHigh_i::connect (
+
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ))
+{
+ // Add your implementation here
+ cpx = new CPX();
+}
+
+void benchmark_PutHigh_i::onePort (
+ ::CORBA::Short portNo,
+ ::CORBA::Short value
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ))
+{
+ // Add your implementation here
+ cpx->set(portNo, value);
+}
+
+void benchmark_PutHigh_i::allPorts (
+ ::CORBA::Short valPort1,
+ ::CORBA::Short valPort2,
+ ::CORBA::Short valPort3
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ))
+{
+ // Add your implementation here
+ if(valPort1>=0) cpx->set(1, valPort1);
+ if(valPort2>=0) cpx->set(2, valPort2);
+ if(valPort3>=0) cpx->set(3, valPort3);
+}
+
+
diff --git a/quellcode/versuch4/multithreading/benchI.h b/quellcode/versuch4/multithreading/benchI.h
new file mode 100755
index 0000000..fb33928
--- /dev/null
+++ b/quellcode/versuch4/multithreading/benchI.h
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+//
+// $Id$
+
+// **** Code generated by the The ACE ORB (TAO) IDL Compiler ****
+// TAO and the TAO IDL Compiler have been developed by:
+// Center for Distributed Object Computing
+// Washington University
+// St. Louis, MO
+// USA
+// http://www.cs.wustl.edu/~schmidt/doc-center.html
+// and
+// Distributed Object Computing Laboratory
+// University of California at Irvine
+// Irvine, CA
+// USA
+// http://doc.ece.uci.edu/
+// and
+// Institute for Software Integrated Systems
+// Vanderbilt University
+// Nashville, TN
+// USA
+// http://www.isis.vanderbilt.edu/
+//
+// Information about TAO is available at:
+// http://www.cs.wustl.edu/~schmidt/TAO.html
+
+// TAO_IDL - Generated from
+// be/be_codegen.cpp:1001
+
+#ifndef BENCHI_H_
+#define BENCHI_H_
+
+#include "benchS.h"
+#include "cpx.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+class benchmark_PutLow_i
+ : public virtual POA_benchmark::PutLow
+{
+private:
+ CPX* cpx;
+public:
+ // Constructor
+ benchmark_PutLow_i (void);
+
+ // Destructor
+ virtual ~benchmark_PutLow_i (void);
+
+ virtual
+ void connect (
+
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ));
+
+ virtual
+ void onePort (
+ ::CORBA::Short portNo,
+ ::CORBA::Short value
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ));
+
+ virtual
+ void allPorts (
+ ::CORBA::Short valPort1,
+ ::CORBA::Short valPort2,
+ ::CORBA::Short valPort3
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ));
+};
+
+class benchmark_PutHigh_i
+ : public virtual POA_benchmark::PutHigh
+{
+
+private:
+ CPX* cpx;
+public:
+ // Constructor
+ benchmark_PutHigh_i (void);
+
+ // Destructor
+ virtual ~benchmark_PutHigh_i (void);
+
+ virtual
+ void connect (
+
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ));
+
+ virtual
+ void onePort (
+ ::CORBA::Short portNo,
+ ::CORBA::Short value
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ));
+
+ virtual
+ void allPorts (
+ ::CORBA::Short valPort1,
+ ::CORBA::Short valPort2,
+ ::CORBA::Short valPort3
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::benchmark::invalidRequest
+ ));
+};
+
+
+#endif /* BENCHI_H_ */
+
diff --git a/quellcode/versuch4/multithreading/cpx.cpp b/quellcode/versuch4/multithreading/cpx.cpp
new file mode 100755
index 0000000..eebdc65
--- /dev/null
+++ b/quellcode/versuch4/multithreading/cpx.cpp
@@ -0,0 +1,85 @@
+/**
+ *
+ * \file cpx.cpp
+ * \brief read and write DIO
+ *
+ * \author Manuel Traut
+ * \version 2006-10-06
+ *
+ */
+
+#include "cpx.h"
+
+CPX::CPX(){
+ init();
+ std::cout<<"\n\n init ok\n\n";
+}
+
+int CPX::init(){
+
+ int fd_out = open(CPX_Input, O_RDWR | O_SYNC);
+ if (fd_out == -1){
+ std::cout<<"PBCIO: open failed"<<std::endl;
+ return(-1);
+ }
+ std::cout<<"CPX_Output_1 opened\n";
+
+ /* setup signal on interrupt */
+ param.signal = 1001;
+ param.pid = getpid();
+
+ if (ioctl(fd_out, CPX_DIO_IOCTL_ADD_SIG, (void *) &param) == -1) {
+ std::cout<<"signal map failed\n";
+ close(fd_out);
+ return(-1);
+ } else std::cout<<"signal map ok\n";
+
+ mapped_out = (u_char*) mmap (NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd_out, 0);
+ if (mapped_out == MAP_FAILED) {
+ std::cout<<"PBCIO: mmap failed\n";
+ close (fd_out);
+ return(-2);
+ }
+ std::cout<<"mmap ok\n";
+
+ DOUT = (u_char *) mapped_out;
+ DIN = (u_char *) mapped_out;
+
+ return 0;
+}
+
+short CPX::get(short port){
+ unsigned char value = 0;
+
+ switch(port){
+ case 1:
+ value = DIN[PORT1_IN];
+ break;
+ case 2:
+ value = DIN[PORT1_IN];
+ break;
+ case 3:
+ value = DIN[PORT1_IN];
+ break;
+ default:
+ std::cout<<"portNo: "<<port<<" incorrect\n";
+ }
+
+ return (short) value;
+}
+
+void CPX::set(short port, short value){
+ switch(port){
+ case 1:
+ DOUT[PORT1_OUT] = value;
+ break;
+ case 2:
+ DOUT[PORT2_OUT] = value;
+ break;
+ case 3:
+ DOUT[PORT3_OUT] = value;
+ break;
+ default:
+ std::cout<<"portNo: "<<port<<" incorrect\n";
+ }
+}
diff --git a/quellcode/versuch4/multithreading/cpx.h b/quellcode/versuch4/multithreading/cpx.h
new file mode 100755
index 0000000..7b4545a
--- /dev/null
+++ b/quellcode/versuch4/multithreading/cpx.h
@@ -0,0 +1,73 @@
+/**
+ *
+ * \file cpx.h
+ * \brief read and write DIO
+ *
+ * \author Manuel Traut
+ * \version 2006-10-06
+ *
+ */
+
+#ifndef CPX_H
+#define CPX_H
+
+#include <iostream>
+
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#define CPX_Input "/dev/iio2"
+#define CPX_Input_1 "/dev/iio2_in"
+#define CPX_Output_1 "/dev/iio2_out"
+
+#define PORT1_OUT 0x2c00
+#define PORT2_OUT 0x3c00
+#define PORT3_OUT 0x4c00
+
+#define PORT1_IN 0x5c00
+#define PORT2_IN 0x6c00
+#define PORT3_IN 0x7c00
+
+# ifndef PROT_READ
+# define PROT_READ 0x01
+# endif
+# ifndef PROT_WRITE
+# define PROT_WRITE 0x02
+# endif
+# ifndef MAP_SHARED
+# define MAP_SHARED 0x01
+# endif
+# ifndef MAP_PRIVATE
+# define MAP_PRIVATE 0x02
+# endif
+
+// ioctl (file descriptor, CPX_DIO_IOCTL_SET_SIGNAL, irq_send_signal_param*)
+// enable sending signal on interrupt
+// cpx_dio_set_signal_param.signal = signal to be sent to process
+#define CPX_DIO_IOCTL_BASE 0xCD
+
+typedef struct{
+ int signal; /* IN parameter: LINUX signal to be sent */
+ int pid; /* IN parameter: process id where signal should be sent to */
+}cpx_dio_set_signal_param;
+
+#define CPX_DIO_IOCTL_ADD_SIG _IOW(CPX_DIO_IOCTL_BASE, 3, cpx_dio_set_signal_param)
+#define CPX_DIO_IOCTL_DEL_SIG _IOW(CPX_DIO_IOCTL_BASE, 4, cpx_dio_set_signal_param)
+
+class CPX{
+ public:
+ CPX();
+ void set(short port, short value);
+ short get(short port);
+ private:
+ int init();
+ unsigned char *mapped_in;
+ unsigned char *mapped_out;
+ volatile u_char *DOUT;
+ volatile u_char *DIN;
+ cpx_dio_set_signal_param param;
+};
+
+#endif