clang-format
This commit is contained in:
@@ -48,12 +48,11 @@
|
||||
* some more of your own.
|
||||
*/
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NTHREADS 3
|
||||
#define MAX 1<<25
|
||||
#define NTHREADS 3
|
||||
#define MAX 1 << 25
|
||||
|
||||
/* counter for the loop in the threads:
|
||||
This variable is shared and incremented by each
|
||||
@@ -64,23 +63,21 @@ volatile int count = 0;
|
||||
void ThreadRunner(void);
|
||||
void BladeRunner(void);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
for (i=0; i<NTHREADS; i++) {
|
||||
if (i)
|
||||
threadfork(ThreadRunner);
|
||||
else
|
||||
threadfork(BladeRunner);
|
||||
}
|
||||
for (i = 0; i < NTHREADS; i++) {
|
||||
if (i)
|
||||
threadfork(ThreadRunner);
|
||||
else
|
||||
threadfork(BladeRunner);
|
||||
}
|
||||
|
||||
printf("Parent has left.\n");
|
||||
return 0;
|
||||
printf("Parent has left.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* multiple threads will simply print out the global variable.
|
||||
@@ -88,22 +85,18 @@ main(int argc, char *argv[])
|
||||
random results.
|
||||
*/
|
||||
|
||||
void
|
||||
BladeRunner()
|
||||
{
|
||||
while (count < MAX) {
|
||||
if (count % 500 == 0)
|
||||
printf("Blade ");
|
||||
count++;
|
||||
}
|
||||
void BladeRunner() {
|
||||
while (count < MAX) {
|
||||
if (count % 500 == 0)
|
||||
printf("Blade ");
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ThreadRunner()
|
||||
{
|
||||
while (count < MAX) {
|
||||
if (count % 513 == 0)
|
||||
printf(" Runner\n");
|
||||
count++;
|
||||
}
|
||||
void ThreadRunner() {
|
||||
while (count < MAX) {
|
||||
if (count % 513 == 0)
|
||||
printf(" Runner\n");
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user