Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ThreadStart.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 
00003 // This file is part of Vesta.
00004 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Sun May 22 21:34:32 EDT 2005 by ken@xorian.net
00020 //      modified on Fri Aug 28 09:07:57 PDT 1998 by heydon
00021 
00022 #ifndef _THREAD_START_H
00023 #define _THREAD_START_H
00024 
00025 // On Linux, gprof requires help to collect profile data from more
00026 // than just the main thread.  The GPROF_SUPPORT macro turns on a
00027 // feature in the thread start code that causes profile data to be
00028 // recorded by all threads.  (It may be harmless to have this on all
00029 // the time, but for now it's optional.)  For more information on this
00030 // issue, see:
00031 
00032 // http://sam.zoy.org/writings/programming/gprof.html
00033 
00034 #if defined(__linux__) && defined(GPROF_SUPPORT)
00035 #include <sys/time.h>
00036 #endif
00037 
00038 #include "Thread.H"
00039 
00040 namespace Basics
00041 {
00042   struct ForkArgs {
00043     thread::StartRoutine proc;
00044     void *arg;
00045 
00046     // fields for blocking parent until child is running
00047     mutex mu;
00048     bool started;
00049     cond untilStarted;
00050 
00051 #if defined(__linux__) && defined(GPROF_SUPPORT)
00052     // gprof support
00053     struct itimerval itimer; 
00054 #endif
00055   };
00056 
00057   extern "C" void *ThreadStart_Callback(void *arg) throw ();
00058   /* This is the function called by "thread::fork" and
00059      "thread::fork_and_detach". The argument "arg" is
00060      actually of type "ForkArgs *". */
00061 
00062   void ThreadStart_WaitForChild(ForkArgs *forkArgs) throw ();
00063   /* When linked with the garbage collector, this procedure
00064      must be called by the parent before it drops "forkArgs"
00065      on the floor to be collected. This procedure may block
00066      until the child thread has really started running and
00067      has noted "fa" on its thread stack to prevent it from
00068      being collected. */
00069 }
00070 
00071 #endif // _THREAD_START_H

Generated on Mon May 8 00:48:29 2006 for Vesta by  doxygen 1.4.2