concurrent.c revision 95ee490bbdb97ab2b4f1dfa63a0a26e0dd1c2f17
/* concurrent.c
*
* Copyright © 2013 S.Çağlar Onur <caglar@10ur.org>
*
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <limits.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#define _GNU_SOURCE
#include <getopt.h>
#include <lxc/lxccontainer.h>
static int nthreads = 5;
static int iterations = 1;
static int quiet = 0;
static int delay = 0;
static const char *template = "busybox";
{ 0, 0, 0, 0 },
};
static void usage(void) {
"Common options :\n"
" -j, --threads=N Threads to run concurrently\n"
" (default: 5, use 1 for no threading)\n"
" -i, --iterations=N Number times to run the test (default: 1)\n"
" -t, --template=t Template to use (default: busybox)\n"
" -d, --delay=N Delay in seconds between start and stop\n"
" -m, --modes=<mode,mode,...> Modes to run (create, start, stop, destroy)\n"
" -q, --quiet Don't produce any output\n"
" -?, --help Give this help list\n"
"\n"
"Mandatory or optional arguments to long options are also mandatory or optional\n"
"for any corresponding short options.\n\n");
}
struct thread_args {
int thread_id;
int return_code;
char *mode;
};
static void do_function(void *arguments)
{
struct lxc_container *c;
if (!c) {
return;
}
if (!c->is_defined(c)) {
goto out;
}
}
if (c->is_defined(c) && !c->is_running(c)) {
c->want_daemonize(c, true);
goto out;
}
goto out;
}
}
if (c->is_defined(c) && c->is_running(c)) {
if (!c->stop(c)) {
goto out;
}
goto out;
}
}
if (c->is_defined(c) && !c->is_running(c)) {
if (!c->destroy(c)) {
goto out;
}
}
}
args->return_code = 0;
out:
}
static void *concurrent(void *arguments)
{
return NULL;
}
struct thread_args *args;
char **modes = modes_default;
switch(opt) {
case 'j':
break;
case 'i':
break;
case 't':
break;
case 'd':
break;
case 'q':
quiet = 1;
break;
case 'm': {
}
break;
}
default: /* '?' */
usage();
}
}
}
int fd;
if (!quiet)
for (i = 0; modes[i];i++) {
if (!quiet)
for (j = 0; j < nthreads; j++) {
if (nthreads > 1) {
perror("pthread_create() error");
}
} else {
do_function(&args[j]);
}
}
for (j = 0; j < nthreads; j++) {
if (nthreads > 1) {
perror("pthread_join() error");
}
}
if (args[j].return_code) {
}
}
}
}
}