clang-format

This commit is contained in:
2024-09-10 13:03:02 -04:00
parent 53c617d779
commit d66450e427
381 changed files with 28864 additions and 34170 deletions

View File

@@ -36,35 +36,29 @@
#include <synch.h>
#include <test.h>
#define NTHREADS 8
#define NTHREADS 8
static struct semaphore *tsem = NULL;
static
void
init_sem(void)
{
if (tsem==NULL) {
tsem = sem_create("tsem", 0);
if (tsem == NULL) {
panic("threadtest: sem_create failed\n");
}
}
static void init_sem(void) {
if (tsem == NULL) {
tsem = sem_create("tsem", 0);
if (tsem == NULL) {
panic("threadtest: sem_create failed\n");
}
}
}
static
void
loudthread(void *junk, unsigned long num)
{
int ch = '0' + num;
int i;
static void loudthread(void *junk, unsigned long num) {
int ch = '0' + num;
int i;
(void)junk;
(void)junk;
for (i=0; i<120; i++) {
putch(ch);
}
V(tsem);
for (i = 0; i < 120; i++) {
putch(ch);
}
V(tsem);
}
/*
@@ -77,70 +71,58 @@ loudthread(void *junk, unsigned long num)
* The delay loop is supposed to be long enough that it should be clear
* if either timeslicing or the scheduler is not working right.
*/
static
void
quietthread(void *junk, unsigned long num)
{
int ch = '0' + num;
volatile int i;
static void quietthread(void *junk, unsigned long num) {
int ch = '0' + num;
volatile int i;
(void)junk;
(void)junk;
putch(ch);
for (i=0; i<200000; i++);
putch(ch);
putch(ch);
for (i = 0; i < 200000; i++)
;
putch(ch);
V(tsem);
V(tsem);
}
static
void
runthreads(int doloud)
{
char name[16];
int i, result;
static void runthreads(int doloud) {
char name[16];
int i, result;
for (i=0; i<NTHREADS; i++) {
snprintf(name, sizeof(name), "threadtest%d", i);
result = thread_fork(name, NULL,
doloud ? loudthread : quietthread,
NULL, i);
if (result) {
panic("threadtest: thread_fork failed %s)\n",
strerror(result));
}
}
for (i = 0; i < NTHREADS; i++) {
snprintf(name, sizeof(name), "threadtest%d", i);
result =
thread_fork(name, NULL, doloud ? loudthread : quietthread, NULL, i);
if (result) {
panic("threadtest: thread_fork failed %s)\n", strerror(result));
}
}
for (i=0; i<NTHREADS; i++) {
P(tsem);
}
for (i = 0; i < NTHREADS; i++) {
P(tsem);
}
}
int threadtest(int nargs, char **args) {
(void)nargs;
(void)args;
int
threadtest(int nargs, char **args)
{
(void)nargs;
(void)args;
init_sem();
kprintf("Starting thread test...\n");
runthreads(1);
kprintf("\nThread test done.\n");
init_sem();
kprintf("Starting thread test...\n");
runthreads(1);
kprintf("\nThread test done.\n");
return 0;
return 0;
}
int
threadtest2(int nargs, char **args)
{
(void)nargs;
(void)args;
int threadtest2(int nargs, char **args) {
(void)nargs;
(void)args;
init_sem();
kprintf("Starting thread test 2...\n");
runthreads(0);
kprintf("\nThread test 2 done.\n");
init_sem();
kprintf("Starting thread test 2...\n");
runthreads(0);
kprintf("\nThread test 2 done.\n");
return 0;
return 0;
}