char *MAX_MSGS = "/proc/sys/fs/mqueue/msg_max";
char *MAX_MSGSIZE = "/proc/sys/fs/mqueue/msgsize_max";
-#define min(a,b) ((a) < (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
#define MAX_CPUS 64
char *cpu_option_string;
int cpus_to_pin[MAX_CPUS];
struct mq_attr result;
int mq_prio_max;
-const struct poptOption options[] =
-{
+const struct poptOption options[] = {
{
.longName = "continuous",
.shortName = 'c',
if (in_shutdown++)
return;
- for (i=0; i < num_cpus_to_pin; i++)
+ for (i = 0; i < num_cpus_to_pin; i++)
if (cpu_threads[i]) {
pthread_kill(cpu_threads[i], SIGUSR1);
pthread_join(cpu_threads[i], NULL);
pthread_exit(0);
else {
fprintf(stderr, "Caught signal %d in SIGUSR1 handler, "
- "exiting\n", signum);
+ "exiting\n", signum);
shutdown(0, "", 0);
fprintf(stderr, "\n\nReturned from shutdown?!?!\n\n");
exit(0);
int flags = O_RDWR | O_EXCL | O_CREAT | O_NONBLOCK;
int perms = DEFFILEMODE;
- if ((queue = mq_open(queue_path, flags, perms, attr)) == -1)
+ queue = mq_open(queue_path, flags, perms, attr);
+ if (queue == -1)
shutdown(1, "mq_open()", __LINE__);
if (mq_getattr(queue, &result))
shutdown(1, "mq_getattr()", __LINE__);
{
int i;
- for (i=0; i < num_cpus_to_pin; i++)
+ for (i = 0; i < num_cpus_to_pin; i++)
if (cpu_threads[i] == pthread_self())
break;
printf("\tStarted fake continuous mode thread %d on CPU %d\n", i,
cpus_to_pin[i]);
- while(1) ;
+ while (1)
+ ;
}
void *cont_thread(void *arg)
char buff[MSG_SIZE];
int i, priority;
- for (i=0; i < num_cpus_to_pin; i++)
+ for (i = 0; i < num_cpus_to_pin; i++)
if (cpu_threads[i] == pthread_self())
break;
printf("\tStarted continuous mode thread %d on CPU %d\n", i,
cpus_to_pin[i]);
- while(1) {
- while(mq_send(queue, buff, sizeof(buff), 0) == 0);
+ while (1) {
+ while (mq_send(queue, buff, sizeof(buff), 0) == 0)
+ ;
mq_receive(queue, buff, sizeof(buff), &priority);
}
}
do { \
if (mq_send(queue, buff, MSG_SIZE, prio_out)) \
shutdown(3, "Test send failure", __LINE__); \
- } while(0)
+ } while (0)
#define do_send_recv() \
do { \
void inc_prio(int *prio)
{
if (++*prio == mq_prio_max)
- *prio = 0;;
+ *prio = 0;
}
void dec_prio(int *prio)
t = &cpu_threads[0];
printf("\n\tStarted mqueue performance test thread on CPU %d\n",
cpus_to_pin[0]);
- if ((mq_prio_max = sysconf(_SC_MQ_PRIO_MAX)) == -1)
+ mq_prio_max = sysconf(_SC_MQ_PRIO_MAX);
+ if (mq_prio_max == -1)
shutdown(2, "sysconf(_SC_MQ_PRIO_MAX)", __LINE__);
if (pthread_getcpuclockid(cpu_threads[0], &clock) != 0)
shutdown(2, "pthread_getcpuclockid", __LINE__);
- printf("\n\tTest #1: Time send/recv message, queue "
- "empty\n");
+ printf("\n\tTest #1: Time send/recv message, queue empty\n");
printf("\t\t(%d iterations)\n", TEST1_LOOPS);
prio_out = 0;
send_total.tv_sec = 0;
cur_limits.rlim_cur = RLIM_INFINITY;
cur_limits.rlim_max = RLIM_INFINITY;
setr(RLIMIT_MSGQUEUE, &cur_limits);
- while (try_set(max_msgs, cur_max_msgs += 10));
+ while (try_set(max_msgs, cur_max_msgs += 10))
+ ;
cur_max_msgs = get(max_msgs);
- while (try_set(max_msgsize, cur_max_msgsize += 1024));
+ while (try_set(max_msgsize, cur_max_msgsize += 1024))
+ ;
cur_max_msgsize = get(max_msgsize);
if (setpriority(PRIO_PROCESS, 0, -20) != 0)
shutdown(2, "setpriority()", __LINE__);
exit(1);
}
cpus_online = min(MAX_CPUS, sysconf(_SC_NPROCESSORS_ONLN));
- if ((cpu_set = CPU_ALLOC(cpus_online)) == NULL) {
+ cpu_set = CPU_ALLOC(cpus_online);
+ if (cpu_set == NULL) {
perror("CPU_ALLOC()");
exit(1);
}
(continuous_mode_fake ? "fake mode" : "enabled") :
"disabled");
printf("\tCPUs to pin:\t\t\t\t%d", cpus_to_pin[0]);
- for(cpu=1; cpu < num_cpus_to_pin; cpu++)
+ for (cpu = 1; cpu < num_cpus_to_pin; cpu++)
printf(",%d", cpus_to_pin[cpu]);
printf("\n");
attr.mq_msgsize = MSG_SIZE;
open_queue(&attr);
}
- for (i=0; i < num_cpus_to_pin; i++) {
+ for (i = 0; i < num_cpus_to_pin; i++) {
pthread_attr_t thread_attr;
void *thread_func;
if (!continuous_mode) {
pthread_join(cpu_threads[0], &retval);
shutdown((long)retval, "perf_test_thread()", __LINE__);
- } else
- while(1) sleep(1);
- shutdown(0,"",0);
+ } else {
+ while (1)
+ sleep(1);
+ }
+ shutdown(0, "", 0);
}