12 #ifdef HAVE_SYS_TYPES_H
13 #include <sys/types.h>
15 #ifdef HAVE_SYS_SELECT_H
16 #include <sys/select.h>
21 #ifdef HAVE_POSIX_SIGNALS
22 #define AFS_POSIX_SIGNALS 1
24 #define AFS_LWP_MINSTACKSIZE (100 * 1024)
34 #ifdef WINDOWS_THREADS_LWP
41 int lwp_debug
; /* ON = show LWP debugging trace */
43 extern int lwp_stackUseEnabled
;
44 extern int lwp_MaxStackSeen
;
45 #define LWP_ActiveProcess (lwp_cpptr+0)
47 #define LWP_VERSION 210888001
50 #define LWP_EBADPID -1
51 #define LWP_EBLOCKED -2
53 #define LWP_EMAXPROC -4
54 #define LWP_ENOBLOCK -5
56 #define LWP_ENOPROCESS -7
57 #define LWP_ENOWAIT -8
58 #define LWP_EBADCOUNT -9
59 #define LWP_EBADEVENT -10
60 #define LWP_EBADPRI -11
61 #define LWP_NO_STACK -12
62 /* These two are for the signal mechanism. */
63 #define LWP_EBADSIG -13 /* bad signal number */
64 #define LWP_ESYSTEM -14 /* system call failed */
65 /* These are for the rock mechanism */
66 #define LWP_ENOROCKS -15 /* all rocks are in use */
67 #define LWP_EBADROCK -16 /* the specified rock does not exist */
70 /* Maximum priority permissible (minimum is always 0) */
71 #define LWP_MAX_PRIORITY 4
73 /* Usual priority used by user LWPs */
74 #define LWP_NORMAL_PRIORITY (LWP_MAX_PRIORITY-1)
76 #define LWP_SignalProcess(event) LWP_INTERNALSIGNAL(event, 1)
77 #define LWP_NoYieldSignal(event) LWP_INTERNALSIGNAL(event, 0)
79 /* Users aren't really supposed to know what a pcb is, but .....*/
80 typedef struct lwp_pcb
*PROCESS
;
82 /* Action to take on stack overflow. */
83 #define LWP_SOQUIET 1 /* do nothing */
84 #define LWP_SOABORT 2 /* abort the program */
85 #define LWP_SOMESSAGE 3 /* print a message and be quiet */
86 extern int lwp_overflowAction
;
88 /* Invalid LWP Index */
89 #define LWP_INVALIDTHREADID (-1)
91 /* Tells if stack size counting is enabled. */
92 extern int lwp_stackUseEnabled
;
95 int LWP_QSignal(PROCESS
);
96 int LWP_Init(int, int, PROCESS
*);
97 int LWP_InitializeProcessSupport(int, PROCESS
*);
98 int LWP_TerminateProcessSupport(void);
99 int LWP_CreateProcess(void (*)(), int, int, char *, char *, PROCESS
*);
100 int LWP_CurrentProcess(PROCESS
*);
101 int LWP_DestroyProcess(PROCESS
);
102 int LWP_DispatchProcess(void);
103 int LWP_GetProcessPriority(PROCESS
, int *);
104 int LWP_INTERNALSIGNAL(void *, int);
105 int LWP_WaitProcess(void *);
106 int LWP_MwaitProcess(int, char **);
107 int LWP_StackUsed(PROCESS
, int *, int *);
108 int LWP_NewRock(int, char *);
109 int LWP_GetRock(int, char **);
110 char *LWP_Name(void);
112 int LWP_HighestIndex(void);
114 int IOMGR_SoftSig(void (*)(), char *);
115 int IOMGR_Initialize(void);
116 int IOMGR_Finalize(void);
117 long IOMGR_Poll(void);
118 int IOMGR_Select(int, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
119 int IOMGR_Cancel(PROCESS
);
120 int IOMGR_Signal(int, char *);
121 int IOMGR_CancelSignal(int);
122 void IOMGR_Sleep(unsigned int);
124 int FT_Init(int, int);
128 int FT_GetTimeOfDay(struct timeval
*, struct timezone
*);
129 int TM_GetTimeOfDay(struct timeval
*, struct timezone
*);
130 int FT_AGetTimeOfDay(struct timeval
*, struct timezone
*);
131 unsigned int FT_ApproxTime(void);
133 /* Initial size of eventlist in a PCB; grows dynamically */
137 {/* to hide things associated with this LWP under */
138 int tag
; /* unique identifier for this rock */
139 /* pointer to some arbitrary data structure */
140 #if defined(PTHREADS_LWP)
142 #elif defined(WINDOWS_THREADS_LWP)
147 #define MAXROCKS 4 /* max no. of rocks per LWP */
149 struct lwp_pcb
{ /* process control block */
167 struct rock rlist
[MAXROCKS
];
170 struct IoRequest
*iomgrRequest
;
172 struct timeval lastReady
;
173 #if defined(PTHREADS_LWP)
177 #elif defined(WINDOWS_THREADS_LWP)
184 extern int lwp_nextindex
; /* Next lwp index to assign */
186 extern PROCESS lwp_cpptr
; /* pointer to current process pcb */
187 struct lwp_ctl
{ /* LWP control structure */
188 int processcnt
; /* number of lightweight processes */
189 char *outersp
; /* outermost stack pointer */
190 PROCESS outerpid
; /* process carved by Initialize */
191 PROCESS first
, last
; /* ptrs to first and last pcbs */
192 char dsptchstack
[800]; /* stack for dispatcher use only */
195 /* Debugging macro */
197 #define lwpdebug(level, msg)\
198 if (lwp_debug > level) {\
199 printf("***LWP (0x%x): ", lwp_cpptr);\
205 #define lwpdebug(level, msg)
206 #endif /* LWPDEBUG */
208 #define MAXTHREADS 100
210 #endif /* LWP_INCLUDED */