Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r605 - in branches/itanium2: Core/Shm StandAlone
- Date: Fri, 7 Oct 2005 04:18:11 -0600 (MDT)
Author: abe
Date: Fri Oct 7 04:18:10 2005
New Revision: 605
Added:
branches/itanium2/StandAlone/mf_stream_test.cc
Modified:
branches/itanium2/Core/Shm/MFStreamData.cc
branches/itanium2/Core/Shm/MFStreamData.h
branches/itanium2/Core/Shm/ShmSemaphore.h
branches/itanium2/StandAlone/CMakeLists.txt
Log:
Added a test program for the shm image display.
bin/manta -np 4 -imagedisplay "mf( -key 400 )" &
bin/mf_stream_test -key 400
The test program will try to attach to the shm segment already created by
manta and then will output the front and back
buffer fields every half second. Test program works on fisher.
A StandAlone/mf_stream_test.cc
M StandAlone/CMakeLists.txt
M Core/Shm/ShmSemaphore.h
M Core/Shm/MFStreamData.cc
M Core/Shm/MFStreamData.h
Modified: branches/itanium2/Core/Shm/MFStreamData.cc
==============================================================================
--- branches/itanium2/Core/Shm/MFStreamData.cc (original)
+++ branches/itanium2/Core/Shm/MFStreamData.cc Fri Oct 7 04:18:10 2005
@@ -50,6 +50,9 @@
#define PERM_FILE ( S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
S_IWOTH )
+
+
+
void *MFStreamData::operator new( size_t bytes, int key_, int flag ) {
int id;
@@ -59,7 +62,7 @@
// Check to see if we should create a new segment.
if ((errno == ENOENT) && (flag == STRM_SHM_CREATE)) {
-
+
// Try to create again.
if ((id = shmget( key_, sizeof(MFStreamData), IPC_CREAT|PERM_FILE ))
== -1) {
throw new ErrnoException( "Cannot create shm: ", errno, __FILE__,
__LINE__ );
@@ -94,6 +97,8 @@
xres( xres_ ),
yres( yres_ ),
zres( 4 ),
+ frontBuffer( 0 ),
+ backBuffer ( 1 ),
semaphore( key, LOCK_OPEN )
{
}
Modified: branches/itanium2/Core/Shm/MFStreamData.h
==============================================================================
--- branches/itanium2/Core/Shm/MFStreamData.h (original)
+++ branches/itanium2/Core/Shm/MFStreamData.h Fri Oct 7 04:18:10 2005
@@ -94,8 +94,12 @@
// Allocates a new Media Fusion Stream Data struct using the specified
shm key.
void *operator new( size_t bytes, int key_, int flag );
- // Constructor specific actual image size.
+ // Constructor specifies actual image size.
MFStreamData( int xres_, int yres_ );
+
+ // Constructor for attaching to an existing shm segment.
+ MFStreamData() { };
+
~MFStreamData();
// Swap buffers method.
Modified: branches/itanium2/Core/Shm/ShmSemaphore.h
==============================================================================
--- branches/itanium2/Core/Shm/ShmSemaphore.h (original)
+++ branches/itanium2/Core/Shm/ShmSemaphore.h Fri Oct 7 04:18:10 2005
@@ -44,6 +44,7 @@
public:
ShmSemaphore( int key_, int init_val_ );
+ ShmSemaphore() { };
~ShmSemaphore();
void post();
Modified: branches/itanium2/StandAlone/CMakeLists.txt
==============================================================================
--- branches/itanium2/StandAlone/CMakeLists.txt (original)
+++ branches/itanium2/StandAlone/CMakeLists.txt Fri Oct 7 04:18:10 2005
@@ -29,3 +29,13 @@
${CMAKE_THREAD_LIBS_INIT}
)
+ADD_EXECUTABLE(mf_stream_test mf_stream_test.cc)
+TARGET_LINK_LIBRARIES(mf_stream_test Manta_Engine
+ Manta_UserInterface
+ Manta_Model
+ Manta_Image
+ Manta_Interface
+ Manta_Core
+ SCIRun_Core
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
Added: branches/itanium2/StandAlone/mf_stream_test.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/StandAlone/mf_stream_test.cc Fri Oct 7 04:18:10
2005
@@ -0,0 +1,46 @@
+
+
+#include <string>
+#include <iostream>
+
+#include <Core/Shm/MFStreamData.h>
+#include <SCIRun/Core/Exceptions/Exception.h>
+#include <SCIRun/Core/Thread/Time.h>
+
+using namespace std;
+using namespace Manta;
+
+
+
+
+int main( int argc, char **argv ) {
+
+ int key = 0;
+
+
+ // Parse args.
+ for (int i=0;i<argc;++i) {
+ string arg = argv[i];
+
+ if (arg == "-key") {
+ key = atoi( argv[++i] );
+ }
+ }
+
+ MFStreamData *stream_data;
+
+ try {
+ stream_data = new(key, false) MFStreamData;
+ std::cerr << "Acquired Successfully" << std::endl;
+ }
+ catch (SCIRun::Exception *e) {
+ std::cerr << "Caught Exception: " << e->message() << std::endl;
+ }
+
+ while (1) {
+ std::cerr << "front: " << stream_data->frontBuffer << " back: " <<
stream_data->backBuffer << std::endl;
+ SCIRun::Time::waitUntil( SCIRun::Time::currentSeconds()+0.5 );
+ }
+
+ return 1;
+};
- [MANTA] r605 - in branches/itanium2: Core/Shm StandAlone, abe, 10/07/2005
Archive powered by MHonArc 2.6.16.