- Timestamp:
- Feb 3, 2021, 2:12:35 PM (5 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 8 edited
-
include/pantasks.h (modified) (1 diff)
-
lib.shell/gprint.c (modified) (2 diffs)
-
pantasks/CheckTasks.c (modified) (1 diff)
-
pantasks/ListenClients.c (modified) (3 diffs)
-
pantasks/controller_threads.c (modified) (4 diffs)
-
pantasks/jobs_and_tasks_thread.c (modified) (4 diffs)
-
pantasks/pantasks.c.in (modified) (3 diffs)
-
pantasks/pantasks_server.c.in (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/include/pantasks.h
r40424 r41483 265 265 int DeleteClient (int client); 266 266 void *ListenClients (void *data); 267 void QuitClientThread (void); 267 268 268 269 // functions related to the server threads 269 270 void *CheckJobsAndTasksThread (void *data); 271 void QuitJobsAndTasksThread (void); 272 void QuitControllerThread (void); 270 273 271 274 void CheckTasksSetState (int state); -
trunk/Ohana/src/opihi/lib.shell/gprint.c
r38986 r41483 304 304 305 305 if (stream[0].mode == GP_FILE) { 306 // fprintf (stderr, "printing to %s, mode FILE, thread %d\n", stream[0].name, (int) stream[0].thread); 306 307 status = vfprintf (stream[0].file, format, argp); 307 308 fflush (stream[0].file); … … 310 311 } 311 312 } else { 313 // fprintf (stderr, "printing to %s, mode BUFF, thread %d\n", stream[0].name, (int) stream[0].thread); 312 314 vPrintIOBuffer (stream[0].buffer, format, argp); 313 315 } -
trunk/Ohana/src/opihi/pantasks/CheckTasks.c
r38986 r41483 52 52 // XXX this should be optional 53 53 fuzz = task[0].exec_period*(0.5*drand48() - 0.25); 54 task[0].last.tv_usec = 1e6*(fuzz - (int)fuzz);54 task[0].last.tv_usec += 1e6*(fuzz - (int)fuzz); 55 55 task[0].last.tv_sec += (int) fuzz; 56 56 -
trunk/Ohana/src/opihi/pantasks/ListenClients.c
r39457 r41483 7 7 static int *clients; 8 8 static IOBuffer **buffers; 9 10 static int ClientThreadRuns = TRUE; 11 12 void QuitClientThread (void) { 13 ClientThreadRuns = FALSE; 14 } 9 15 10 16 void InitClients () { … … 83 89 gprintSetBuffer (GP_ERR); 84 90 85 while ( 1) {91 while (ClientThreadRuns) { 86 92 87 93 /* Wait up to 0.5 second - need to timeout to update client list */ … … 174 180 /* check if we need to shut down the thread */ 175 181 } 182 return NULL; 176 183 } 177 184 -
trunk/Ohana/src/opihi/pantasks/controller_threads.c
r39457 r41483 5 5 static int CheckControllerRun = FALSE; 6 6 7 static int ControllerThreadRuns = TRUE; 8 7 9 void CheckControllerSetState (int state) { 8 10 CheckControllerRun = state; … … 10 12 int CheckControllerGetState () { 11 13 return (CheckControllerRun); 14 } 15 16 void QuitControllerThread (void) { 17 ControllerThreadRuns = FALSE; 12 18 } 13 19 … … 26 32 } 27 33 28 while ( 1) {34 while (ControllerThreadRuns) { 29 35 30 36 // check for thread suspend … … 47 53 usleep (500000); // allow other threads a chance to run 48 54 } 55 return NULL; 49 56 } -
trunk/Ohana/src/opihi/pantasks/jobs_and_tasks_thread.c
r39457 r41483 5 5 static int CheckTasksRun = FALSE; 6 6 static int CheckJobsRun = FALSE; 7 8 static int JobsAndTasksThreadRuns = TRUE; 7 9 8 10 void CheckJobsSetState (int state) { … … 23 25 } 24 26 27 void QuitJobsAndTasksThread (void) { 28 JobsAndTasksThreadRuns = FALSE; 29 } 30 25 31 void *CheckJobsAndTasksThread (void *data) { 26 32 OHANA_UNUSED_PARAM(data); … … 39 45 } 40 46 41 while ( 1) {47 while (JobsAndTasksThreadRuns) { 42 48 43 49 // one run of the task checker … … 63 69 } 64 70 } 71 return NULL; 65 72 } 66 73 -
trunk/Ohana/src/opihi/pantasks/pantasks.c.in
r39457 r41483 7 7 # define opihi_rcfile ".pantasksrc" 8 8 9 static pthread_t JobsAndTasksThread; 10 static pthread_t controllerThread; 11 9 12 /* program-dependent initialization */ 10 13 void program_init (int *argc, char **argv) { … … 12 15 OHANA_UNUSED_PARAM(argv); 13 16 14 pthread_t JobsAndTasksThread;15 pthread_t controllerThread;16 17 17 auto_break = TRUE; 18 18 … … 67 67 /* add program-dependent exit functions here */ 68 68 void cleanup () { 69 // stop the threads before calling the free functions 69 70 QuitKapa (); 70 71 QuitController (); 71 72 ConfigFree (); 73 74 // tell the threads to exit and wait for them to exit 75 QuitJobsAndTasksThread(); pthread_join (JobsAndTasksThread, NULL); 76 QuitControllerThread(); pthread_join (controllerThread, NULL); 72 77 73 78 FreeBasic (); -
trunk/Ohana/src/opihi/pantasks/pantasks_server.c.in
r39457 r41483 15 15 void special_init (int *argc, char **argv); 16 16 17 static pthread_t JobsAndTasksThread; 18 static pthread_t controllerThread; 19 static pthread_t clientsThread; 20 17 21 /* program-dependent initialization */ 18 22 int main (int argc, char **argv) { … … 20 24 char hostname[256], portinfo[256]; 21 25 char log_stdout[1024], log_stderr[1024], tmpname[1024]; 22 pthread_t JobsAndTasksThread;23 pthread_t clientsThread;24 pthread_t controllerThread;25 26 int InitSocket, BindSocket; 26 27 SockAddress Address; … … 136 137 QuitController (); 137 138 ConfigFree (); 139 140 QuitJobsAndTasksThread(); pthread_join (JobsAndTasksThread, NULL); 141 QuitControllerThread(); pthread_join (controllerThread, NULL); 142 QuitClientThread(); pthread_join (clientsThread, NULL); 143 138 144 InitBasic (); 139 145 InitData ();
Note:
See TracChangeset
for help on using the changeset viewer.
