summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/tests/threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/tests/threads.c')
-rw-r--r--nsprpub/pr/tests/threads.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/nsprpub/pr/tests/threads.c b/nsprpub/pr/tests/threads.c
index 1b9b133d9..4a28dc6e5 100644
--- a/nsprpub/pr/tests/threads.c
+++ b/nsprpub/pr/tests/threads.c
@@ -16,7 +16,7 @@ PRInt32 count, iterations, alive;
PRBool debug_mode = PR_FALSE, passed = PR_TRUE;
-void
+void
PR_CALLBACK
ReallyDumbThread(void *arg)
{
@@ -42,7 +42,7 @@ DumbThread(void *arg)
if (!thr) {
if (debug_mode) {
printf("Could not create really dumb thread (%d, %d)!\n",
- PR_GetError(), PR_GetOSError());
+ PR_GetError(), PR_GetOSError());
}
passed = PR_FALSE;
} else {
@@ -65,8 +65,8 @@ static void CreateThreads(PRThreadScope scope1, PRThreadScope scope2)
alive = count;
for (n=0; n<count; n++) {
thr = PR_CreateThread(PR_USER_THREAD,
- DumbThread,
- (void *)scope2,
+ DumbThread,
+ (void *)scope2,
PR_PRIORITY_NORMAL,
scope1,
PR_UNJOINABLE_THREAD,
@@ -74,12 +74,12 @@ static void CreateThreads(PRThreadScope scope1, PRThreadScope scope2)
if (!thr) {
if (debug_mode) {
printf("Could not create dumb thread (%d, %d)!\n",
- PR_GetError(), PR_GetOSError());
+ PR_GetError(), PR_GetOSError());
}
passed = PR_FALSE;
alive--;
}
-
+
PR_Sleep(0);
}
@@ -90,7 +90,7 @@ static void CreateThreads(PRThreadScope scope1, PRThreadScope scope2)
}
PR_ExitMonitor(mon);
- PR_DestroyMonitor(mon);
+ PR_DestroyMonitor(mon);
}
static void CreateThreadsUU(void)
@@ -137,37 +137,43 @@ int main(int argc, char **argv)
PR_STDIO_INIT();
PR_Init(PR_USER_THREAD, PR_PRIORITY_HIGH, 0);
-
+
{
- PLOptStatus os;
- PLOptState *opt = PL_CreateOptState(argc, argv, "dc:i:");
- while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
+ PLOptStatus os;
+ PLOptState *opt = PL_CreateOptState(argc, argv, "dc:i:");
+ while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
- if (PL_OPT_BAD == os) continue;
+ if (PL_OPT_BAD == os) {
+ continue;
+ }
switch (opt->option)
{
- case 'd': /* debug mode */
- debug_mode = PR_TRUE;
- break;
- case 'c': /* loop counter */
- count = atoi(opt->value);
- break;
- case 'i': /* loop counter */
- iterations = atoi(opt->value);
- break;
- default:
- break;
+ case 'd': /* debug mode */
+ debug_mode = PR_TRUE;
+ break;
+ case 'c': /* loop counter */
+ count = atoi(opt->value);
+ break;
+ case 'i': /* loop counter */
+ iterations = atoi(opt->value);
+ break;
+ default:
+ break;
}
}
- PL_DestroyOptState(opt);
+ PL_DestroyOptState(opt);
}
- if (0 == count) count = 50;
- if (0 == iterations) iterations = 10;
+ if (0 == count) {
+ count = 50;
+ }
+ if (0 == iterations) {
+ iterations = 10;
+ }
if (debug_mode)
{
- printf("\
+ printf("\
** Tests lots of thread creations. \n\
** Create %ld native threads %ld times. \n\
** Create %ld user threads %ld times \n", iterations,count,iterations,count);
@@ -180,7 +186,9 @@ int main(int argc, char **argv)
Measure(CreateThreadsKK, "Create native/native threads");
}
- if (debug_mode) printf("\nNow switch to recycling threads \n\n");
+ if (debug_mode) {
+ printf("\nNow switch to recycling threads \n\n");
+ }
PR_SetThreadRecycleMode(1);
for (index=0; index<iterations; index++) {