Skip to content

Commit

Permalink
Update stress.c
Browse files Browse the repository at this point in the history
minor formatting of comments etc.
  • Loading branch information
cooljeanius committed Dec 28, 2020
1 parent fcf9085 commit 36d1f1b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/stress.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* stress.c: A program to put stress on a POSIX system (stress).
/* stress.c: A program to put stress on a POSIX system (stress). -*- C -*-
*
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010
* Amos Waterland <[email protected]>
Expand Down Expand Up @@ -33,13 +33,13 @@
#include "../config.h"
#include "stress.h"

/* By default, print all messages of severity info and above. */
/* By default, print all messages of severity info and above: */
static int global_debug = 2;

/* Name of this program */
static char *global_progname = PACKAGE;

/* Implemention of runtime-selectable severity message printing. */
/* Macros for implemention of runtime-selectable severity message printing: */
#define dbg(OUT, STR, ARGS...) if (global_debug >= 3) \
fprintf(stdout, "%s: dbug: [%lli] ", \
global_progname, (long long)getpid()), \
Expand All @@ -59,8 +59,8 @@ static char *global_progname = PACKAGE;

/* Implementation of check for option argument correctness. */
#define assert_arg(A) \
if (++i == argc || ((arg = argv[i])[0] == '-' && \
!isdigit ((int)arg[1]) )) \
if ((++i == argc) || (((arg = argv[i])[0] == '-') && \
!isdigit((int)arg[1]))) \
{ \
err(stderr, "missing argument to option '%s'\n", A); \
exit(1); \
Expand Down Expand Up @@ -100,13 +100,13 @@ main(int argc, char **argv)
long long do_hdd_bytes = (1024 * 1024 * 1024);
/* (1024 * 1024 * 1024) = 1073741824 */

/* Record our start time. */
/* Record our start time: */
if ((starttime = time (NULL)) == -1) {
err(stderr, "failed to acquire current time: %s\n", strerror(errno));
exit(1);
}

/* SuSv3 does not define any error conditions for this function. */
/* SuSv3 does not define any error conditions for this function: */
global_progname = basename(argv[0]);

/* For portability, parse command line options without getopt_long(), and
Expand Down Expand Up @@ -206,33 +206,33 @@ main(int argc, char **argv)
}
}

/* Print startup message if we have work to do, bail otherwise. */
/* Print startup message if we have work to do, bail otherwise: */
if (do_cpu + do_io + do_vm + do_hdd) {
out(stdout, "dispatching hogs: %lli cpu, %lli io, %lli vm, %lli hdd\n",
do_cpu, do_io, do_vm, do_hdd);
} else {
usage(0);
}

/* Round robin dispatch our worker processes. */
/* Round robin dispatch our worker processes: */
while ((forks = (do_cpu + do_io + do_vm + do_hdd))) {
long long backoff, timeout = 0;

/* Calculate the backoff value so we get good fork throughput. */
/* Calculate the backoff value so we get good fork throughput: */
backoff = (do_backoff * forks);
dbg(stdout, "using backoff sleep of %llius\n", backoff);

/* If we are supposed to respect a timeout, calculate it. */
/* If we are supposed to respect a timeout, calculate it: */
if (do_timeout) {
long long currenttime;

/* Acquire current time. */
/* Acquire current time: */
if ((currenttime = time(NULL)) == -1) {
perror("error acquiring current time");
exit(1);
}

/* Calculate timeout based on current time. */
/* Calculate timeout based on current time: */
timeout = (do_timeout - (currenttime - starttime));

if (timeout > 0) {
Expand Down Expand Up @@ -322,7 +322,7 @@ main(int argc, char **argv)
}
}

/* Wait for our children to exit. */
/* Wait for our children to exit: */
while (children) {
int status, ret;

Expand Down Expand Up @@ -370,16 +370,16 @@ main(int argc, char **argv)
}
}

/* Record our stop time. */
/* Record our stop time: */
if ((stoptime = time(NULL)) == -1) {
err(stderr, "failed to acquire current time\n");
exit(1);
}

/* Calculate our runtime. */
/* Calculate our runtime: */
runtime = (stoptime - starttime);

/* Print final status message. */
/* Print final status message: */
if (retval) {
err(stderr, "failed run completed in %lis\n", runtime);
} else {
Expand Down Expand Up @@ -471,7 +471,7 @@ hoghdd(long long bytes)
int chunk = ((1024 * 1024) - 1); /* Minimize slow writing. */
char buff[chunk];

/* Initialize buffer with some random ASCII data. */
/* Initialize buffer with some random ASCII data: */
dbg(stdout, "seeding %d byte buffer with random data\n", chunk);
for ((i = 0); (i < (chunk - 1)); i++) {
j = rand();
Expand Down

0 comments on commit 36d1f1b

Please sign in to comment.