Changeset 54da7c3e in rtems


Ignore:
Timestamp:
Jun 28, 2012, 1:03:15 PM (7 years ago)
Author:
Christian Mauderer <christian.mauderer@…>
Branches:
4.11, master
Children:
5267241
Parents:
ea008e2
git-author:
Christian Mauderer <christian.mauderer@…> (06/28/12 13:03:15)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/12/12 07:51:44)
Message:

mghttpd: Add stack size and scheduling options

Location:
cpukit/mghttpd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/mghttpd/mongoose.1

    rea008e2 r54da7c3e  
    144144matches, no further matching/substitution is performed
    145145(first matching pattern wins). Use full paths in substitutions. Default: ""
     146.It Fl x Ar thread_stack_size
     147Use the given amount of stack for each thread. Default: ""
     148.It Fl y Ar thread_priority
     149Use the given priority for all posix threads. If this option is used without the
     150thread_policy option, the systems default scheduling policy will be used for the
     151threads instead of inheriting the policy of the creating thread. Default: ""
     152.It Fl z Ar thread_policy
     153Select the posix scheduling policy for the threads.  Possible Values are 's' for
     154sporadic (not on all systems available), 'r' for round robin, 'f' for fifo or
     155'o' for other scheduling strategie. If this option is used without the
     156thread_priority option, the systems default priority will be used for the
     157threads instead of inheriting the priority of the creating thread. Default: ""
    146158.El
    147159.Pp
  • cpukit/mghttpd/mongoose.c

    rea008e2 r54da7c3e  
    425425  EXTRA_MIME_TYPES, LISTENING_PORTS,
    426426  DOCUMENT_ROOT, SSL_CERTIFICATE, NUM_THREADS, RUN_AS_USER, REWRITE,
     427  THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_POLICY,
    427428  NUM_OPTIONS
    428429};
     
    452453  "u", "run_as_user", NULL,
    453454  "w", "url_rewrite_patterns", NULL,
     455  "x", "thread_stack_size", NULL,
     456  "y", "thread_priority", NULL,
     457  "z", "thread_policy", NULL,
    454458  NULL
    455459};
     
    12781282  pthread_attr_t attr;
    12791283  int retval;
     1284  char* stacksize = ctx->config[THREAD_STACK_SIZE];
     1285  char* priority = ctx->config[THREAD_PRIORITY];
     1286  char* policy = ctx->config[THREAD_POLICY];
     1287  int noinheritsched = 0;
    12801288
    12811289  (void) pthread_attr_init(&attr);
     
    12831291  // TODO(lsm): figure out why mongoose dies on Linux if next line is enabled
    12841292  // (void) pthread_attr_setstacksize(&attr, sizeof(struct mg_connection) * 5);
     1293
     1294  if (stacksize != NULL) {
     1295    size_t size = atoi(stacksize);
     1296    (void) pthread_attr_setstacksize(&attr, size);
     1297  }
     1298
     1299  if (priority != NULL) {
     1300    struct sched_param sched_param;
     1301    memset(&sched_param, 0, sizeof(sched_param));
     1302    sched_param.sched_priority = atoi(priority);
     1303    (void) pthread_attr_setschedparam(&attr, &sched_param);
     1304    noinheritsched = 1;
     1305  }
     1306
     1307  if (policy != NULL) {
     1308    int p_policy;
     1309    (void) pthread_attr_getschedpolicy(&attr, &p_policy);
     1310
     1311    switch (policy[0]) {
     1312      case 'o':
     1313        p_policy = SCHED_OTHER;
     1314        break;
     1315      case 'f':
     1316        p_policy = SCHED_FIFO;
     1317        break;
     1318      case 'r':
     1319        p_policy = SCHED_RR;
     1320        break;
     1321#if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER)
     1322      case 's':
     1323        p_policy = SCHED_SPORADIC;
     1324        break;
     1325#endif
     1326      default:
     1327        cry(fc(ctx), "%s: Unknown scheduler: %s", __func__, policy);
     1328        break;
     1329    }
     1330
     1331    (void) pthread_attr_setschedpolicy(&attr, p_policy);
     1332
     1333    noinheritsched = 1;
     1334  }
     1335
     1336  if (noinheritsched != 0) {
     1337    (void) pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
     1338  }
    12851339
    12861340  if ((retval = pthread_create(&thread_id, &attr, func, param)) != 0) {
Note: See TracChangeset for help on using the changeset viewer.