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

threads.h

Go to the documentation of this file.
00001 /*
00002 || This file is part of Pike. For copyright information see COPYRIGHT.
00003 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
00004 || for more information.
00005 || $Id: threads.h,v 1.130 2004/12/30 13:50:35 grubba Exp $
00006 */
00007 
00008 #ifndef THREADS_H
00009 #define THREADS_H
00010 
00011 #include "machine.h"
00012 #include "object.h"
00013 #include "pike_error.h"
00014 #include "interpret.h"
00015 #include "pike_threadlib.h"
00016 
00017 #ifdef PIKE_THREADS
00018 
00019 #include "pike_rusage.h"
00020 
00021 struct svalue;
00022 struct pike_frame;
00023 
00024 extern PIKE_MUTEX_T interleave_lock;
00025 
00026 /* Status values */
00027 #define THREAD_NOT_STARTED -1
00028 #define THREAD_RUNNING 0
00029 #define THREAD_EXITED 1
00030 
00031 /* Thread flags */
00032 #define THREAD_FLAG_TERM        1       /* Pending termination. */
00033 #define THREAD_FLAG_INTR        2       /* Pending interrupt. */
00034 
00035 #define THREAD_FLAG_SIGNAL_MASK 3       /* All of the above. */
00036 
00037 /* Debug flags */
00038 #define THREAD_DEBUG_LOOSE  1   /* Thread is not bound to the interpreter. */
00039 
00040 struct thread_state {
00041   struct Pike_interpreter state;
00042   struct object *thread_obj;    /* NOTE: Not ref-counted! */
00043   char swapped;                 /* Set if thread has been swapped out. */
00044 #ifdef __CHAR_UNSIGNED__
00045   signed char status;
00046 #else
00047   char status;
00048 #endif
00049   unsigned short flags;
00050   COND_T status_change;
00051   THREAD_T id;
00052   struct mapping *thread_local;
00053   struct thread_state *hashlink, **backlink;
00054   struct svalue result;
00055 #if CPU_TIME_IS_THREAD_LOCAL == PIKE_YES
00056   cpu_time_t auto_gc_time;
00057 #endif
00058 #ifdef PIKE_DEBUG
00059   char debug_flags;
00060 #endif
00061 };
00062 
00063 
00064 /* Prototypes begin here */
00065 int low_nt_create_thread(unsigned stack_size,
00066                          unsigned (TH_STDCALL *func)(void *),
00067                          void *arg,
00068                          unsigned *id);
00069 struct thread_starter;
00070 struct thread_local;
00071 void low_init_threads_disable(void);
00072 void init_threads_disable(struct object *o);
00073 void exit_threads_disable(struct object *o);
00074 void init_interleave_mutex(IMUTEX_T *im);
00075 void exit_interleave_mutex(IMUTEX_T *im);
00076 void thread_table_init(void);
00077 unsigned INT32 thread_table_hash(THREAD_T *tid);
00078 PMOD_EXPORT void thread_table_insert(struct thread_state *s);
00079 PMOD_EXPORT void thread_table_delete(struct thread_state *s);
00080 PMOD_EXPORT struct thread_state *thread_state_for_id(THREAD_T tid);
00081 PMOD_EXPORT struct object *thread_for_id(THREAD_T tid);
00082 PMOD_EXPORT void f_all_threads(INT32 args);
00083 PMOD_EXPORT int count_pike_threads(void);
00084 TH_RETURN_TYPE new_thread_func(void * data);
00085 void f_thread_create(INT32 args);
00086 void f_thread_set_concurrency(INT32 args);
00087 PMOD_EXPORT void f_this_thread(INT32 args);
00088 struct mutex_storage;
00089 struct key_storage;
00090 void f_mutex_lock(INT32 args);
00091 void f_mutex_trylock(INT32 args);
00092 void init_mutex_obj(struct object *o);
00093 void exit_mutex_obj(struct object *o);
00094 void init_mutex_key_obj(struct object *o);
00095 void exit_mutex_key_obj(struct object *o);
00096 void f_cond_wait(INT32 args);
00097 void f_cond_signal(INT32 args);
00098 void f_cond_broadcast(INT32 args);
00099 void init_cond_obj(struct object *o);
00100 void exit_cond_obj(struct object *o);
00101 void f_thread_backtrace(INT32 args);
00102 void f_thread_id_status(INT32 args);
00103 void init_thread_obj(struct object *o);
00104 void exit_thread_obj(struct object *o);
00105 PMOD_EXPORT void f_thread_local(INT32 args);
00106 void f_thread_local_get(INT32 args);
00107 void f_thread_local_set(INT32 args);
00108 void low_th_init(void);
00109 void th_init(void);
00110 void th_cleanup(void);
00111 int th_num_idle_farmers(void);
00112 int th_num_farmers(void);
00113 PMOD_EXPORT void th_farm(void (*fun)(void *), void *here);
00114 /* Prototypes end here */
00115 
00116 #endif
00117 
00118 
00119 /* for compatibility */
00120 #include "interpret.h"
00121 
00122 #endif /* THREADS_H */

Generated on Fri Jul 22 23:44:27 2005 for Pike by  doxygen 1.3.9.1