Changeset 8548
- Timestamp:
- Aug 23, 2006, 5:31:41 PM (20 years ago)
- Location:
- trunk/Ohana/src/opihi/pantasks
- Files:
-
- 1 added
- 17 edited
-
CheckPassword.c (modified) (1 diff)
-
ControllerOps.c (modified) (2 diffs)
-
InputQueue.c (modified) (1 diff)
-
ListenClients.c (modified) (1 diff)
-
LocalJob.c (modified) (2 diffs)
-
Makefile (modified) (3 diffs)
-
TaskOps.c (modified) (1 diff)
-
client_shell.c (modified) (1 diff)
-
controller.c (modified) (4 diffs)
-
controller_host.c (modified) (1 diff)
-
controller_run.c (added)
-
controller_status.c (modified) (1 diff)
-
init_server.c (modified) (2 diffs)
-
pantasks_server.c (modified) (2 diffs)
-
server.c (modified) (2 diffs)
-
server_run.c (modified) (2 diffs)
-
server_threads.c (modified) (13 diffs)
-
status_server.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/CheckPassword.c
r7917 r8548 7 7 8 8 VarConfig ("PASSWORD", "%s", PASSWORD); 9 9 return (TRUE); 10 10 } 11 11 -
trunk/Ohana/src/opihi/pantasks/ControllerOps.c
r8184 r8548 290 290 status = ReadtoIOBuffer (&buffer, stdout_fd[0]); 291 291 p = memstr (buffer.buffer, "CONNECTED", buffer.Nbuffer); 292 usleep (10000); 292 usleep (10000); // wait for controller to start up 293 293 } 294 294 if (status == 0) goto pipe_error; … … 464 464 result = waitpid (ControllerPID, &waitstatus, WNOHANG); 465 465 for (i = 0; (i < 10) && (result == 0); i++) { 466 usleep (10000); / * 10 ms is min */466 usleep (10000); // wait for controller to exit 467 467 result = waitpid (ControllerPID, &waitstatus, WNOHANG); 468 468 } -
trunk/Ohana/src/opihi/pantasks/InputQueue.c
r7952 r8548 65 65 66 66 Nbytes = snprintf (&tmp, 0, "input %s", input); 67 fprintf (stderr, "string len %d\n", Nbytes);68 69 67 ALLOCATE (line, char, Nbytes + 1); 70 fprintf (stderr, "allocated line\n");71 72 68 snprintf (line, Nbytes + 1, "input %s", input); 73 74 fprintf (stderr, "running command %s\n", line);75 69 76 70 status = command (line, &outline, TRUE); -
trunk/Ohana/src/opihi/pantasks/ListenClients.c
r7940 r8548 66 66 struct timeval timeout; 67 67 IOBuffer *outbuffer; 68 IOBuffer testbuffer;69 68 70 69 InitClients (); -
trunk/Ohana/src/opihi/pantasks/LocalJob.c
r7917 r8548 166 166 result = 0; 167 167 for (i = 0; (i < 10) && (result == 0); i++) { 168 usleep (10000); / * 10 ms is min */168 usleep (10000); // wait for job to exit 169 169 result = waitpid (job[0].pid, &waitstatus, WNOHANG); 170 170 } … … 175 175 result = 0; 176 176 for (i = 0; (i < 10) && (result == 0); i++) { 177 usleep (10000); / * 10 ms is min */177 usleep (10000); // wait for job to exit 178 178 result = waitpid (job[0].pid, &waitstatus, WNOHANG); 179 179 } -
trunk/Ohana/src/opihi/pantasks/Makefile
r8129 r8548 26 26 27 27 single = \ 28 $(SDIR)/pantasks.$(ARCH).o 28 $(SDIR)/init.$(ARCH).o \ 29 $(SDIR)/run.$(ARCH).o \ 30 $(SDIR)/stop.$(ARCH).o \ 31 $(SDIR)/pantasks.$(ARCH).o \ 32 $(SDIR)/CheckSystem.$(ARCH).o 29 33 30 34 funcs = \ 31 $(SDIR)/init.$(ARCH).o \32 35 $(SDIR)/CheckJobs.$(ARCH).o \ 33 $(SDIR)/CheckSystem.$(ARCH).o \34 36 $(SDIR)/CheckController.$(ARCH).o \ 35 37 $(SDIR)/CheckTasks.$(ARCH).o \ … … 42 44 43 45 cmds = \ 44 $(SDIR)/run.$(ARCH).o \45 $(SDIR)/stop.$(ARCH).o \46 46 $(SDIR)/pulse.$(ARCH).o \ 47 47 $(SDIR)/status.$(ARCH).o \ … … 54 54 $(SDIR)/controller_check.$(ARCH).o \ 55 55 $(SDIR)/controller_status.$(ARCH).o \ 56 $(SDIR)/controller_run.$(ARCH).o \ 56 57 $(SDIR)/controller_output.$(ARCH).o \ 57 58 $(SDIR)/controller_pulse.$(ARCH).o \ -
trunk/Ohana/src/opihi/pantasks/TaskOps.c
r8192 r8548 128 128 129 129 int i, j; 130 char *start, *stop 130 char *start, *stop; 131 131 Task *task; 132 132 -
trunk/Ohana/src/opihi/pantasks/client_shell.c
r7938 r8548 4 4 int client_shell (int argc, char **argv) { 5 5 6 int i, Nbad, status, server;6 int Nbad, status; 7 7 char *line, *prompt, *history; 8 8 pid_t ppid; -
trunk/Ohana/src/opihi/pantasks/controller.c
r7917 r8548 4 4 int controller_exit PROTO((int, char **)); 5 5 int controller_status PROTO((int, char **)); 6 int controller_run PROTO((int, char **)); 7 int controller_stop PROTO((int, char **)); 6 8 int controller_check PROTO((int, char **)); 7 9 int controller_output PROTO((int, char **)); … … 12 14 {"host", controller_host, "define host for controller"}, 13 15 {"check", controller_check, "check controller host/job"}, 16 {"run", controller_run, "start controller operation"}, 17 {"stop", controller_stop, "stop controller (no disconnect)"}, 14 18 {"status", controller_status, "check controller status"}, 15 19 {"output", controller_output, "print controller output"}, … … 19 23 int controller (int argc, char **argv) { 20 24 21 int status;25 int i, N, status; 22 26 CommandF *func; 23 27 … … 25 29 gprint (GP_ERR, "USAGE: controller (command) ... \n"); 26 30 return (FALSE); 31 } 32 33 if (!strcasecmp (argv[1], "help")) { 34 N = sizeof (controller_cmds) / sizeof (Command); 35 36 for (i = 0; i < N; i++) { 37 gprint (GP_LOG, "%-15s %s\n", controller_cmds[i].name, controller_cmds[i].help); 38 } 39 return (TRUE); 27 40 } 28 41 -
trunk/Ohana/src/opihi/pantasks/controller_host.c
r8184 r8548 20 20 sprintf (command, "host %s %s", argv[1], argv[2]); 21 21 InitIOBuffer (&buffer, 0x100); 22 23 SerialThreadLock (); 22 24 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 25 SerialThreadUnlock (); 26 23 27 if (status) gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG); 28 24 29 FreeIOBuffer (&buffer); 25 30 return (TRUE); -
trunk/Ohana/src/opihi/pantasks/controller_status.c
r7917 r8548 15 15 status = CheckControllerStatus (); 16 16 if (!status) { 17 gprint (GP_LOG, "controller is not running\n");17 gprint (GP_LOG, "controller is not active\n"); 18 18 return (TRUE); 19 19 } 20 20 21 21 22 sprintf (command, "status"); 22 23 InitIOBuffer (&buffer, 0x100); 24 25 SerialThreadLock (); 23 26 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 27 SerialThreadUnlock (); 28 24 29 if (status) { 25 30 gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG); 26 31 } else { 27 gprint (GP_LOG, "controller is down\n");32 gprint (GP_LOG, "controller is not communicating\n"); 28 33 } 29 34 FreeIOBuffer (&buffer); -
trunk/Ohana/src/opihi/pantasks/init_server.c
r7960 r8548 8 8 int task_macros PROTO((int, char **)); 9 9 int task_command PROTO((int, char **)); 10 int task_options PROTO((int, char **)); 10 11 int task_periods PROTO((int, char **)); 11 int run PROTO((int, char **));12 int stop PROTO((int, char **));13 12 int pulse PROTO((int, char **)); 14 13 int status_server PROTO((int, char **)); … … 17 16 int verbose PROTO((int, char **)); 18 17 int version PROTO((int, char **)); 19 int server PROTO((int, char **));18 int server PROTO((int, char **)); 20 19 21 20 static Command cmds[] = { 22 {"controller", controller, "controller commands"}, 23 {"task", task, "define a schedulable task"}, 24 {"host", task_host, "define host machine for a task"}, 25 {"nmax", task_nmax, "define maximum number of jobs for a task"}, 26 {"trange", task_trange, "define valid/invalid time periods for a task"}, 27 {"task.exit", task_macros, "define exit macros for a task"}, 28 {"task.exec", task_macros, "define pre-exec macro for a task"}, 29 {"command", task_command, "define executed command for a task"}, 30 {"periods", task_periods, "define time scales for a task"}, 31 {"run", run, "run the scheduler"}, 32 {"stop", stop, "stop the scheduler"}, 33 {"pulse", pulse, "set the scheduler update period"}, 34 {"server", server, "server-specific commands"}, 21 {"controller", controller, "controller commands"}, 22 {"task", task, "define a schedulable task"}, 23 {"host", task_host, "define host machine for a task"}, 24 {"nmax", task_nmax, "define maximum number of jobs for a task"}, 25 {"trange", task_trange, "define valid/invalid time periods for a task"}, 26 {"task.exit", task_macros, "define exit macros for a task"}, 27 {"task.exec", task_macros, "define pre-exec macro for a task"}, 28 {"command", task_command, "define executed command for a task"}, 29 {"options", task_options, "define optional variables associated with the job task"}, 30 {"periods", task_periods, "define time scales for a task"}, 31 {"pulse", pulse, "set the scheduler update period"}, 32 {"server", server, "server-specific commands"}, 35 33 {"status", status_server, "get system status"}, 36 {"kill", kill_job, "kill job"},37 {"delete", delete_job, "delete job"},38 {"version", version, "show version information"},39 {"verbose", verbose, "set/toggle verbose mode"},34 {"kill", kill_job, "kill job"}, 35 {"delete", delete_job, "delete job"}, 36 {"version", version, "show version information"}, 37 {"verbose", verbose, "set/toggle verbose mode"}, 40 38 }; 41 39 -
trunk/Ohana/src/opihi/pantasks/pantasks_server.c
r7952 r8548 18 18 pthread_t clientsThread; 19 19 pthread_t tasksThread; 20 pthread_t jobsThread;20 // pthread_t jobsThread; 21 21 pthread_t inputsThread; 22 22 pthread_t controllerThread; … … 48 48 pthread_create (&clientsThread, NULL, &ListenClients, NULL); 49 49 pthread_create (&tasksThread, NULL, &CheckTasksThread, NULL); 50 pthread_create (&jobsThread, NULL, &CheckJobsThread, NULL);50 // pthread_create (&jobsThread, NULL, &CheckJobsThread, NULL); 51 51 pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL); 52 52 pthread_create (&inputsThread, NULL, &CheckInputsThread, NULL); -
trunk/Ohana/src/opihi/pantasks/server.c
r7952 r8548 27 27 int server (int argc, char **argv) { 28 28 29 int status;29 int i, N, status; 30 30 CommandF *func; 31 31 … … 33 33 gprint (GP_ERR, "USAGE: server (command) ... \n"); 34 34 return (FALSE); 35 } 36 37 if (!strcasecmp (argv[1], "help")) { 38 N = sizeof (server_cmds) / sizeof (Command); 39 40 for (i = 0; i < N; i++) { 41 gprint (GP_LOG, "%-15s %s\n", server_cmds[i].name, server_cmds[i].help); 42 } 43 return (TRUE); 35 44 } 36 45 -
trunk/Ohana/src/opihi/pantasks/server_run.c
r7952 r8548 9 9 10 10 CheckTasksSetState (TRUE); 11 // CheckJobsSetState (TRUE); 12 CheckControllerSetState (TRUE); 13 CheckInputsSetState (TRUE); 11 14 return (TRUE); 12 15 } … … 20 23 21 24 CheckTasksSetState (FALSE); 25 // CheckJobsSetState (FALSE); 26 CheckControllerSetState (FALSE); 27 CheckInputsSetState (FALSE); 22 28 return (TRUE); 23 29 } -
trunk/Ohana/src/opihi/pantasks/server_threads.c
r7960 r8548 13 13 } 14 14 15 /* the threaded version of pantasks does not worry about limiting the 16 time spent in one of the test loops -- comms with the client are 17 in a separate thread anyway... 18 */ 19 20 int TestElapsedCheck () { 21 return (FALSE); 22 } 23 15 24 /** things related to CheckTasks **/ 16 25 … … 24 33 } 25 34 26 void CheckTasksThread (void *data) {35 void *CheckTasksThread (void *data) { 27 36 28 37 gprintInit (); // each thread needs to init the printing system … … 31 40 // check for thread suspend 32 41 if (!CheckTasksRun) { 33 usleep ( 500000);42 usleep (100000); // idle if thread action is suspended 34 43 continue; 35 44 } … … 38 47 SerialThreadLock (); 39 48 CheckTasks (); 49 CheckJobs (); 40 50 SerialThreadUnlock (); 41 51 fprintf (stderr, "T"); 42 usleep ( 250000);52 usleep (10000); // allow other threads a chance to run 43 53 } 44 54 } 45 55 56 # if 0 57 // XXX need to harvest jobs on the same thread as they were 58 // spawned. for the moment, put CheckTasks and CheckJobs in 59 // a single thread. 46 60 /** things related to CheckJobs **/ 47 61 … … 55 69 } 56 70 57 void CheckJobsThread (void *data) {71 void *CheckJobsThread (void *data) { 58 72 59 73 gprintInit (); // each thread needs to init the printing system … … 62 76 // check for thread suspend 63 77 if (!CheckJobsRun) { 64 usleep ( 500000);78 usleep (100000); // idle if thread action is suspended 65 79 continue; 66 80 } … … 71 85 SerialThreadUnlock (); 72 86 fprintf (stderr, "J"); 73 usleep ( 250000);87 usleep (10000); // allow other threads a chance to run 74 88 } 75 89 } 90 # endif 76 91 77 92 /** things related to CheckController **/ … … 86 101 } 87 102 88 void CheckControllerThread (void *data) {103 void *CheckControllerThread (void *data) { 89 104 90 105 gprintInit (); // each thread needs to init the printing system … … 93 108 // check for thread suspend 94 109 if (!CheckControllerRun) { 95 usleep ( 500000);110 usleep (100000); // idle if thread action is suspended 96 111 continue; 97 112 } … … 103 118 SerialThreadUnlock (); 104 119 fprintf (stderr, "C"); 105 usleep ( 250000);120 usleep (10000); // allow other threads a chance to run 106 121 } 107 122 } … … 118 133 } 119 134 120 void CheckInputsThread (void *data) {135 void *CheckInputsThread (void *data) { 121 136 122 137 gprintInit (); // each thread needs to init the printing system … … 125 140 // check for thread suspend 126 141 if (!CheckInputsRun) { 127 usleep ( 500000);142 usleep (100000); // idle if thread action is suspended 128 143 continue; 129 144 } … … 134 149 SerialThreadUnlock (); 135 150 fprintf (stderr, "I"); 136 usleep ( 250000);151 usleep (10000); // allow other threads a chance to run 137 152 } 138 153 } -
trunk/Ohana/src/opihi/pantasks/status_server.c
r7960 r8548 10 10 } 11 11 if (CheckControllerGetState()) { 12 gprint (GP_LOG, " Controller is running\n");12 gprint (GP_LOG, " Controller is active\n"); 13 13 } else { 14 gprint (GP_LOG, " Controller is stopped\n");14 gprint (GP_LOG, " Controller is not active\n"); 15 15 } 16 16 ListTasks (FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.
