Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/nto/cs6.cpp

Go to the documentation of this file.
00001 #ifndef __J2K__CS6_CPP__
00002 #define __J2K__CS6_CPP__
00003 
00004 #include <j2k/nto/cs_def.hpp>
00005 #include <j2k/nto/Server.hpp>
00006 #include <j2k/nto/Producer.hpp>
00007 #include <j2k/nto/Consumer.hpp>
00008 
00009 #include <j2k/nto/Server.cpp>
00010 #include <j2k/nto/Producer.cpp>
00011 #include <j2k/nto/Consumer.cpp>
00012 
00013 int nbConsumers = 2;
00014 int nbProducers = 1;
00015 int nbServers   = 1;
00016 
00017 int main( int argc, char **argv ) 
00018 {
00019   if ( argc >= 2 )
00020   {
00021     nbConsumers = (int)strtoull( argv[ 1 ], NULL, 10 );
00022     printf( "Loading %d consumers [%s] \n", nbConsumers, argv[1] );
00023   }
00024 
00025   if ( argc >= 3 )
00026   {
00027     nbProducers = (int)strtoull( argv[ 2 ], NULL, 10 );
00028     printf( "Loading %d producers [%s] \n", nbProducers, argv[2] );
00029   }
00030 
00031   NameSpace* n = new NameSpace( "coen320_fred", nbConsumers, nbProducers, nbServers  );
00032   Server s( n );
00033 
00034   Producer* p[ nbProducers ];
00035   Consumer* c[ nbConsumers ];
00036 
00037   s.start();
00038   setprio( s.getPID(), 20 );
00039 
00040   n->waitForServer();
00041 
00042   setprio( pthread_self(), 19 );
00043 
00044   register int i = 0;
00045   for( i = 0; i < nbProducers; i++ )
00046   {
00047     p[i] = new Producer( n, i+100 );
00048     p[i]->start();
00049     p[i]->setPThread( p[i]->getPID() );
00050     setprio( p[i]->getPID(), 18 );
00051   }
00052 
00053   for( i = 0; i < nbConsumers; i++ )
00054   {
00055     c[i] = new Consumer( n, i+100 );
00056     c[i]->start();
00057     c[i]->setPThread( c[i]->getPID() );
00058     setprio( c[i]->getPID(), 18 );
00059   }
00060 
00061   n->waitForThreads();
00062 
00063 //  pthread_join( c.getPID(), NULL );
00064 
00065   n->waitForClient();
00066 
00067   printf( "Main Done \n" );
00068   fflush( stdout );
00069 
00070   // Shut down the READ-Blocked server
00071   printf( "Shut down the READ-Blocked server... \n" );
00072   fflush( stdout );
00073 
00074   pthread_kill( s.getPID(), SIGKILL );
00075 
00076   if ( n != NULL ) delete n;
00077 
00078   return 0;
00079 }
00080 
00081 #endif // End of CS6.cpp

Generated on Sun Oct 14 18:46:39 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001