diff options
Diffstat (limited to 'docs/tutorials/Chap_4')
-rw-r--r-- | docs/tutorials/Chap_4/Chap_4.zip | bin | 8317 -> 0 bytes | |||
-rw-r--r-- | docs/tutorials/Chap_4/ex01.html | 74 | ||||
-rw-r--r-- | docs/tutorials/Chap_4/ex02.html | 67 | ||||
-rw-r--r-- | docs/tutorials/Chap_4/ex03.html | 78 | ||||
-rw-r--r-- | docs/tutorials/Chap_4/ex04.html | 69 | ||||
-rw-r--r-- | docs/tutorials/Chap_4/ex05.html | 69 | ||||
-rw-r--r-- | docs/tutorials/Chap_4/ex06.html | 95 | ||||
-rw-r--r-- | docs/tutorials/Chap_4/ex07.html | 84 | ||||
-rw-r--r-- | docs/tutorials/Chap_4/ex08.html | 72 |
9 files changed, 0 insertions, 608 deletions
diff --git a/docs/tutorials/Chap_4/Chap_4.zip b/docs/tutorials/Chap_4/Chap_4.zip Binary files differdeleted file mode 100644 index b29059f1457..00000000000 --- a/docs/tutorials/Chap_4/Chap_4.zip +++ /dev/null diff --git a/docs/tutorials/Chap_4/ex01.html b/docs/tutorials/Chap_4/ex01.html deleted file mode 100644 index 00e8cb8f51d..00000000000 --- a/docs/tutorials/Chap_4/ex01.html +++ /dev/null @@ -1,74 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 1</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 1</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Thread.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch_T.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT><FONT COLOR="#006600"> "ace/Synch.h"</FONT> -<BR>static int number=0; -<BR>static int seed=0; - -<P>static void* -<BR>worker(void *arg){ -<BR> ACE_UNUSED_ARG(arg); -<BR> ACE_DEBUG((LM_DEBUG,"Thread (%t) Created to do some work")); -<BR> ::number++; -<BR> ACE_DEBUG((LM_DEBUG," and number is %d\n",::number)); -<BR> -<BR> <FONT COLOR="#FF0000">//Let the other guy go while I fall asleep -for a random period of time</FONT> -<BR> ACE_Thread::yield(); -<BR> ACE_OS::sleep(ACE_OS::rand()%2); - -<P><FONT COLOR="#FF0000"> //Exiting now</FONT> -<BR> ACE_DEBUG((LM_DEBUG, -<BR> "\t\t Thread (%t) Done! \t The number is now: %d\n",number)); -<BR> ACE_OS::fflush(stdout); -<BR> return 0; -<BR> } -<BR> - -<P>int main(int argc, char *argv[]){ -<BR>if(argc<2) -<BR> ACE_DEBUG((LM_DEBUG,"Usage: <program_name> <number of threads>\n")); -<BR> -<BR>int n_threads=ACE_OS::atoi(argv[1]); -<BR><FONT COLOR="#FF0000">//Setup the random number generator</FONT> -<BR>ACE_OS::srand(::seed); - -<P><FONT COLOR="#FF0000">//Spawn off n_threads number of threads</FONT> -<BR>for(int i=0; i<n_threads; i++){ -<BR> if(ACE_Thread::spawn((ACE_THR_FUNC)worker)==-1) -<BR> ACE_DEBUG((LM_DEBUG,"Error in spawning thread\n")); -<BR> } - -<P><FONT COLOR="#FF0000">//Wait for all the threads to exit before you -let the main fall through</FONT> -<BR><FONT COLOR="#FF0000">//and have the process exit. This way of using -join is non-portable</FONT> -<BR><FONT COLOR="#FF0000">//and may not work on a system using pthreads.</FONT> -<BR>int check_count=0; -<BR>while(ACE_Thread::join(NULL,NULL,NULL)==0) check_count++; -<BR>ACE_ASSERT(check_count==n_threads); -<BR>} - -<P> <A HREF="ex02.html">Next Example</A> -<BR> -</BODY> -</HTML> diff --git a/docs/tutorials/Chap_4/ex02.html b/docs/tutorials/Chap_4/ex02.html deleted file mode 100644 index 4feefe6dbe5..00000000000 --- a/docs/tutorials/Chap_4/ex02.html +++ /dev/null @@ -1,67 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 2</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 2</FONT> -<BR><FONT COLOR="#000099">#include </FONT><FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch.h"</FONT> - -<P><FONT COLOR="#FF0000">//Arguments that are to be passed to the worker -thread are passed through this class.</FONT> -<BR>class Args{ -<BR>public: -<BR>Args(int iterations): -<BR> mutex_(),iterations_(iterations){} -<BR>ACE_Thread_Mutex mutex_; -<BR>int iterations_; -<BR>}; - -<P><FONT COLOR="#FF0000">//The starting point for the worker threads</FONT> -<BR>static void* -<BR>worker(void*arguments){ -<BR>Args *arg= (Args*) arguments; -<BR>for(int i=0;i<arg->iterations_;i++){ -<BR> ACE_DEBUG((LM_DEBUG, -<BR> "(%t) Trying to get a hold of this iteration\n")); -<BR><FONT COLOR="#FF0000"> //This is our critical section</FONT> -<BR> arg->mutex_.acquire(); -<BR> ACE_DEBUG((LM_DEBUG,"(%t) This is iteration number %d\n",i)); -<BR><FONT COLOR="#FF0000"> //work</FONT> -<BR> ACE_OS::sleep(2); -<BR> arg->mutex_.release(); -<BR> } -<BR>return 0; -<BR>} - -<P>int main(int argc, char*argv[]){ -<BR>if(argc<2){ -<BR>ACE_OS::printf("Usage: egx <number_of_threads> -<BR> <number_of_iterations>\n"); -<BR> ACE_OS::exit(1); -<BR> } -<BR><FONT COLOR="#FF0000">//Setup the arguments</FONT> -<BR>Args arg(ACE_OS::atoi(argv[2])); - -<P>ACE_Thread::spawn_n -<BR> (ACE_OS::atoi(argv[1]),(ACE_THR_FUNC)worker,(void*)&arg); -<BR><FONT COLOR="#FF0000">//Spawn the worker threads</FONT> -<BR>while(ACE_Thread::join(NULL,NULL,NULL)==0); -<BR>} -<BR> -<BR> <A HREF="ex03.html">Next Example</A> -</BODY> -</HTML> diff --git a/docs/tutorials/Chap_4/ex03.html b/docs/tutorials/Chap_4/ex03.html deleted file mode 100644 index 56fbd9441aa..00000000000 --- a/docs/tutorials/Chap_4/ex03.html +++ /dev/null @@ -1,78 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 3</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 3</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch_T.h"</FONT> - -<P><FONT COLOR="#FF0000">//Arguments that are to be passed to the worker -thread are passed through this class.</FONT> -<BR>class Args{ -<BR>public: -<BR>Args(ACE_Lock* lock,int iterations): -<BR> mutex_(lock),iterations_(iterations){} -<BR>ACE_Lock* mutex_; -<BR>int iterations_; -<BR>}; - -<P><FONT COLOR="#FF0000">//The starting point for the worker threads</FONT> -<BR>static void* -<BR>worker(void*arguments){ -<BR>Args *arg= (Args*) arguments; -<BR>for(int i=0;i<arg->iterations_;i++){ -<BR> ACE_DEBUG((LM_DEBUG, -<BR> "(%t) Trying to get a hold of this iteration\n")); -<BR><FONT COLOR="#FF0000"> //This is our critical section</FONT> -<BR> arg->mutex_->acquire(); -<BR> ACE_DEBUG((LM_DEBUG,"(%t) This is iteration number %d\n",i)); -<BR><FONT COLOR="#FF0000"> //work</FONT> -<BR> ACE_OS::sleep(2); -<BR> arg->mutex_->release(); -<BR> } -<BR>return 0; -<BR>} - -<P>int main(int argc, char*argv[]){ -<BR>if(argc<4){ -<BR> ACE_OS::printf("Usage: egx <number_of_threads> -<BR> <number_of_iterations> <lock_type>\n"); -<BR> ACE_OS::exit(1); -<BR> } -<BR><FONT COLOR="#FF0000">//Lock used by application</FONT> -<BR>ACE_Lock *lock; - -<P><FONT COLOR="#FF0000">//Decide which lock you want to use at run time. -Possible due to</FONT> -<BR><FONT COLOR="#FF0000">//ACE_Lock.</FONT> -<BR>if(ACE_OS::strcmp(argv[3],"Thread")) -<BR> lock=new ACE_Lock_Adapter<ACE_Thread_Mutex>; -<BR>else -<BR> lock=new ACE_Lock_Adapter<ACE_Mutex> - -<P><FONT COLOR="#FF0000">//Setup the arguments</FONT> -<BR>Args arg(lock,ACE_OS::atoi(argv[2])); -<BR><FONT COLOR="#FF0000">//Spawn the worker threads</FONT> -<BR>ACE_Thread::spawn_n -<BR> (ACE_OS::atoi(argv[1]),(ACE_THR_FUNC)worker,(void*)&arg); -<BR>while(ACE_Thread::join(NULL,NULL,NULL)==0); -<BR>} - -<P> <A HREF="ex04.html">Next Example</A> -</BODY> -</HTML> diff --git a/docs/tutorials/Chap_4/ex04.html b/docs/tutorials/Chap_4/ex04.html deleted file mode 100644 index 091433ba5be..00000000000 --- a/docs/tutorials/Chap_4/ex04.html +++ /dev/null @@ -1,69 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 4</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 4</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT><FONT COLOR="#006600"> "ace/Token.h"</FONT> - -<P><FONT COLOR="#FF0000">//Arguments that are to be passed to the worker -thread are passed</FONT> -<BR><FONT COLOR="#FF0000">//through this class.</FONT> -<BR>class Args{ -<BR>public: -<BR>Args(int iterations): -<BR> mutex_(),iterations_(iterations){} -<BR>ACE_Token mutex_; -<BR>int iterations_; -<BR>}; - -<P><FONT COLOR="#FF0000">//The starting point for the worker threads</FONT> -<BR>static void* -<BR>worker(void*arguments){ -<BR>Args *arg= (Args*) arguments; -<BR>for(int i=0;i<arg->iterations_;i++){ -<BR> ACE_DEBUG((LM_DEBUG,"(%t) Trying to get a hold of this iteration\n")); -<BR><FONT COLOR="#FF0000"> //This is our critical section</FONT> -<BR> arg->mutex_.acquire(); -<BR> ACE_DEBUG((LM_DEBUG,"(%t) This is iteration number %d\n",i)); -<BR><FONT COLOR="#FF0000"> //work</FONT> -<BR> ACE_OS::sleep(2); -<BR> arg->mutex_.release(); -<BR> } -<BR>return 0; -<BR>} -<BR> - -<P>int main(int argc, char*argv[]){ -<BR>if(argc<4){ -<BR> ACE_OS::printf("Usage: egx <number_of_threads> -<BR> <number_of_iterations> <lock_type>\n"); -<BR> ACE_OS::exit(1); -<BR> } - -<P><FONT COLOR="#FF0000">//Setup the arguments</FONT> -<BR>Args arg(ACE_OS::atoi(argv[2])); -<BR><FONT COLOR="#FF0000">//Spawn the worker threads</FONT> -<BR>ACE_Thread::spawn_n(ACE_OS::atoi(argv[1]),(ACE_THR_FUNC)worker,(void*)&arg); - -<P>while(ACE_Thread::join(NULL,NULL,NULL)==0); - -<P>} - -<P> <A HREF="ex05.html">Next Example</A> -</BODY> -</HTML> diff --git a/docs/tutorials/Chap_4/ex05.html b/docs/tutorials/Chap_4/ex05.html deleted file mode 100644 index 74fbb7cd80f..00000000000 --- a/docs/tutorials/Chap_4/ex05.html +++ /dev/null @@ -1,69 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 5</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 5</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch_T.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT><FONT COLOR="#006600"> "ace/Token.h"</FONT> - -<P><FONT COLOR="#FF0000">//Arguments that are to be passed to the worker -thread are passed through this class.</FONT> -<BR>class Args{ -<BR>public: -<BR>Args(int iterations): -<BR> mutex_(),iterations_(iterations){} -<BR>ACE_Token mutex_; -<BR>int iterations_; -<BR>}; - -<P><FONT COLOR="#FF0000">//The starting point for the worker threads</FONT> -<BR>static void* -<BR>worker(void*arguments){ -<BR>Args *arg= (Args*) arguments; -<BR>for(int i=0;i<arg->iterations_;i++){ -<BR> ACE_DEBUG((LM_DEBUG,"(%t) Trying to get a hold of this iteration\n")); -<BR> {<FONT COLOR="#FF0000">//begin critical section</FONT> -<BR> ACE_Guard<ACE_Token> guard(arg->mutex_); -<BR> <FONT COLOR="#FF0000"> //This is our critical section</FONT> -<BR> ACE_DEBUG((LM_DEBUG,"(%t) This is iteration number %d\n",i)); -<BR><FONT COLOR="#FF0000"> //work</FONT> -<BR> ACE_OS::sleep(2); -<BR> }<FONT COLOR="#FF0000">//end critical section</FONT> -<BR> } -<BR>return 0; -<BR>} -<BR> - -<P>int main(int argc, char*argv[]){ -<BR>if(argc<3){ -<BR> ACE_OS::printf("Usage: egx <number_of_threads> <number_of_iterations> -\n"); -<BR> ACE_OS::exit(1); -<BR> } - -<P><FONT COLOR="#FF0000">//Setup the arguments</FONT> -<BR>Args arg(ACE_OS::atoi(argv[2])); -<BR><FONT COLOR="#FF0000">//Spawn the worker threads</FONT> -<BR>ACE_Thread::spawn_n(ACE_OS::atoi(argv[1]),(ACE_THR_FUNC)worker,(void*)&arg); -<BR>while(ACE_Thread::join(NULL,NULL,NULL)==0); -<BR>} - -<P> <A HREF="ex06.html">Next Example</A> -</BODY> -</HTML> diff --git a/docs/tutorials/Chap_4/ex06.html b/docs/tutorials/Chap_4/ex06.html deleted file mode 100644 index 7a8df16dcd3..00000000000 --- a/docs/tutorials/Chap_4/ex06.html +++ /dev/null @@ -1,95 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 6</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 6</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Thread.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include </FONT><FONT COLOR="#006600">"ace/Synch_T.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT><FONT COLOR="#006600"> "ace/Synch.h"</FONT> - -<P>static int number=0; -<BR>static int seed=0; - -<P>class Args{ -<BR>public: -<BR>Args(ACE_Condition<ACE_Thread_Mutex> *cond, int threads): -<BR> cond_(cond), threads_(threads){} -<BR>ACE_Condition<ACE_Thread_Mutex> *cond_; -<BR>int threads_; -<BR>}; - -<P>static void* -<BR>worker(void *arguments){ -<BR> Args *arg= (Args*)arguments; -<BR> ACE_DEBUG((LM_DEBUG,"Thread (%t) Created to do some work\n")); -<BR> ::number++; -<BR><FONT COLOR="#FF0000"> //Work</FONT> -<BR> ACE_OS::sleep(ACE_OS::rand()%2); - -<P><FONT COLOR="#FF0000"> //Exiting now</FONT> -<BR> ACE_DEBUG((LM_DEBUG, -<BR> "\tThread (%t) Done! \n\tThe number is now: %d\n",number)); -<BR><FONT COLOR="#FF0000"> //If all threads are done signal main thread -that program can now exit</FONT> -<BR> if(number==arg->threads_){ -<BR> ACE_DEBUG((LM_DEBUG, -<BR> "(%t) Last Thread!\n All threads have done -their job! -<BR> Signal main thread\n")); -<BR> arg->cond_->signal(); -<BR> } -<BR>return 0; -<BR>} -<BR> - -<P>int main(int argc, char *argv[]){ -<BR>if(argc<2){ -<BR> ACE_DEBUG((LM_DEBUG,"Usage: <program_name> <number of threads>\n")); -<BR> ACE_OS::exit(1); -<BR> } -<BR> -<BR>int n_threads=ACE_OS::atoi(argv[1]); - -<P><FONT COLOR="#FF0000">//Setup the random number generator</FONT> -<BR>ACE_OS::srand(::seed); - -<P><FONT COLOR="#FF0000">//Setup arguments for threads</FONT> -<BR>ACE_Thread_Mutex mutex; -<BR>ACE_Condition<ACE_Thread_Mutex> cond(mutex); -<BR>Args arg(&cond,n_threads); - -<P><FONT COLOR="#FF0000">//Spawn off n_threads number of threads</FONT> -<BR>for(int i=0; i<n_threads; i++){ -<BR> if(ACE_Thread::spawn((ACE_THR_FUNC)worker,(void*)&arg, -<BR> THR_DETACHED|THR_NEW_LWP)==-1) -<BR> ACE_DEBUG((LM_DEBUG,"Error in spawning thread\n")); -<BR> } - -<P><FONT COLOR="#FF0000">//Wait for signal indicating that all threads -are done and program can exit</FONT> -<BR>mutex.acquire(); -<BR>if(number!=n_threads) -<BR> cond.wait(); -<BR>ACE_DEBUG((LM_DEBUG,"(%t) Main Thread got signal. Program exiting..\n")); -<BR>mutex.release(); -<BR>ACE_OS::exit(0); -<BR>} - -<P> <A HREF="ex07.html">Next Example</A> -</BODY> -</HTML> diff --git a/docs/tutorials/Chap_4/ex07.html b/docs/tutorials/Chap_4/ex07.html deleted file mode 100644 index 4adf56569d3..00000000000 --- a/docs/tutorials/Chap_4/ex07.html +++ /dev/null @@ -1,84 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 7</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 7</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Thread.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch_T.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch.h"</FONT> - -<P>static int number=0; -<BR>static int seed=0; - -<P>class Args{ -<BR>public: -<BR>Args(ACE_Barrier *barrier): -<BR> barrier_(barrier){} -<BR>ACE_Barrier *barrier_; -<BR>}; - -<P>static void* -<BR>worker(void *arguments){ -<BR> Args *arg= (Args*)arguments; -<BR> ACE_DEBUG((LM_DEBUG,"Thread (%t) Created to do some work\n")); -<BR> ::number++; -<BR> -<BR><FONT COLOR="#FF0000"> //Work</FONT> -<BR> ACE_OS::sleep(ACE_OS::rand()%2); - -<P><FONT COLOR="#FF0000"> //Exiting now</FONT> -<BR> ACE_DEBUG((LM_DEBUG, -<BR> "\tThread (%t) Done! \n\tThe number is now: %d\n",number)); -<BR><FONT COLOR="#FF0000"> //Let the barrier know we are done.</FONT> -<BR> arg->barrier_->wait(); -<BR> ACE_DEBUG((LM_DEBUG,"Thread (%t) is exiting \n")); -<BR> return 0; -<BR>} -<BR> - -<P>int main(int argc, char *argv[]){ -<BR>if(argc<2){ -<BR> ACE_DEBUG((LM_DEBUG,"Usage: <program_name> <number of threads>\n")); -<BR> ACE_OS::exit(1); -<BR> } -<BR> -<BR>int n_threads=ACE_OS::atoi(argv[1]); -<BR>ACE_DEBUG((LM_DEBUG,"Preparing to spawn %d threads",n_threads)); -<BR><FONT COLOR="#FF0000">//Setup the random number generator</FONT> -<BR>ACE_OS::srand(::seed); - -<P><FONT COLOR="#FF0000">//Setup arguments for threads</FONT> -<BR>ACE_Barrier barrier(n_threads); -<BR>Args arg(&barrier); - -<P><FONT COLOR="#FF0000">//Spawn off n_threads number of threads</FONT> -<BR>for(int i=0; i<n_threads; i++){ if(ACE_Thread::spawn((ACE_THR_FUNC)worker,(void*)&arg,THR_DETACHED|THR_NEW_LWP)==-1) -<BR> ACE_DEBUG((LM_DEBUG,"Error in spawning thread\n")); -<BR> } - -<P><FONT COLOR="#FF0000">//Wait for all the other threads to let the main -thread</FONT> -<BR><FONT COLOR="#FF0000">// know that they are done using hte barrier</FONT> -<BR>barrier.wait(); -<BR>ACE_DEBUG((LM_DEBUG,"(%t)Other threads are finished. Program exiting..\n")); -<BR>ACE_OS::sleep(2); -<BR>} - -<P> <A HREF="ex08.html">Next Example</A> -</BODY> -</HTML> diff --git a/docs/tutorials/Chap_4/ex08.html b/docs/tutorials/Chap_4/ex08.html deleted file mode 100644 index 2418a93c0a8..00000000000 --- a/docs/tutorials/Chap_4/ex08.html +++ /dev/null @@ -1,72 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 8</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 8</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch_T.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch.h"</FONT> - -<P>ACE_Atomic_Op<ACE_Thread_Mutex,int> foo; - -<P>static void* -<BR>worker(void *arg){ -<BR> ACE_UNUSED_ARG(arg); -<BR> foo=5; -<BR> ACE_ASSERT (foo == 5); -<BR> -<BR> ++foo; -<BR> ACE_ASSERT (foo == 6); -<BR> -<BR> --foo; -<BR> ACE_ASSERT (foo == 5); -<BR> -<BR> foo += 10; -<BR> ACE_ASSERT (foo == 15); -<BR> -<BR> foo -= 10; -<BR> ACE_ASSERT (foo == 5); -<BR> -<BR> foo = 5L; -<BR> ACE_ASSERT (foo == 5); -<BR> return 0; -<BR>} - -<P>int main(int argc, char *argv[]){ -<BR>if(argc<2){ -<BR> ACE_DEBUG((LM_DEBUG,"Usage: <program_name> <number of threads>\n")); -<BR> ACE_OS::exit(1); -<BR> } -<BR> -<BR>int n_threads=ACE_OS::atoi(argv[1]); -<BR>ACE_DEBUG((LM_DEBUG,"Preparing to spawn %d threads\n",n_threads)); -<BR> - -<P><FONT COLOR="#FF0000">//Spawn off n_threads number of threads</FONT> -<BR>for(int i=0; i<n_threads; i++){ -<BR> if(ACE_Thread::spawn((ACE_THR_FUNC)worker,0,THR_DETACHED|THR_NEW_LWP)==-1) -<BR> ACE_DEBUG((LM_DEBUG,"Error in spawning thread\n")); -<BR> } - -<P><FONT COLOR="#FF0000">//Wait for all the other threads to let the main -thread know when it is time to exit</FONT> -<BR>while(ACE_Thread::join(NULL,NULL,NULL)==0); -<BR>ACE_DEBUG((LM_DEBUG,"(%t)Other threads are finished. Program exiting..\n")); -<BR>} - -<P> <A HREF="../Chap_5/ex01.html">Next Example</A> -</BODY> -</HTML> |