Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* |
2 | * Copyright 1995, Brown University, Providence, RI |
||
3 | * |
||
4 | * Permission to use and modify this software and its documentation for |
||
5 | * any purpose other than its incorporation into a commercial product is |
||
6 | * hereby granted without fee. Permission to copy and distribute this |
||
7 | * software and its documentation only for non-commercial use is also |
||
8 | * granted without fee, provided, however, that the above copyright notice |
||
9 | * appear in all copies, that both that copyright notice and this permission |
||
10 | * notice appear in supporting documentation, that the name of Brown |
||
11 | * University not be used in advertising or publicity pertaining to |
||
12 | * distribution of the software without specific, written prior permission, |
||
13 | * and that the person doing the distribution notify Brown University of |
||
14 | * such distributions outside of his or her organization. Brown University |
||
15 | * makes no representations about the suitability of this software for |
||
16 | * any purpose. It is provided "as is" without express or implied warranty. |
||
17 | * Brown University requests notification of any modifications to this |
||
18 | * software or its documentation. |
||
19 | * |
||
20 | * Send the following redistribution information: |
||
21 | * |
||
22 | * Name: |
||
23 | * Organization: |
||
24 | * Address (postal and/or electronic): |
||
25 | * |
||
26 | * To: |
||
27 | * Software Librarian |
||
28 | * Computer Science Department, Box 1910 |
||
29 | * Brown University |
||
30 | * Providence, RI 02912 |
||
31 | * |
||
32 | * or |
||
33 | * |
||
34 | * brusd@cs.brown.edu |
||
35 | * |
||
36 | * We will acknowledge all electronic notifications. |
||
37 | */ |
||
38 | |||
39 | /* ------------------------------------------------------------------------- |
||
40 | Public THREAD include file |
||
41 | ------------------------------------------------------------------------- */ |
||
42 | |||
43 | // Original code by Tom Meyer |
||
44 | // Altered by Loring Holden to work with MPEGmovie object |
||
45 | |||
46 | /* $Id: thread_m.h,v 1.1.1.1 2002-03-29 14:12:59 pj Exp $ */ |
||
47 | |||
48 | #ifndef THREAD_MP_HAS_BEEN_INCLUDED |
||
49 | #define THREAD_MP_HAS_BEEN_INCLUDED |
||
50 | |||
51 | #if defined(sol) |
||
52 | |||
53 | #ifdef CPLPLTHREADS |
||
54 | #include "/pro/threadtools/C++_mon/include/c++thread.h" |
||
55 | #else |
||
56 | #include <unistd.h> |
||
57 | #include <thread.h> |
||
58 | #endif |
||
59 | #include <string.h> |
||
60 | |||
61 | #elif defined(hp) |
||
62 | // No multithreading on the HPs |
||
63 | #elif defined(sgi) |
||
64 | #include <stdio.h> |
||
65 | #include <ulocks.h> |
||
66 | #include <sys/types.h> |
||
67 | #include <sys/resource.h> |
||
68 | #include <sys/prctl.h> |
||
69 | #endif |
||
70 | #include "queue_int.H" |
||
71 | |||
72 | #if defined(sgi) |
||
73 | void THREADprocessor_startup_func(void *proc); |
||
74 | #endif |
||
75 | #if defined(sol) |
||
76 | #ifndef CPLPLTHREADS |
||
77 | void *THREADprocessor_startup_func(void *proc); |
||
78 | #endif |
||
79 | #endif |
||
80 | |||
81 | #if defined(sol) |
||
82 | #if CPLPLTHREADS |
||
83 | class THREAD_processor : public Thread { |
||
84 | #else |
||
85 | class THREAD_processor { |
||
86 | #endif |
||
87 | #else |
||
88 | class THREAD_processor { |
||
89 | #endif |
||
90 | private: |
||
91 | void *(*_start_routine)(void *, void *); |
||
92 | void *_arg, *_arg2; |
||
93 | protected: |
||
94 | #if defined(sol) |
||
95 | #if CPLPLTHREADS |
||
96 | Semaphore *sema,*semaDone; |
||
97 | #else |
||
98 | thread_t thr; |
||
99 | sema_t sema,semaDone; |
||
100 | #endif |
||
101 | #elif defined(sgi) |
||
102 | pid_t pid; |
||
103 | usema_t *_sema,*semaDone; |
||
104 | #else |
||
105 | #endif |
||
106 | public: |
||
107 | void startup(); |
||
108 | #if defined(sol) |
||
109 | #ifndef CPLPLTHREADS |
||
110 | virtual void startup_func(); |
||
111 | THREAD_processor(); |
||
112 | #endif |
||
113 | #endif |
||
114 | THREAD_processor(char *name = "", char *thrname = ""); |
||
115 | virtual ~THREAD_processor() {} |
||
116 | |||
117 | virtual void start_execute(void *(*start_routine)(void *, void *), |
||
118 | void *arg, void *arg2); |
||
119 | virtual int wait_for_done(); |
||
120 | virtual int still_running(); |
||
121 | int running; |
||
122 | }; |
||
123 | |||
124 | class THREAD_mp_manager { |
||
125 | protected: |
||
126 | int num_procs() const; |
||
127 | THREAD_mp_manager(int _procs = 0); |
||
128 | }; |
||
129 | |||
130 | |||
131 | class THREADprocessor : public THREAD_processor { |
||
132 | protected: |
||
133 | public: |
||
134 | THREADprocessor(char *name = "", char *thrname = "") |
||
135 | : THREAD_processor(name, thrname) {}; |
||
136 | virtual ~THREADprocessor() {} |
||
137 | }; |
||
138 | |||
139 | class THREADmp_manager : public THREAD_mp_manager { |
||
140 | THREADprocessor **procs; |
||
141 | int _num_procs; |
||
142 | void THREADmp_initproc(int i); |
||
143 | static int procNum; // just for test |
||
144 | QUEUEint queue; |
||
145 | public: |
||
146 | THREADmp_manager(int _procs = 0); |
||
147 | virtual ~THREADmp_manager(); |
||
148 | void enqThread(int threadNumber); |
||
149 | int deqThread(); |
||
150 | |||
151 | int num_processes() const { return _num_procs; } |
||
152 | THREADprocessor *processor(int i) const { return procs[i]; } |
||
153 | void THREADmp_newproc(); |
||
154 | }; |
||
155 | |||
156 | #endif |