home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / j2sdk / files / linux / j2sdklin.bin / jdk1.3.1 / include-old / threads.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-06  |  3.2 KB  |  109 lines

  1. /*
  2.  * @(#)threads.h    1.56 00/02/02
  3.  *
  4.  * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the proprietary information of Sun Microsystems, Inc.  
  7.  * Use is subject to license terms.
  8.  * 
  9.  */
  10.  
  11. #ifndef _JAVASOFT_THREADS_H_
  12. #define _JAVASOFT_THREADS_H_
  13.  
  14. #include "oobj.h"
  15. #include "interpreter.h"
  16. #include "monitor.h"
  17. #include "sys_api.h"
  18.  
  19. #include "java_lang_Thread.h"
  20. #include "java_lang_ThreadGroup.h"
  21.  
  22. /*
  23.  * Thread-related data structures
  24.  */
  25.  
  26. typedef struct Hjava_lang_Thread HThread;
  27. typedef struct Hjava_lang_ThreadGroup HThreadGroup;
  28. typedef struct Hjava_lang_Thread *TID;
  29.  
  30. /* Access to thread data structures */
  31. #define THREAD(tid)    ((struct Classjava_lang_Thread *) unhand(tid))
  32.  
  33. /* The default Java stack size is legitimately platform-independent */
  34. #define JAVASTACKSIZE (400 * 1024)     /* Default size of a thread java stack */
  35.  
  36. extern HThreadGroup *maingroup;         /* the main ThreadGroup */
  37. extern HThreadGroup *systemgroup;       /* the system ThreadGroup */
  38.  
  39. extern long ProcStackSize;        /* Actual size of thread C stack */
  40. extern long JavaStackSize;        /* Actual maximum size of java stack */
  41.  
  42. /*
  43.  * External interface to threads support
  44.  */
  45.  
  46. int createSystemThread(char *name, int priority, long stack_size,
  47.                void (*f)(void *), void *arg);
  48. void threadBootstrap(TID tid);
  49. int  threadCreate(TID, size_t, int, void (*)(void *));
  50. TID  threadSelf(void);
  51. void threadSleep(int64_t);
  52.  
  53. int threadPostException(TID tid, void *exc);
  54. void threadTryVMSuspend(void);
  55.  
  56. void threadInit(void);
  57.  
  58. void WaitForSingleThreaded(void);
  59. void AdjustUserThreadCount(int n);
  60.  
  61. /*
  62.  * Exit the current thread.  This function is not expected to return.
  63.  *
  64.  * Note that we currently never stop a thread dead in its tracks, but
  65.  * rather throw an exception against it that causes it to unwind its
  66.  * stack, exit monitors, etc. and exit in a single place (ThreadRT0).
  67.  * If a thread is caused to exit precipitously by calling threadExit()
  68.  * at random places it will corrupt the runtime and at minimum will
  69.  * fail to clean the thread out of any monitors it currently holds.
  70.  */
  71. void threadExit(void);
  72.  
  73. void threadFree(void);
  74.  
  75. /*
  76.  * Note that we do not check that priorities are within Java's limits down here.
  77.  * In fact, we make use of that for things like the idle and clock threads.
  78.  * This may change once we work out a portable priority model.
  79.  */
  80. int threadSetPriority(TID tid, int pri);
  81. int threadGetPriority(TID tid, int *prip);
  82.  
  83. #define threadYield()            sysThreadYield()
  84.  
  85. int threadResume(TID tid);
  86. int threadSuspend(TID tid);
  87.  
  88. /*
  89.  * Return information about this thread's stack.  This is used by
  90.  * Garbage Collection code that needs to inspect the stack.
  91.  *
  92.  * It is permissable to return a null stack_base for those threads
  93.  * that don't have a known stack (e.g. not allocated by the threads
  94.  * package).  It is also permissable to return a somewhat bogus
  95.  * stack_pointer for the current thread.
  96.  */
  97. void *threadStackBase(TID tid);
  98. void *threadStackPointer(TID tid);
  99.  
  100. #define threadCheckStack()        sysThreadCheckStack()
  101.  
  102. /*
  103.  * Interface to thread interrupt support
  104.  */
  105. void threadInterrupt(TID tid);
  106. int threadIsInterrupted(TID tid, long ClearInterrupted);
  107.  
  108. #endif /* !_JAVASOFT_THREADS_H_ */
  109.