home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / csim / source.lha / source / Threads / GnuThreads / gnulwp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-14  |  3.4 KB  |  158 lines

  1. /*
  2.  * lwp.h -- prototypes and structures for lightweight processes
  3.  * Copyright (C) 1991 Stephen Crane.
  4.  *
  5.  * This is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 1, or (at your option)
  8.  * any later version.
  9.  *
  10.  * This software is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * see the file COPYING.  If not, write to
  17.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * author: Stephen Crane, (jsc@doc.ic.ac.uk), Department of Computing,
  20.  * Imperial College of Science, Technology and Medicine, 180 Queen's
  21.  * Gate, London SW7 2BZ, England.
  22.  */
  23.  
  24. /*
  25.  * This header file has been altered to make it work with the C++ simulation
  26.  * package.
  27.  * Modifier: Mark Little (M.C.Little@ncl.ac.uk)
  28.  * Modified Data: May 1992
  29.  */
  30.  
  31.  
  32. #ifndef _LWP_H
  33. #define _LWP_H
  34.  
  35. /*
  36.  * Modified for C++ Simulator
  37.  */
  38.  
  39. #define Thread_Par int dummy1 = 0, char** dummy2 = 0, void* dummy3 = 0
  40.  
  41. #define MAXPRI    8
  42.  
  43. #ifndef __signal_h
  44. #include <signal.h>
  45. #endif
  46. #define SIGNALS (sigmask(SIGIO)|sigmask(SIGALRM))
  47.  
  48. #ifndef mips
  49. #ifndef _SETJMP
  50. #include <setjmp.h>
  51. #endif
  52. #else
  53. typedef int jmp_buf[16];
  54. #endif
  55.  
  56. #ifndef _sys_time_h
  57. #include <sys/time.h>
  58. #endif
  59.  
  60. /* process control block.  do *not* change the position of context */
  61. struct pcb {
  62.     jmp_buf    context;    /* processor context area */
  63.     void    *sbtm;        /* bottom of stack attached to it */
  64.     int     size;           /* size of stack */
  65.     void    (*entry)(int, char**, void*);    /* entry point */
  66.     unsigned dead:1;    /* whether the process should be rescheduled */
  67.     int    pri;        /* which scheduling queue we're on */
  68.     struct timeval    dt;
  69.     int    argc;        /* initial arguments */
  70.     char    **argv;
  71.     void    *envp;        /* user structure pointer */
  72.     struct pcb    *next;
  73. };
  74.  
  75. /* queue */
  76. struct lpq {
  77.     struct pcb *head, *tail;
  78. };
  79.  
  80. /* semaphore */
  81. struct sem {
  82.     int count;
  83.     struct lpq q;
  84. };
  85.  
  86. /* signal struct */
  87. struct siginfo {
  88.     struct siginfo *next;
  89.     int des;
  90.     void (*han) (void*, int);
  91.     void *ctx;
  92. };
  93.  
  94. typedef double stkalign_t;
  95.  
  96. #define savep(x)    setjmp(x)
  97. #define restorep(x)    longjmp(x, 1)
  98.  
  99. #ifdef __cplusplus
  100. extern "C" {
  101. #endif
  102.  
  103. #ifdef mips
  104. int savep (jmp_buf);
  105. void restorep (jmp_buf);
  106. #endif
  107.  
  108. /* semaphore operations */
  109. struct sem *creats (int);
  110. void signals (struct sem *);
  111. void waits (struct sem *);
  112.  
  113. /* queue operations */
  114. void toq (struct lpq *, struct pcb *);
  115. struct pcb *hoq (struct lpq *);
  116.  
  117. /* process operations */
  118.  
  119. /*
  120.  * Modified for C++ Simulator
  121.  */
  122.  
  123. #ifdef _INIT_
  124. class GNU_Thread;
  125. struct pcb *creatp (int, void (*func)(int, char**, GNU_Thread*), int, int, char **, void *);
  126. #else
  127. struct pcb *creatp (int, void (*func)(int, char**, void*), int, int, char **, void *);
  128. #endif
  129. void suicidep (void);
  130. void destroyp (struct pcb *);
  131. void readyp (struct pcb *);
  132. void reschedp (void);
  133. void yieldp (void);
  134. void *getenvp (struct pcb *);
  135. int prisetp (int);
  136.  
  137. /* access operations */
  138. int btmcurrp (void);
  139. int sizecurrp (void);
  140.  
  141. /* timer operations */
  142. void delayp (long);
  143. void onalarm (void);
  144.  
  145. /* initialisation */
  146. struct pcb *initlp (int);
  147. void initp (struct pcb *);
  148. void wrapp (void);
  149.  
  150. /* signal stuff */
  151. int sigioset (int, void (*)(), void *);
  152. int sigioclr (int);
  153. #ifdef __cplusplus
  154. }
  155. #endif    /* __cplusplus */
  156.  
  157. #endif    /* _LWP_H */
  158.