From: Scott Schwartz schwartz@galapagos.cse.psu.edu
Subject: more microbenchmarks, threads
Date: Sat, 9 Dec 1995 00:22:44 -0500 [thread overview]
Message-ID: <19951209052244.glUNMCgKizwFbvls9TTpujdMI8uUfXoim-Qom1Rm66w@z> (raw)
Over on comp.programming.threads there's been some discussion of thread
performance under solaris based on some small programs that exercise
thread creation. (See Steve Rogers' <steve@ct.picker.com>
Message-ID: <1995Dec6.125003.2562@picker.com>, and subsequent.)
Inspired to comparare, I ran one of those programs on a Sparcstation 2
with Solaris. Then I translated it---accurately I hope, although
rendezvous() isn't quite the same as a semaphore---for Plan 9, and ran
it on another SS2. The results were about the same, except that under
Plan 9 real time was much greater than user+system. Is the time
getting lost during scheduling, or something like that?
term% time k.out
COUNTER: 10000
0.20u 9.78s 43.26r k.out
#include <u.h>
#include <libc.h>
#include <lock.h>
#define ITERATIONS 1000
#define MAX_THREAD 10
static Lock mutex;
static int counter = 0;
void thread_func(void)
{
lock(&mutex);
counter++;
if ((counter % MAX_THREAD) == 0) {
rendezvous(0, 1);
}
unlock(&mutex);
}
int thr_create (void (*func)(void))
{
int pid = rfork(RFPROC|RFMEM|RFNOWAIT);
switch (pid) {
case -1:
fprint(2, "rfork failed: %r\n");
exits("rfork");
case 0:
(*func)();
exits(0);
default:
return pid;
}
}
void main(int argc, char *argv[])
{
int ii, jj;
int pid;
counter = 0;
lockinit();
for ( ii = 0; ii < ITERATIONS; ii++ ) {
for ( jj = 0; jj < MAX_THREAD; jj++ ) {
pid = thr_create(thread_func);
}
rendezvous(0, 0);
}
fprint(2, "COUNTER: %d\n", counter);
exits(0);
}
reply other threads:[~1995-12-09 5:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19951209052244.glUNMCgKizwFbvls9TTpujdMI8uUfXoim-Qom1Rm66w@z \
--to=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).