IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7952


Ignore:
Timestamp:
Jul 23, 2006, 3:05:21 PM (20 years ago)
Author:
eugene
Message:

adding working threads to server/client mode

Location:
trunk/Ohana/src/opihi
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/lookup.c

    r7949 r7952  
    33int lookup (int argc, char **argv) {
    44 
    5   int i, Nbins, bin, N, Normalize;
    6   float start, end, delta;
    7   float *V, *K, *O, *NV;
    8   Vector *val, *key, *out;
     5  int i, j;
     6  float *ip, *op, *xp, *yp;
     7  Vector *in, *out, *xv, *yv;
    98
    109  if (argc != 5) {
  • trunk/Ohana/src/opihi/doc/pantasks.txt

    r7929 r7952  
     1
     2- todo:
     3
     4  - create the processing threads:
     5    - check tasks
     6    - check jobs
     7    - check controller 
     8    - load inputs
    19
    210- additional issues:
    3 
    4   - missing dependency for shell.h?
    5   - should not return an error message in client if command is not found
    611  - server input needs to place files for input on a stack which is
    712    actually loaded by the RunScheduler loop
     
    1015    be running multicommand, but it probably does not hurt.
    1116    (the client is not allowed to send ';' to the server)
    12   - the multicommand needs to be available in the 'for' and other loops
    13     this probably means unifying the client and non-client forms. 
    14     how does multiclient get the value of the server?  I tend to use
    15     globals for things like that, which is probably not the best
    16     practice.  is the client form of the tool generic? are there other
    17     circumstances which would use a client/server beyond pantasks?
    18     maybe pcontrol? 
    1917
    20     the two pieces of information which need to be carried to the
    21     multicommand and command functions in client/server mode are the
    22     server socket and the verbosity of the error messages.  these could
    23     be defined on startup with globals and an init function of some sort.
     18  - pantasks input: this passes an 'input' command to the server, which
     19    performs the input in a different thread.  is this the same thread
     20    as the scheduler loop?  another option within the scheduler loop?
    2421
    25 I need to do some serious work on the output messages in order
    26 to support the client/server interactions.  In client/server mode,
    27 all of the output messages to be sent back to the client need to be
    28 saved in a buffer and then pushed back to the client after the command
    29 is executed.  Currently, I can select only the output file pointer.
    30 this is not sufficient.  I need to supply a function which will write to
    31 an internal buffer until a 'dump' function is called, or something
    32 equivalent. 
    33 
    34 in client/server mode, the commands issues by the client (except as noted
    35 below) all return immediately.  The output produced by those commands
    36 is saved by the server until the command is finished, then the
    37 resulting buffered data is pushed back to the client.  There a few
    38 commands which behave a bit differently.  these commands are in the
    39 background thread of the scheduler.  the resulting output is sent to
    40 the logger device of the scheduler rather than back to any specific
    41 client.  should there be a way for the client(s) to examine the
    42 scheduler output?
    43 
    44 - pantasks input: this passes an 'input' command to the server, which
    45   performs the input in a different thread.  is this the same thread
    46   as the scheduler loop?  another option within the scheduler loop?
    47 
    48 - run
  • trunk/Ohana/src/opihi/include/pantasks.h

    r7940 r7952  
    213213int gprintf (char *format, ...);
    214214*/
     215
     216// functions related to the server threads
     217void CheckTasksSetState (int state);
     218int CheckTasksGetState ();
     219void CheckTasksThread ();
     220void CheckJobsSetState (int state);
     221int CheckJobsGetState ();
     222void CheckJobsThread ();
     223void CheckControllerSetState (int state);
     224int CheckControllerGetState ();
     225void CheckControllerThread ();
     226void CheckInputsSetState (int state);
     227int CheckInputsGetState ();
     228void CheckInputsThread ();
     229
     230// functions related to the queue of input files
     231void InitInputs ();
     232void AddNewInput (char *input);
     233int DeleteInput (char *input);
     234void CheckInputs ();
     235
     236void SerialThreadLock ();
     237void SerialThreadUnlock ();
  • trunk/Ohana/src/opihi/pantasks/Makefile

    r7938 r7952  
    7474server = \
    7575$(SDIR)/pantasks_server.$(ARCH).o \
     76$(SDIR)/server_threads.$(ARCH).o \
     77$(SDIR)/server_run.$(ARCH).o \
     78$(SDIR)/server_load.$(ARCH).o \
     79$(SDIR)/InputQueue.$(ARCH).o \
    7680$(SDIR)/ListenClients.$(ARCH).o \
    7781$(SDIR)/CheckPassword.$(ARCH).o
  • trunk/Ohana/src/opihi/pantasks/pantasks_server.c

    r7940 r7952  
    1616int main (int argc, char **argv) {
    1717 
    18   pthread_t thread;
     18  pthread_t clientsThread;
     19  pthread_t tasksThread;
     20  pthread_t jobsThread;
     21  pthread_t inputsThread;
     22  pthread_t controllerThread;
    1923  int InitSocket, BindSocket;
    2024  SockAddress Address;
     
    3236 
    3337  gprintInit ();  // each thread needs to init the printing system
     38  InitInputs ();
    3439
    3540  signal (SIGPIPE, gotsignal);
     
    3843  signal (SIGINT, SIG_DFL);
    3944
    40   // startup (&argc, argv);
    41 
    42   /* set up mechanisms for sharing data between the threads */
    43   // init_data_handling ();
     45  startup (&argc, argv);
    4446
    4547  /* start up the background threads here */
    46   pthread_create (&thread, NULL, &ListenClients, NULL);
    47 
    48   // pthread_create (&thread, NULL, &RunScheduler, NULL);
    49   // pthread_create (&thread, NULL, &RunController, NULL);
     48  pthread_create (&clientsThread,    NULL, &ListenClients,         NULL);
     49  pthread_create (&tasksThread,      NULL, &CheckTasksThread,      NULL);
     50  pthread_create (&jobsThread,       NULL, &CheckJobsThread,       NULL);
     51  pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL);
     52  pthread_create (&inputsThread,     NULL, &CheckInputsThread,     NULL);
    5053
    5154  /* in this loop, we listen for incoming connections, validate, and
  • trunk/Ohana/src/opihi/pantasks/server.c

    r7930 r7952  
    44int quit            PROTO((int, char **));
    55int input           PROTO((int, char **));
     6int server_load     PROTO((int, char **));
     7int server_run      PROTO((int, char **));
     8int server_stop     PROTO((int, char **));
    69int cd              PROTO((int, char **));
    710int pwd             PROTO((int, char **));
     
    1417  {"quit",   quit,   "shutdown server"},
    1518  {"input",  input,  "load input file on server"},
     19  {"load",   server_load, "load input file on server"},
     20  {"run",    server_run,  "run scheduler"},
     21  {"stop",   server_stop, "stop scheduler"},
    1622  {"cd",     cd,     "set local directory"},
    1723  {"pwd",    pwd,    "check local directory"},
  • trunk/Ohana/src/opihi/pantasks/status.c

    r7917 r7952  
    99    gprint (GP_LOG, " Scheduler is running\n");
    1010  }
    11   if (CheckControllerStatus ()) {
     11  if (CheckControllerStatus()) {
     12    gprint (GP_LOG, " Controller is running\n");
     13  } else {
     14    gprint (GP_LOG, " Controller is stopped\n");
     15  }
     16  if (CheckTasksGetState()) {
     17    gprint (GP_LOG, " Scheduler is running\n");
     18  } else {
     19    gprint (GP_LOG, " Scheduler is stopped\n");
     20  }
     21  if (CheckControllerGetState()) {
    1222    gprint (GP_LOG, " Controller is running\n");
    1323  } else {
Note: See TracChangeset for help on using the changeset viewer.