automotive-dlt
|
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <limits.h>
#include <signal.h>
#include <errno.h>
#include <pthread.h>
#include <sys/wait.h>
#include <syslog.h>
#include "dlt.h"
#include "dlt_common.h"
#include "dlt-test-multi-process.h"
Go to the source code of this file.
Data Structures | |
struct | s_parameters |
struct | s_thread_data |
Macros | |
#define | MAX_PROCS 100 |
#define | MAX_THREADS 100 |
Functions | |
void | init_params (s_parameters *params) |
void | quit_handler (int signum) |
void | cleanup () |
void | do_forks (s_parameters params) |
void | run_threads (s_parameters params) |
void | do_logging (s_thread_data *data) |
int | wait_for_death () |
void | usage (char *prog_name) |
int | read_cli (s_parameters *params, int argc, char **argv) |
int | main (int argc, char **argv) |
time_t | mksleep_time (int delay, int fudge) |
Variables | |
volatile sig_atomic_t | in_handler = 0 |
pid_t | pids [MAX_PROCS] |
unsigned int | pidcount = 0 |
Definition in file dlt-test-multi-process.c.
#define MAX_PROCS 100 |
Definition at line 62 of file dlt-test-multi-process.c.
Referenced by read_cli(), and usage().
#define MAX_THREADS 100 |
Definition at line 63 of file dlt-test-multi-process.c.
Referenced by usage().
void cleanup | ( | ) |
Ask the child processes to die
Definition at line 275 of file dlt-test-multi-process.c.
References pidcount, and pids.
Referenced by do_forks(), main(), and quit_handler().
void do_forks | ( | s_parameters | params | ) |
Start the child processes
Definition at line 222 of file dlt-test-multi-process.c.
References cleanup(), s_parameters::nprocs, pidcount, pids, and run_threads().
Referenced by main().
void do_logging | ( | s_thread_data * | data | ) |
Open logging channel and proceed to spam messages
Definition at line 298 of file dlt-test-multi-process.c.
References s_parameters::delay, s_parameters::delay_fudge, DLT_LOG, DLT_LOG_INFO, DLT_REGISTER_CONTEXT, DLT_STRING, DLT_UNREGISTER_CONTEXT, mksleep_time(), mycontext, s_parameters::nmsgs, s_thread_data::params, and PAYLOAD_DATA.
Referenced by run_threads().
void init_params | ( | s_parameters * | params | ) |
Set nice default values for parameters
Definition at line 119 of file dlt-test-multi-process.c.
References s_parameters::delay, s_parameters::delay_fudge, s_parameters::nmsgs, s_parameters::nprocs, and s_parameters::nthreads.
int main | ( | int | argc, |
char ** | argv | ||
) |
Entry point
Definition at line 189 of file dlt-test-multi-process.c.
References cleanup(), do_forks(), init_params(), quit_handler(), read_cli(), usage(), and wait_for_death().
time_t mksleep_time | ( | int | delay, |
int | fudge | ||
) |
Generate the next sleep time
Definition at line 287 of file dlt-test-multi-process.c.
Referenced by do_logging().
void quit_handler | ( | int | signum | ) |
Clean up the child processes. Reraise signal to default handler.
Definition at line 260 of file dlt-test-multi-process.c.
References cleanup(), and in_handler.
Referenced by main().
int read_cli | ( | s_parameters * | params, |
int | argc, | ||
char ** | argv | ||
) |
Read the command line and modify parameters
Definition at line 130 of file dlt-test-multi-process.c.
References s_parameters::delay, s_parameters::delay_fudge, MAX_PROCS, s_parameters::nmsgs, s_parameters::nprocs, and s_parameters::nthreads.
Referenced by main().
void run_threads | ( | s_parameters | params | ) |
Start the threads and wait for them to return.
Definition at line 321 of file dlt-test-multi-process.c.
References DLT_REGISTER_APP, DLT_UNREGISTER_APP, do_logging(), s_parameters::nthreads, NULL, s_thread_data::params, and pidcount.
Referenced by do_forks().
void usage | ( | char * | prog_name | ) |
Print instructions.
Definition at line 98 of file dlt-test-multi-process.c.
References s_parameters::delay, s_parameters::delay_fudge, dlt_get_version(), init_params(), MAX_PROCS, MAX_THREADS, s_parameters::nmsgs, s_parameters::nprocs, and s_parameters::nthreads.
Referenced by main().
int wait_for_death | ( | ) |
Wait for child processes to complete their work.
Definition at line 361 of file dlt-test-multi-process.c.
References pidcount, and pids.
Referenced by main().
volatile sig_atomic_t in_handler = 0 |
Definition at line 89 of file dlt-test-multi-process.c.
Referenced by quit_handler().
unsigned int pidcount = 0 |
Definition at line 93 of file dlt-test-multi-process.c.
Referenced by cleanup(), do_forks(), run_threads(), and wait_for_death().
pid_t pids[MAX_PROCS] |
Definition at line 92 of file dlt-test-multi-process.c.
Referenced by cleanup(), do_forks(), and wait_for_death().